Skip to content

Commit

Permalink
[TASK] Minor Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed May 17, 2023
1 parent 46e6e38 commit f625b56
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Classes/AvatarProvider/GravatarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getAvatarUrl(Author $author, int $size): string
$default = trim($default = (string)($settings['authors']['avatar']['provider']['default'] ?? '')) === '' ? null : $default;

$gravatarUri = $this->gravatarUriBuilder->getUri(
$author->getEmail(),
$author->getEmail() ?? '',
$size,
$rating,
$default
Expand All @@ -91,7 +91,7 @@ public function getAvatarUrl(Author $author, int $size): string
$absoluteWebPath = PathUtility::getAbsoluteWebPath($filePath);

if (file_exists($filePath)) {
if (hash_equals(md5_file($filePath), md5($gravatar->getContent()))) {
if (hash_equals((string) md5_file($filePath), md5($gravatar->getContent()))) {
return $absoluteWebPath;
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/AvatarProvider/ImageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function getAvatarUrl(Author $author, int $size): string
$imageService = GeneralUtility::makeInstance(ImageService::class);
$image = $imageService->getImage('', $image, false);

if ($image->hasProperty('crop') && $image->getProperty('crop')) {
$cropString = '';
if ($image->hasProperty('crop') && $image->getProperty('crop') !== '') {
$cropString = $image->getProperty('crop');
}
$cropVariantCollection = CropVariantCollection::create((string)$cropString);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Backend/View/BlogPostHeaderContentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
public function render(ServerRequestInterface $request): string
{
$blogConfiguration = $this->extensionConfiguration->get('blog');
if ((bool)($blogConfiguration['disablePageLayoutHeader']) ?? true) {
if ((bool)($blogConfiguration['disablePageLayoutHeader'] ?? true)) {
return '';
}

Expand Down
12 changes: 6 additions & 6 deletions Classes/Controller/WidgetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public function tagsAction(): ResponseInterface
if (!(bool)($requestParameters['tag'] ?? null)) {
$currentTag = (int)$requestParameters['tag'];
}
$limit = (int)$this->settings['widgets']['tags']['limit'] ?? 20;
$minSize = (int)$this->settings['widgets']['tags']['minSize'] ?? 100;
$maxSize = (int)$this->settings['widgets']['tags']['maxSize'] ?? 100;
$limit = (int)($this->settings['widgets']['tags']['limit'] ?? 20);
$minSize = (int)($this->settings['widgets']['tags']['minSize'] ?? 100);
$maxSize = (int)($this->settings['widgets']['tags']['maxSize'] ?? 100);
$tags = $this->tagRepository->findTopByUsage($limit);
$minimumCount = null;
$maximumCount = 0;
Expand Down Expand Up @@ -150,7 +150,7 @@ public function tagsAction(): ResponseInterface
*/
public function recentPostsAction(): ResponseInterface
{
$limit = (int)$this->settings['widgets']['recentposts']['limit'] ?? 0;
$limit = (int)($this->settings['widgets']['recentposts']['limit'] ?? 0);

$posts = $limit > 0
? $this->postRepository->findAllWithLimit($limit)
Expand All @@ -169,8 +169,8 @@ public function recentPostsAction(): ResponseInterface
*/
public function commentsAction(): ResponseInterface
{
$limit = (int)$this->settings['widgets']['comments']['limit'] ?? 5;
$blogSetup = (int)$this->settings['widgets']['comments']['blogSetup'] ?? null;
$limit = (int)($this->settings['widgets']['comments']['limit'] ?? 5);
$blogSetup = isset($this->settings['widgets']['comments']['blogSetup']) ? (int) $this->settings['widgets']['comments']['blogSetup'] : null;
$comments = $this->commentRepository->findActiveComments($limit, $blogSetup);
$this->view->assign('comments', $comments);
foreach ($comments as $comment) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Notification/CommentAddedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getTitle(): string
{
/** @var Post $post */
$post = $this->data['post'];
return sprintf(LocalizationUtility::translate('emails.CommentAddedNotification.subject', 'blog'), $post->getTitle());
return sprintf((string)LocalizationUtility::translate('emails.CommentAddedNotification.subject', 'blog'), $post->getTitle());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/CommentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function addComment(Post $post, Comment $comment): string
break;
default:
}
$comment->setPid($post->getUid());
$comment->setPid((int)$post->getUid());
$comment->setPostLanguageId(GeneralUtility::makeInstance(Context::class)->getAspect('language')->getId());
$post->addComment($comment);
$this->postRepository->update($post);
Expand Down

0 comments on commit f625b56

Please sign in to comment.