From 7db03e9d42ae1177cd9dbbcd975518d745e4b9d8 Mon Sep 17 00:00:00 2001 From: Simon Schaufelberger Date: Thu, 7 Apr 2022 16:50:05 +0200 Subject: [PATCH] [TASK] Add return types, parameter types and clean up doc comments --- Classes/Aggregate/AbstractAggregate.php | 15 ++--- .../AbstractInlineContentAggregate.php | 5 +- .../Aggregate/AbstractOverridesAggregate.php | 5 +- Classes/Aggregate/AggregateCollection.php | 8 +-- Classes/Aggregate/BackendPreviewAggregate.php | 16 ++--- .../Aggregate/ContentElementIconAggregate.php | 2 +- .../Aggregate/ContentRenderingAggregate.php | 39 ++---------- .../ExtensionConfigurationAggregate.php | 12 ++-- .../Aggregate/InlineContentCTypeAggregate.php | 2 +- .../InlineContentColPosAggregate.php | 2 +- Classes/Aggregate/LanguageAwareInterface.php | 5 +- Classes/Aggregate/LanguageAwareTrait.php | 5 +- .../NewContentElementWizardAggregate.php | 7 +-- Classes/Aggregate/PhpAwareInterface.php | 9 +-- Classes/Aggregate/PhpAwareTrait.php | 19 +----- .../Aggregate/PlainTextFileAwareInterface.php | 5 +- Classes/Aggregate/PlainTextFileAwareTrait.php | 17 +----- Classes/Aggregate/SqlAwareInterface.php | 5 +- Classes/Aggregate/SqlAwareTrait.php | 18 +----- Classes/Aggregate/TcaAggregate.php | 13 +--- Classes/Aggregate/TcaAwareTrait.php | 25 ++------ .../Aggregate/TtContentOverridesAggregate.php | 4 +- .../BackendFluidCodeGenerator.php | 26 ++------ Classes/CodeGenerator/HtmlCodeGenerator.php | 20 +++---- Classes/Controller/ExportController.php | 59 +++++-------------- .../FileCollection/AbstractFileCollection.php | 10 +--- Classes/FileCollection/FileCollection.php | 7 +-- .../FileCollection/LanguageFileCollection.php | 9 ++- Classes/FileCollection/PhpFileCollection.php | 5 +- .../PlainTextFileCollection.php | 5 +- Classes/FileCollection/SqlFileCollection.php | 5 +- Classes/FlagResolver/AbstractFlagResolver.php | 6 +- Classes/FlagResolver/FlagInterface.php | 12 +--- .../FlagResolver/FlagResolverInterface.php | 6 +- .../PhpFileFlag/ClosureFunctionFlag.php | 8 +-- .../PhpFileFlag/DefinedTypo3ModeFlag.php | 12 +--- .../PhpFileFlag/PhpStartTagFlag.php | 8 +-- .../AbstractExportControllerTestCase.php | 2 +- .../BackendPreview/ExportControllerTest.php | 6 +- .../Configuration/ExportControllerTest.php | 10 ++-- .../DataProvider/ExportControllerTest.php | 26 ++------ .../FlagResolver/PhpFileFlagResolverTest.php | 14 ++--- .../MaskConfiguration/EmptyColumnsTest.php | 2 +- .../EmptyMaskConfigurationTest.php | 2 +- .../ExportControllerTest.php | 2 +- .../Ressources/ExportControllerTest.php | 10 ++-- .../TypoScript/ExportControllerTest.php | 6 +- .../FileCollection/PhpFileCollectionTest.php | 2 +- 48 files changed, 132 insertions(+), 386 deletions(-) diff --git a/Classes/Aggregate/AbstractAggregate.php b/Classes/Aggregate/AbstractAggregate.php index 129ff5e..c1b63c2 100644 --- a/Classes/Aggregate/AbstractAggregate.php +++ b/Classes/Aggregate/AbstractAggregate.php @@ -49,9 +49,6 @@ abstract class AbstractAggregate */ protected $typoScriptFilePath = 'Configuration/TypoScript/'; - /** - * @param array $maskConfiguration - */ public function __construct(array $maskConfiguration) { $this->maskConfiguration = $maskConfiguration; @@ -63,12 +60,12 @@ public function __construct(array $maskConfiguration) /** * Evaluates the configuration and stores necessary Interface information */ - abstract protected function process(); + abstract protected function process(): void; /** * Remove hidden content elements from configuration */ - protected function removeHiddenContentElements() + protected function removeHiddenContentElements(): void { if (empty($this->maskConfiguration['tt_content']['elements'])) { return; @@ -85,7 +82,7 @@ static function (array $element) { /** * Remove core fields from configuration */ - protected function removeCoreFields() + protected function removeCoreFields(): void { foreach ($this->maskConfiguration as $table => $configuration) { if (empty($configuration['tca'])) { @@ -100,11 +97,7 @@ static function ($field) { } } - /** - * @param string $string - * @return string - */ - protected function escapeMaskExtensionKey($string) + protected function escapeMaskExtensionKey(string $string): string { return preg_replace('/(m)ask/i', '${\\1ask}', $string); } diff --git a/Classes/Aggregate/AbstractInlineContentAggregate.php b/Classes/Aggregate/AbstractInlineContentAggregate.php index 7e6ce92..04bafd2 100644 --- a/Classes/Aggregate/AbstractInlineContentAggregate.php +++ b/Classes/Aggregate/AbstractInlineContentAggregate.php @@ -19,10 +19,7 @@ abstract class AbstractInlineContentAggregate extends AbstractAggregate { - /** - * @return array - */ - protected function getAvailableInlineFields() + protected function getAvailableInlineFields(): array { $inlineFields = []; foreach ($this->maskConfiguration as $table => $configuration) { diff --git a/Classes/Aggregate/AbstractOverridesAggregate.php b/Classes/Aggregate/AbstractOverridesAggregate.php index 14014f2..393b48a 100644 --- a/Classes/Aggregate/AbstractOverridesAggregate.php +++ b/Classes/Aggregate/AbstractOverridesAggregate.php @@ -30,10 +30,7 @@ abstract class AbstractOverridesAggregate extends AbstractAggregate implements L */ protected $tcaOverridesFilePath = 'Configuration/TCA/Overrides/'; - /** - * @param array $tableConfiguration - */ - protected function addTableColumns(array $tableConfiguration) + protected function addTableColumns(array $tableConfiguration): void { if (empty($tableConfiguration['columns']) || empty($this->maskConfiguration[$this->table]['tca'])) { return; diff --git a/Classes/Aggregate/AggregateCollection.php b/Classes/Aggregate/AggregateCollection.php index f364066..81c03e1 100644 --- a/Classes/Aggregate/AggregateCollection.php +++ b/Classes/Aggregate/AggregateCollection.php @@ -36,10 +36,6 @@ class AggregateCollection */ protected $maskConfiguration; - /** - * @param array $aggregateClassNames - * @param array $maskConfiguration - */ public function __construct(array $aggregateClassNames, array $maskConfiguration) { $this->aggregateClassNames = $aggregateClassNames; @@ -49,7 +45,7 @@ public function __construct(array $aggregateClassNames, array $maskConfiguration /** * @return AbstractAggregate[] */ - public function getCollection() + public function getCollection(): array { if (null === $this->collection) { $this->initializeCollection(); @@ -61,7 +57,7 @@ public function getCollection() /** * Initializes aggregate objects */ - protected function initializeCollection() + protected function initializeCollection(): void { $this->collection = []; foreach ($this->aggregateClassNames as $className) { diff --git a/Classes/Aggregate/BackendPreviewAggregate.php b/Classes/Aggregate/BackendPreviewAggregate.php index 90992e2..b2d7560 100644 --- a/Classes/Aggregate/BackendPreviewAggregate.php +++ b/Classes/Aggregate/BackendPreviewAggregate.php @@ -40,10 +40,6 @@ class BackendPreviewAggregate extends AbstractOverridesAggregate implements Plai */ protected $templatesFilePath = 'Resources/Private/Backend/Templates/'; - /** - * @param array $maskConfiguration - * @param BackendFluidCodeGenerator $fluidCodeGenerator - */ public function __construct(array $maskConfiguration, BackendFluidCodeGenerator $fluidCodeGenerator = null) { $this->fluidCodeGenerator = (null !== $fluidCodeGenerator) ? $fluidCodeGenerator : GeneralUtility::makeInstance(BackendFluidCodeGenerator::class); @@ -54,7 +50,7 @@ public function __construct(array $maskConfiguration, BackendFluidCodeGenerator /** * Adds PHP and Fluid files */ - protected function process() + protected function process(): void { if (empty($this->maskConfiguration[$this->table]['elements'])) { return; @@ -66,7 +62,7 @@ protected function process() $this->addFluidTemplates(); } - protected function addPageTsConfiguration() + protected function addPageTsConfiguration(): void { $rootPaths = $this->getFluidRootPaths(); @@ -96,7 +92,7 @@ protected function addPageTsConfiguration() /** * This adds the PHP file with the hook to render own element template */ - protected function addDrawItemHook() + protected function addDrawItemHook(): void { $this->appendPhpFile( 'ext_localconf.php', @@ -266,7 +262,7 @@ protected function getProcessedData(array \$databaseRow, array \$processedTcaCol /** * Ensure proper labels in $GLOBALS['TCA'] configuration */ - protected function replaceTableLabels() + protected function replaceTableLabels(): void { foreach ($this->maskConfiguration as $table => $_) { if (!isset($GLOBALS['TCA'][$table]) || empty($GLOBALS['TCA'][$table]['columns'])) { @@ -297,7 +293,7 @@ protected function replaceTableLabels() } } - protected function addFluidTemplates() + protected function addFluidTemplates(): void { foreach ($this->maskConfiguration[$this->table]['elements'] as $key => $element) { $templateKey = GeneralUtility::underscoredToUpperCamelCase($key); @@ -325,7 +321,7 @@ protected function addFluidTemplates() } } - protected function getFluidRootPaths() + protected function getFluidRootPaths(): array { $rootPath = dirname($this->templatesFilePath); diff --git a/Classes/Aggregate/ContentElementIconAggregate.php b/Classes/Aggregate/ContentElementIconAggregate.php index a4cd594..8d4de4d 100644 --- a/Classes/Aggregate/ContentElementIconAggregate.php +++ b/Classes/Aggregate/ContentElementIconAggregate.php @@ -35,7 +35,7 @@ class ContentElementIconAggregate extends TtContentOverridesAggregate implements /** * Adds content elements to the newContentElementWizard */ - protected function process() + protected function process(): void { if (empty($this->maskConfiguration['tt_content']['elements'])) { return; diff --git a/Classes/Aggregate/ContentRenderingAggregate.php b/Classes/Aggregate/ContentRenderingAggregate.php index 8221ef5..b15aebc 100644 --- a/Classes/Aggregate/ContentRenderingAggregate.php +++ b/Classes/Aggregate/ContentRenderingAggregate.php @@ -55,10 +55,6 @@ class ContentRenderingAggregate extends AbstractOverridesAggregate implements Pl */ protected $partialPath = 'Partials/'; - /** - * @param array $maskConfiguration - * @param HtmlCodeGenerator $htmlCodeGenerator - */ public function __construct(array $maskConfiguration, HtmlCodeGenerator $htmlCodeGenerator = null) { $this->htmlCodeGenerator = (null !== $htmlCodeGenerator) ? $htmlCodeGenerator : GeneralUtility::makeInstance(HtmlCodeGenerator::class); @@ -69,7 +65,7 @@ public function __construct(array $maskConfiguration, HtmlCodeGenerator $htmlCod /** * Adds TypoScript and Fluid information */ - protected function process() + protected function process(): void { if (empty($this->maskConfiguration[$this->table]['elements'])) { return; @@ -113,10 +109,7 @@ protected function process() } } - /** - * @param array $element - */ - protected function addTypoScript(array $element) + protected function addTypoScript(array $element): void { $resourcesPath = 'EXT:mask/' . $this->resourcePath; $layoutsPath = $resourcesPath . $this->layoutPath; @@ -157,12 +150,7 @@ protected function addTypoScript(array $element) ); } - /** - * @param string $table - * @param array $fields - * @return string - */ - protected function addDataProcessing($table, array $fields) + protected function addDataProcessing(string $table, array $fields): string { $dataProcessing = ''; $index = 10; @@ -206,13 +194,7 @@ protected function addDataProcessing($table, array $fields) return $dataProcessing; } - /** - * @param string $table - * @param string $columnName - * @param int $index - * @return string - */ - protected function addFileProcessorForField($table, $columnName, $index) + protected function addFileProcessorForField(string $table, string $columnName, int $index): string { return <<