Skip to content

Commit

Permalink
[TASK] Fix some annotations and remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Jan 25, 2025
1 parent d7f36f0 commit 34f9678
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ public function initializeArguments(): void

public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
{
if (!is_array($arguments)) {
return false;
}

/** @var ReflectionService $reflectionService */
$reflectionService = GeneralUtility::makeInstance(ReflectionService::class);

/** @var string $property */
$property = $arguments['property'];
$validatorName = $arguments['validatorName'] ?? null;
/** @var array|object $object */
$object = $arguments['object'] ?? null;

$path = null;
Expand Down
3 changes: 0 additions & 3 deletions Classes/ViewHelpers/Condition/Page/HasSubpagesViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public function initializeArguments(): void

public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
{
if (!is_array($arguments)) {
return false;
}
/** @var int $pageUid */
$pageUid = $arguments['pageUid'];
$includeHiddenInMenu = (boolean) $arguments['includeHiddenInMenu'];
Expand Down
3 changes: 0 additions & 3 deletions Classes/ViewHelpers/Condition/Page/IsLanguageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public function initializeArguments(): void

public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
{
if (!is_array($arguments)) {
return false;
}
/** @var string $language */
$language = $arguments['language'];
/** @var string $defaultTitle */
Expand Down
4 changes: 4 additions & 0 deletions Classes/ViewHelpers/DebugViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ public function render()
}
if (0 < count($this->childObjectAccessorNodes)) {
$nodes[] = '[VARIABLE ACCESSORS]';
/** @var array|object $templateVariables */
$templateVariables = $this->renderingContext->getVariableProvider()->getAll();
foreach ($this->childObjectAccessorNodes as $objectAccessorNode) {
$path = $objectAccessorNode->getObjectPath();
$segments = explode('.', $path);
try {
$value = ObjectAccess::getProperty($templateVariables, array_shift($segments));
foreach ($segments as $segment) {
if (!is_array($value) && !is_object($value)) {
break;
}
$value = ObjectAccess::getProperty($value, $segment);
}
$type = gettype($value);
Expand Down
3 changes: 0 additions & 3 deletions Classes/ViewHelpers/Extension/LoadedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public function initializeArguments(): void

public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
{
if (!is_array($arguments)) {
return false;
}
/** @var string $extensionName */
$extensionName = $arguments['extensionName'];
$extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
Expand Down
3 changes: 3 additions & 0 deletions Classes/ViewHelpers/Iterator/LoopViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function initializeArguments(): void
$this->registerArgument('maximum', 'integer', 'Maxiumum number of loops before stopping', false, PHP_INT_MAX);
}

/**
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Iterator/SortViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected static function sortObjectStorage($storage, $arguments)
/**
* Gets the value to use as sorting value from $object
*
* @param mixed $object
* @param array|object $object
* @param array $arguments
* @return mixed
*/
Expand Down
1 change: 1 addition & 0 deletions Classes/ViewHelpers/Render/AbstractRenderViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected static function getPreparedClonedView(RenderingContextInterface $rende
protected static function renderView($view, array $arguments): string
{
try {
/** @var string|null $content */
$content = $view->render();
} catch (\Exception $error) {
if (!($arguments['graceful'] ?? false)) {
Expand Down
3 changes: 3 additions & 0 deletions Classes/ViewHelpers/Variable/GetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static function renderStatic(
$lastSegment = array_shift($segments);
$templateVariableRootName = $lastSegment;
if ($variableProvider->exists($templateVariableRootName)) {
/** @var array|object $templateVariableRoot */
$templateVariableRoot = $variableProvider->get($templateVariableRootName);
if ($useRawKeys) {
return ObjectAccess::getPropertyPath($templateVariableRoot, implode('.', $segments));
Expand All @@ -103,6 +104,7 @@ public static function renderStatic(
/** @var iterable $value */
foreach ($value as $possibleValue) {
if ($index === $segment) {
/** @var array|object $value */
$value = $possibleValue;
$found = true;
break;
Expand All @@ -114,6 +116,7 @@ public static function renderStatic(
}
continue;
}
/** @var array|object $value */
$value = ObjectAccess::getProperty($value, $segment);
}
return $value;
Expand Down

0 comments on commit 34f9678

Please sign in to comment.