Skip to content

Commit

Permalink
[TASK] Add return types, parameter types and clean up doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Apr 19, 2022
1 parent 30e48d7 commit 7db03e9
Show file tree
Hide file tree
Showing 48 changed files with 132 additions and 386 deletions.
15 changes: 4 additions & 11 deletions Classes/Aggregate/AbstractAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ abstract class AbstractAggregate
*/
protected $typoScriptFilePath = 'Configuration/TypoScript/';

/**
* @param array $maskConfiguration
*/
public function __construct(array $maskConfiguration)
{
$this->maskConfiguration = $maskConfiguration;
Expand All @@ -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;
Expand All @@ -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'])) {
Expand All @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions Classes/Aggregate/AbstractInlineContentAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions Classes/Aggregate/AbstractOverridesAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions Classes/Aggregate/AggregateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class AggregateCollection
*/
protected $maskConfiguration;

/**
* @param array $aggregateClassNames
* @param array $maskConfiguration
*/
public function __construct(array $aggregateClassNames, array $maskConfiguration)
{
$this->aggregateClassNames = $aggregateClassNames;
Expand All @@ -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();
Expand All @@ -61,7 +57,7 @@ public function getCollection()
/**
* Initializes aggregate objects
*/
protected function initializeCollection()
protected function initializeCollection(): void
{
$this->collection = [];
foreach ($this->aggregateClassNames as $className) {
Expand Down
16 changes: 6 additions & 10 deletions Classes/Aggregate/BackendPreviewAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -66,7 +62,7 @@ protected function process()
$this->addFluidTemplates();
}

protected function addPageTsConfiguration()
protected function addPageTsConfiguration(): void
{
$rootPaths = $this->getFluidRootPaths();

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -325,7 +321,7 @@ protected function addFluidTemplates()
}
}

protected function getFluidRootPaths()
protected function getFluidRootPaths(): array
{
$rootPath = dirname($this->templatesFilePath);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Aggregate/ContentElementIconAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 6 additions & 33 deletions Classes/Aggregate/ContentRenderingAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <<<EOS
dataProcessing.{$index} = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
Expand All @@ -228,13 +210,7 @@ protected function addFileProcessorForField($table, $columnName, $index)
EOS;
}

/**
* @param string $table
* @param string $columnName
* @param int $index
* @return string
*/
protected function addDatabaseQueryProcessorForField($table, $columnName, $index)
protected function addDatabaseQueryProcessorForField(string $table, string $columnName, int $index): string
{
$where = $GLOBALS['TCA'][$table]['columns'][$columnName]['config']['foreign_field'] . '=###uid### AND deleted=0 AND hidden=0';
$markerArray = [
Expand Down Expand Up @@ -307,10 +283,7 @@ static function ($key, $value) {
EOS;
}

/**
* @param array $element
*/
protected function addFluidTemplate(array $element)
protected function addFluidTemplate(array $element): void
{
$key = $element['key'];
$templateSubFolder = 'tt_content' === $this->table ? 'Content' : GeneralUtility::underscoredToUpperCamelCase($this->table);
Expand Down
12 changes: 5 additions & 7 deletions Classes/Aggregate/ExtensionConfigurationAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class ExtensionConfigurationAggregate extends AbstractAggregate implements PhpAw

/**
* Own constructor method to ensure that the mask configuration is not changed before export.
*
* @param array $maskConfiguration
*/
public function __construct(array $maskConfiguration, Typo3Version $typo3Version = null)
{
Expand All @@ -44,7 +42,7 @@ public function __construct(array $maskConfiguration, Typo3Version $typo3Version
/**
* Adds typical extension files
*/
protected function process()
protected function process(): void
{
$this->addExtEmconf();
$this->addComposerJson();
Expand All @@ -55,7 +53,7 @@ protected function process()
/**
* Adds ext_emconf.php file
*/
protected function addExtEmconf()
protected function addExtEmconf(): void
{
$emConfUtility = GeneralUtility::makeInstance(EmConfUtility::class);
$extensionData = [
Expand Down Expand Up @@ -94,7 +92,7 @@ protected function addExtEmconf()
/**
* Adds composer.json file
*/
protected function addComposerJson()
protected function addComposerJson(): void
{
$composerData = [
'name' => 'mask/mask',
Expand Down Expand Up @@ -132,7 +130,7 @@ protected function addComposerJson()
/**
* Adds ext_icon.png from mask_export extension
*/
protected function addExtIcon()
protected function addExtIcon(): void
{
$this->addPlainTextFile(
'ext_icon.png',
Expand All @@ -147,7 +145,7 @@ protected function addExtIcon()
/**
* Adds mask.json configuration file
*/
protected function addMaskConfiguration()
protected function addMaskConfiguration(): void
{
$content = json_encode($this->maskConfiguration, JSON_PRETTY_PRINT);
$this->addPlainTextFile(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Aggregate/InlineContentCTypeAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InlineContentCTypeAggregate extends AbstractInlineContentAggregate impleme
/**
* Adds dataProvider for inline content CType restriction
*/
protected function process()
protected function process(): void
{
$inlineFields = $this->getAvailableInlineFields();
if (empty($inlineFields)) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Aggregate/InlineContentColPosAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InlineContentColPosAggregate extends AbstractInlineContentAggregate implem
/**
* Adds dataProvider for inline content colPos name
*/
protected function process()
protected function process(): void
{
$inlineFields = $this->getAvailableInlineFields();
if (empty($inlineFields)) {
Expand Down
5 changes: 1 addition & 4 deletions Classes/Aggregate/LanguageAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@

interface LanguageAwareInterface
{
/**
* @return array
*/
public function getLabels();
public function getLabels(): array;
}
5 changes: 1 addition & 4 deletions Classes/Aggregate/LanguageAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ trait LanguageAwareTrait
*/
protected $labels = [];

/**
* @return array
*/
public function getLabels()
public function getLabels(): array
{
return $this->labels;
}
Expand Down
7 changes: 2 additions & 5 deletions Classes/Aggregate/NewContentElementWizardAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NewContentElementWizardAggregate extends AbstractAggregate implements Lang
/**
* Adds content elements to the newContentElementWizard
*/
protected function process()
protected function process(): void
{
if (empty($this->maskConfiguration['tt_content']['elements'])) {
return;
Expand Down Expand Up @@ -82,10 +82,7 @@ protected function process()
);
}

/**
* @param array $element
*/
protected function processElement(array $element)
protected function processElement(array $element): void
{
$key = $element['key'];
$iconIdentifier = 'tx_mask_' . $key;
Expand Down
9 changes: 3 additions & 6 deletions Classes/Aggregate/PhpAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

interface PhpAwareInterface
{
const PHPFILE_DEFINED_TYPO3_MODE = 1;
const PHPFILE_CLOSURE_FUNCTION = 2;
public const PHPFILE_DEFINED_TYPO3_MODE = 1;
public const PHPFILE_CLOSURE_FUNCTION = 2;

/**
* @return array
*/
public function getPhpFiles();
public function getPhpFiles(): array;
}
Loading

0 comments on commit 7db03e9

Please sign in to comment.