From a013dfdc1b99c1b33a9e7fa41ecc10daada9249c Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Wed, 20 Nov 2024 03:16:00 +0100 Subject: [PATCH] [TASK] Avoid useless parent calls There is no point in calling parent::initializeArguments() when we know the parent method is an empty dummy method that will most likely never have a body since that would break too much. --- phpstan-baseline.neon | 114 ------------------ src/ViewHelpers/AliasViewHelper.php | 1 - src/ViewHelpers/CaseViewHelper.php | 1 - src/ViewHelpers/ConstantViewHelper.php | 1 - src/ViewHelpers/CountViewHelper.php | 1 - src/ViewHelpers/CycleViewHelper.php | 1 - src/ViewHelpers/DebugViewHelper.php | 1 - src/ViewHelpers/ForViewHelper.php | 1 - .../Format/HtmlspecialcharsViewHelper.php | 1 - src/ViewHelpers/Format/PrintfViewHelper.php | 1 - src/ViewHelpers/GroupedForViewHelper.php | 1 - src/ViewHelpers/RenderViewHelper.php | 1 - src/ViewHelpers/SwitchViewHelper.php | 1 - ...tNameForContentInConstructorViewHelper.php | 1 - ...lveContentArgumentNameMethodViewHelper.php | 1 - ...iredArgumentAsRenderChildrenViewHelper.php | 1 - ...onalArgumentAsRenderChildrenViewHelper.php | 1 - .../ContentArgumentNameViewHelper.php | 1 - ...entNameWithoutEscapeChildrenViewHelper.php | 1 - .../ViewHelpers/CompilableViewHelper.php | 1 - 20 files changed, 133 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 69006267b..3436db1fd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -72,126 +72,12 @@ parameters: count: 2 path: src/View/TemplatePaths.php - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/AliasViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/CaseViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/ConstantViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/CountViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/CycleViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/DebugViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/ForViewHelper.php - - message: '#^Variable \$iterationData might not be defined\.$#' identifier: variable.undefined count: 1 path: src/ViewHelpers/ForViewHelper.php - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/Format/HtmlspecialcharsViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/Format/PrintfViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/GroupedForViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/RenderViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: src/ViewHelpers/SwitchViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentInConstructorViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentOverriddenResolveContentArgumentNameMethodViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgumentAfterRequiredArgumentAsRenderChildrenViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalArgumentAsRenderChildrenViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameWithoutEscapeChildrenViewHelper.php - - - - message: '#^Call to TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper\:\:initializeArguments\(\) on a separate line has no effect\.$#' - identifier: staticMethod.resultUnused - count: 1 - path: tests/Functional/ViewHelpers/StaticCacheable/Fixtures/ViewHelpers/CompilableViewHelper.php - - message: '#^Unreachable statement \- code above always terminates\.$#' identifier: deadCode.unreachable diff --git a/src/ViewHelpers/AliasViewHelper.php b/src/ViewHelpers/AliasViewHelper.php index 6f18235d9..a7f8d8476 100644 --- a/src/ViewHelpers/AliasViewHelper.php +++ b/src/ViewHelpers/AliasViewHelper.php @@ -63,7 +63,6 @@ class AliasViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('map', 'array', 'Array that specifies which variables should be mapped to which alias', true); } diff --git a/src/ViewHelpers/CaseViewHelper.php b/src/ViewHelpers/CaseViewHelper.php index 6361af37a..db90a3c3f 100644 --- a/src/ViewHelpers/CaseViewHelper.php +++ b/src/ViewHelpers/CaseViewHelper.php @@ -28,7 +28,6 @@ class CaseViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('value', 'mixed', 'Value to match in this case', true); } diff --git a/src/ViewHelpers/ConstantViewHelper.php b/src/ViewHelpers/ConstantViewHelper.php index 70ceb54a2..9d571abdd 100644 --- a/src/ViewHelpers/ConstantViewHelper.php +++ b/src/ViewHelpers/ConstantViewHelper.php @@ -46,7 +46,6 @@ class ConstantViewHelper extends AbstractViewHelper { public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('name', 'string', 'String representation of a PHP constant or enum'); } diff --git a/src/ViewHelpers/CountViewHelper.php b/src/ViewHelpers/CountViewHelper.php index 23a5a2be4..058ed0c0a 100644 --- a/src/ViewHelpers/CountViewHelper.php +++ b/src/ViewHelpers/CountViewHelper.php @@ -54,7 +54,6 @@ class CountViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('subject', 'array', 'Countable subject, array or \Countable'); } diff --git a/src/ViewHelpers/CycleViewHelper.php b/src/ViewHelpers/CycleViewHelper.php index f9a61243f..720ea1bf0 100644 --- a/src/ViewHelpers/CycleViewHelper.php +++ b/src/ViewHelpers/CycleViewHelper.php @@ -73,7 +73,6 @@ class CycleViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('values', 'array', 'The array or object implementing \ArrayAccess (for example \SplObjectStorage) to iterated over'); $this->registerArgument('as', 'string', 'The name of the iteration variable', true); } diff --git a/src/ViewHelpers/DebugViewHelper.php b/src/ViewHelpers/DebugViewHelper.php index 0a2d3929b..03e6300df 100644 --- a/src/ViewHelpers/DebugViewHelper.php +++ b/src/ViewHelpers/DebugViewHelper.php @@ -54,7 +54,6 @@ class DebugViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('typeOnly', 'boolean', 'If true, debugs only the type of variables', false, false); $this->registerArgument('levels', 'integer', 'Levels to render when rendering nested objects/arrays', false, 5); $this->registerArgument('html', 'boolean', 'Render HTML. If false, output is indented plaintext', false, false); diff --git a/src/ViewHelpers/ForViewHelper.php b/src/ViewHelpers/ForViewHelper.php index 1a7034917..734294f1d 100644 --- a/src/ViewHelpers/ForViewHelper.php +++ b/src/ViewHelpers/ForViewHelper.php @@ -83,7 +83,6 @@ class ForViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('each', 'array', 'The array or \SplObjectStorage to iterated over', true); $this->registerArgument('as', 'string', 'The name of the iteration variable', true); $this->registerArgument('key', 'string', 'Variable to assign array key to'); diff --git a/src/ViewHelpers/Format/HtmlspecialcharsViewHelper.php b/src/ViewHelpers/Format/HtmlspecialcharsViewHelper.php index 8e7cd11ae..a6feaeaf1 100644 --- a/src/ViewHelpers/Format/HtmlspecialcharsViewHelper.php +++ b/src/ViewHelpers/Format/HtmlspecialcharsViewHelper.php @@ -59,7 +59,6 @@ class HtmlspecialcharsViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('value', 'string', 'Value to format'); $this->registerArgument('keepQuotes', 'boolean', 'If true quotes will not be replaced (ENT_NOQUOTES)', false, false); $this->registerArgument('encoding', 'string', 'Encoding', false, 'UTF-8'); diff --git a/src/ViewHelpers/Format/PrintfViewHelper.php b/src/ViewHelpers/Format/PrintfViewHelper.php index be2792ced..f4f6c633e 100644 --- a/src/ViewHelpers/Format/PrintfViewHelper.php +++ b/src/ViewHelpers/Format/PrintfViewHelper.php @@ -70,7 +70,6 @@ class PrintfViewHelper extends AbstractViewHelper { public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('value', 'string', 'String to format'); $this->registerArgument('arguments', 'array', 'The arguments for vsprintf', false, []); } diff --git a/src/ViewHelpers/GroupedForViewHelper.php b/src/ViewHelpers/GroupedForViewHelper.php index ff428d6c4..27f50b002 100644 --- a/src/ViewHelpers/GroupedForViewHelper.php +++ b/src/ViewHelpers/GroupedForViewHelper.php @@ -94,7 +94,6 @@ class GroupedForViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('each', 'array', 'The array or \SplObjectStorage to iterated over', true); $this->registerArgument('as', 'string', 'The name of the iteration variable', true); $this->registerArgument('groupBy', 'string', 'Group by this property', true); diff --git a/src/ViewHelpers/RenderViewHelper.php b/src/ViewHelpers/RenderViewHelper.php index e858132c5..f4e17bd1f 100644 --- a/src/ViewHelpers/RenderViewHelper.php +++ b/src/ViewHelpers/RenderViewHelper.php @@ -113,7 +113,6 @@ class RenderViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('section', 'string', 'Section to render - combine with partial to render section in partial'); $this->registerArgument('partial', 'string', 'Partial to render, with or without section'); $this->registerArgument('delegate', 'string', 'Optional PHP class name of a permanent, included-in-app ParsedTemplateInterface implementation to override partial/section'); diff --git a/src/ViewHelpers/SwitchViewHelper.php b/src/ViewHelpers/SwitchViewHelper.php index 7aa57f111..9c132b44e 100644 --- a/src/ViewHelpers/SwitchViewHelper.php +++ b/src/ViewHelpers/SwitchViewHelper.php @@ -64,7 +64,6 @@ class SwitchViewHelper extends AbstractViewHelper public function initializeArguments() { - parent::initializeArguments(); $this->registerArgument('expression', 'mixed', 'Expression to switch', true); } diff --git a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentInConstructorViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentInConstructorViewHelper.php index 4ee0c9f7a..bee39c4f9 100644 --- a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentInConstructorViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentInConstructorViewHelper.php @@ -31,7 +31,6 @@ public function __construct() public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('firstOptionalArgument', 'string', 'First optional argument which is used as render children.'); $this->registerArgument('secondOptionalArgument', 'string', 'Second optional argument which is used as render children.'); } diff --git a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentOverriddenResolveContentArgumentNameMethodViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentOverriddenResolveContentArgumentNameMethodViewHelper.php index ee123d8df..56973ef3e 100644 --- a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentOverriddenResolveContentArgumentNameMethodViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticExplicitSetArgumentNameForContentOverriddenResolveContentArgumentNameMethodViewHelper.php @@ -27,7 +27,6 @@ public function __construct() {} public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('firstOptionalArgument', 'string', 'First optional argument which is used as render children.'); $this->registerArgument('secondOptionalArgument', 'string', 'Second optional argument which is used as render children.'); } diff --git a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgumentAfterRequiredArgumentAsRenderChildrenViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgumentAfterRequiredArgumentAsRenderChildrenViewHelper.php index d0d42b6bc..673343290 100644 --- a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgumentAfterRequiredArgumentAsRenderChildrenViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgumentAfterRequiredArgumentAsRenderChildrenViewHelper.php @@ -25,7 +25,6 @@ final class CompileWithContentArgumentAndRenderStaticFirstRegisteredOptionalArgu public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('requiredArgument', 'string', 'demo required argument before optional argument', true); $this->registerArgument('firstOptionalArgument', 'string', 'First optional argument which is used as render children.'); } diff --git a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalArgumentAsRenderChildrenViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalArgumentAsRenderChildrenViewHelper.php index dab7e07b5..9fce6d8eb 100644 --- a/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalArgumentAsRenderChildrenViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalArgumentAsRenderChildrenViewHelper.php @@ -25,7 +25,6 @@ final class CompileWithContentArgumentAndRenderStaticUseFirstRegisteredOptionalA public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('firstOptionalArgument', 'string', 'First optional argument which is used as render children.'); } diff --git a/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameViewHelper.php index 3da7b5f8e..75541666d 100644 --- a/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameViewHelper.php @@ -15,7 +15,6 @@ final class ContentArgumentNameViewHelper extends AbstractViewHelper { public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('value', 'string', ''); } diff --git a/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameWithoutEscapeChildrenViewHelper.php b/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameWithoutEscapeChildrenViewHelper.php index 80673ec62..f217e0f94 100644 --- a/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameWithoutEscapeChildrenViewHelper.php +++ b/tests/Functional/Fixtures/ViewHelpers/ContentArgumentNameWithoutEscapeChildrenViewHelper.php @@ -17,7 +17,6 @@ final class ContentArgumentNameWithoutEscapeChildrenViewHelper extends AbstractV public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('value', 'string', ''); } diff --git a/tests/Functional/ViewHelpers/StaticCacheable/Fixtures/ViewHelpers/CompilableViewHelper.php b/tests/Functional/ViewHelpers/StaticCacheable/Fixtures/ViewHelpers/CompilableViewHelper.php index 3b230ae5b..91e9e03d4 100644 --- a/tests/Functional/ViewHelpers/StaticCacheable/Fixtures/ViewHelpers/CompilableViewHelper.php +++ b/tests/Functional/ViewHelpers/StaticCacheable/Fixtures/ViewHelpers/CompilableViewHelper.php @@ -23,7 +23,6 @@ final class CompilableViewHelper extends AbstractViewHelper */ public function initializeArguments(): void { - parent::initializeArguments(); $this->registerArgument('page', 'int', 'The page'); }