Skip to content

Commit

Permalink
[TASK] Drop some docheader and use ?? instead of ?:
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed May 10, 2023
1 parent cdd6b25 commit 48d26ec
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Classes/AvatarProvider/ImageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getAvatarUrl(Author $author): string

$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
$settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'blog');
$size = ($settings['authors']['avatar']['provider']['size'] ?? $defaultSize) ?: $defaultSize;
$size = ($settings['authors']['avatar']['provider']['size'] ?? $defaultSize) ?? $defaultSize;

$imageService = $objectManager->get(ImageService::class);
$image = $imageService->getImage('', $image, false);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function listByDemandAction(): ResponseInterface
*/
public function listLatestPostsAction(): ResponseInterface
{
$maximumItems = (int) ($this->settings['latestPosts']['limit'] ?: 3);
$maximumItems = (int) ($this->settings['latestPosts']['limit'] ?? 3);
$posts = $this->postRepository->findAllWithLimit($maximumItems);

$this->view->assign('type', 'latest');
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 (!empty($requestParameters['tag'])) {
$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 = (int)$this->settings['widgets']['comments']['blogSetup'] ?? null;
$comments = $this->commentRepository->findActiveComments($limit, $blogSetup);
$this->view->assign('comments', $comments);
foreach ($comments as $comment) {
Expand Down
8 changes: 0 additions & 8 deletions Classes/ViewHelpers/Data/ContentListOptionsViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@ class ContentListOptionsViewHelper extends AbstractViewHelper
{
use CompileWithContentArgumentAndRenderStatic;

/**
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
$this->registerArgument('as', 'string', 'Name of variable to create.');
$this->registerArgument('listType', 'string', 'Plugin Type to Render', true);
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
Expand Down
9 changes: 0 additions & 9 deletions Classes/ViewHelpers/Format/Nl2pViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ class Nl2pViewHelper extends AbstractViewHelper
*/
protected $escapeOutput = false;

/**
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
$this->registerArgument('value', 'string', 'string to format');
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$data = explode('<br>', nl2br($renderChildrenClosure(), false));
Expand Down
9 changes: 0 additions & 9 deletions Classes/ViewHelpers/GravatarViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments Initialization.
*
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -39,9 +33,6 @@ public function initializeArguments(): void
$this->registerArgument('default', 'string', 'The default image for the gravatar, use complete url or one of the default keys');
}

/**
* @return string the HTML <img>-Tag of the gravatar
*/
public function render(): string
{
/** @var GravatarProvider $gravatarProvider */
Expand Down
9 changes: 0 additions & 9 deletions Classes/ViewHelpers/Link/ArchiveViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -38,9 +32,6 @@ public function initializeArguments(): void
$this->registerArgument('rss', 'bool', 'Link to rss version', false, false);
}

/**
* @return string Rendered page URI
*/
public function render(): string
{
$rssFormat = (bool)$this->arguments['rss'];
Expand Down
11 changes: 1 addition & 10 deletions Classes/ViewHelpers/Link/AuthorViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -39,9 +33,6 @@ public function initializeArguments(): void
$this->registerArgument('rss', 'bool', 'Link to rss version', false, false);
}

/**
* @return string Rendered page URI
*/
public function render(): string
{
$rssFormat = (bool)$this->arguments['rss'];
Expand Down Expand Up @@ -109,7 +100,7 @@ protected function getUriBuilder(int $pageUid, array $additionalParams, bool $rs
protected function buildAnchorTag(string $uri, Author $author)
{
if ($uri !== '') {
$linkText = $this->renderChildren() ?: $author->getName();
$linkText = $this->renderChildren() ?? $author->getName();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
return $this->tag->render();
Expand Down
14 changes: 1 addition & 13 deletions Classes/ViewHelpers/Link/Be/AuthorViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -41,12 +35,6 @@ public function initializeArguments(): void
$this->registerArgument('returnUri', 'bool', 'return only uri', false, false);
}

/**
* @return string Rendered page URI
*
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
* @throws \InvalidArgumentException
*/
public function render(): string
{
/** @var Author $author */
Expand All @@ -63,7 +51,7 @@ public function render(): string
if ($this->arguments['returnUri']) {
return $uri;
}
$linkText = $this->renderChildren() ?: $author->getName();
$linkText = $this->renderChildren() ?? $author->getName();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
14 changes: 1 addition & 13 deletions Classes/ViewHelpers/Link/Be/CategoryViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -41,12 +35,6 @@ public function initializeArguments(): void
$this->registerArgument('returnUri', 'bool', 'return only uri', false, false);
}

/**
* @return string Rendered page URI
*
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
* @throws \InvalidArgumentException
*/
public function render(): string
{
/** @var Category $category */
Expand All @@ -63,7 +51,7 @@ public function render(): string
if ($this->arguments['returnUri']) {
return $uri;
}
$linkText = $this->renderChildren() ?: $category->getTitle();
$linkText = $this->renderChildren() ?? $category->getTitle();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
14 changes: 1 addition & 13 deletions Classes/ViewHelpers/Link/Be/CommentViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -41,12 +35,6 @@ public function initializeArguments(): void
$this->registerArgument('returnUri', 'bool', 'return only uri', false, false);
}

/**
* @return string Rendered page URI
*
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
* @throws \InvalidArgumentException
*/
public function render(): string
{
/** @var Comment $comment */
Expand All @@ -63,7 +51,7 @@ public function render(): string
if ($this->arguments['returnUri']) {
return $uri;
}
$linkText = $this->renderChildren() ?: $comment->getComment();
$linkText = $this->renderChildren() ?? $comment->getComment();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
12 changes: 1 addition & 11 deletions Classes/ViewHelpers/Link/Be/PostViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -43,10 +37,6 @@ public function initializeArguments(): void
$this->registerArgument('action', 'string', 'action to link', false, null);
}

/**
* @return string
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function render(): string
{
/** @var Post $post */
Expand Down Expand Up @@ -74,7 +64,7 @@ public function render(): string
return $uri;
}
$title = $post !== null ? $post->getTitle() : LocalizationUtility::translate('backend.message.nopost', 'blog');
$linkText = $this->renderChildren() ?: $title;
$linkText = $this->renderChildren() ?? $title;
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
14 changes: 1 addition & 13 deletions Classes/ViewHelpers/Link/Be/TagViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -41,12 +35,6 @@ public function initializeArguments(): void
$this->registerArgument('returnUri', 'bool', 'return only uri', false, false);
}

/**
* @return string Rendered page URI
*
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
* @throws \InvalidArgumentException
*/
public function render(): string
{
/** @var Tag $tag */
Expand All @@ -63,7 +51,7 @@ public function render(): string
if ($this->arguments['returnUri']) {
return $uri;
}
$linkText = $this->renderChildren() ?: $tag->getTitle();
$linkText = $this->renderChildren() ?? $tag->getTitle();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
11 changes: 1 addition & 10 deletions Classes/ViewHelpers/Link/CategoryViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public function __construct()
parent::__construct();
}

/**
* Arguments initialization.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments(): void
{
parent::initializeArguments();
Expand All @@ -38,9 +32,6 @@ public function initializeArguments(): void
$this->registerArgument('rss', 'bool', 'Link to rss version', false, false);
}

/**
* @return string Rendered page URI
*/
public function render(): string
{
$rssFormat = (bool)$this->arguments['rss'];
Expand All @@ -60,7 +51,7 @@ public function render(): string
$uri = $uriBuilder->uriFor('listPostsByCategory', $arguments, 'Post', 'Blog', 'Category');

if ($uri !== '') {
$linkText = $this->renderChildren() ?: $category->getTitle();
$linkText = $this->renderChildren() ?? $category->getTitle();
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($linkText);
$result = $this->tag->render();
Expand Down
Loading

0 comments on commit 48d26ec

Please sign in to comment.