From 00c505679b43431d5524b72540a1889c3f5b7e04 Mon Sep 17 00:00:00 2001 From: Justus Moroni Date: Mon, 18 Mar 2024 12:59:46 +0100 Subject: [PATCH] refactor: Cleanup phpstan baseline Also adjust the readme file. --- .../ResponsiveImagesProcessor.php | 4 +- Classes/Sizes/BackendLayout.php | 11 ++---- Classes/Sizes/BackendLayout/Column.php | 9 +---- Classes/Sizes/Breakpoint.php | 5 --- Classes/Sizes/Container.php | 2 +- Classes/Sizes/ContentElement.php | 5 --- Classes/Sizes/ContentElementInterface.php | 2 - Classes/Sizes/Rootline.php | 11 ++---- README.md | 4 +- phpstan-baseline.neon | 39 ------------------- 10 files changed, 12 insertions(+), 80 deletions(-) diff --git a/Classes/DataProcessing/ResponsiveImagesProcessor.php b/Classes/DataProcessing/ResponsiveImagesProcessor.php index f023af5..fdb38ba 100644 --- a/Classes/DataProcessing/ResponsiveImagesProcessor.php +++ b/Classes/DataProcessing/ResponsiveImagesProcessor.php @@ -84,7 +84,7 @@ public function process( return $processedData; } - $this->contentElementSizes = Rootline::make($processedData['data'])->getFinalSizes(); + $this->contentElementSizes = (new Rootline($processedData['data']))->getFinalSizes(); $this->fetchContentElementFieldConfiguration(); $this->calculateFileDimensions(); @@ -175,7 +175,7 @@ private function getBreakpoints(): array if (is_iterable($breakpointsByPath)) { foreach ($breakpointsByPath as $breakpointIdentifier => $breakpointData) { - $breakpoints[$breakpointIdentifier] = Breakpoint::make($breakpointIdentifier, $breakpointData); + $breakpoints[$breakpointIdentifier] = new Breakpoint($breakpointIdentifier, $breakpointData); } } diff --git a/Classes/Sizes/BackendLayout.php b/Classes/Sizes/BackendLayout.php index 102aac7..570c396 100644 --- a/Classes/Sizes/BackendLayout.php +++ b/Classes/Sizes/BackendLayout.php @@ -46,11 +46,6 @@ public function __construct( $this->determineColumns(); } - public static function make(mixed ...$arguments): static - { - return new self(...$arguments); - } - public function getSizes(): array { return $this->sizes; @@ -71,7 +66,7 @@ public function setActiveColumn(Column $column): void $this->activeColumn = $column; } - public function getActiveColumn(): ?Column + public function getActiveColumn(): Column { return $this->activeColumn; } @@ -100,8 +95,8 @@ private function determineColumns(): array $breakpointsByPath = $this->configurationManager->getByPath($sizesPath); if (is_iterable($breakpointsByPath)) { - foreach ($this->configurationManager->getByPath($sizesPath) as $columnIdentifier => $columnData) { - $this->columns[$columnIdentifier] = Column::make((string) $columnIdentifier, $columnData); + foreach ($breakpointsByPath as $columnIdentifier => $columnData) { + $this->columns[$columnIdentifier] = new Column($columnIdentifier, $columnData); } } diff --git a/Classes/Sizes/BackendLayout/Column.php b/Classes/Sizes/BackendLayout/Column.php index fc558c6..8145b33 100644 --- a/Classes/Sizes/BackendLayout/Column.php +++ b/Classes/Sizes/BackendLayout/Column.php @@ -33,18 +33,13 @@ class Column private readonly array $multiplier; public function __construct( - private readonly string $identifier, + private readonly int $identifier, array $data ) { $this->multiplier = array_map(static fn ($multiplier): float => Multiplier::parse($multiplier), $data['multiplier']); } - public static function make(mixed ...$arguments): self - { - return new self(...$arguments); - } - - public function getIdentifier(): string + public function getIdentifier(): int { return $this->identifier; } diff --git a/Classes/Sizes/Breakpoint.php b/Classes/Sizes/Breakpoint.php index 4db630c..a295d9f 100644 --- a/Classes/Sizes/Breakpoint.php +++ b/Classes/Sizes/Breakpoint.php @@ -35,11 +35,6 @@ public function __construct( ) { } - public static function make(mixed ...$arguments): static - { - return new self(...$arguments); - } - public function getIdentifier(): string { return $this->identifier; diff --git a/Classes/Sizes/Container.php b/Classes/Sizes/Container.php index f35cfb7..b137ded 100644 --- a/Classes/Sizes/Container.php +++ b/Classes/Sizes/Container.php @@ -66,7 +66,7 @@ private function determineColumns(): void $columnsByPath = $this->configurationManager->getByPath($sizesPath); if (is_iterable($columnsByPath)) { foreach ($columnsByPath as $columnIdentifier => $columnData) { - $this->columns[$columnIdentifier] = Column::make((string) $columnIdentifier, $columnData); + $this->columns[$columnIdentifier] = new Column($columnIdentifier, $columnData); } } } diff --git a/Classes/Sizes/ContentElement.php b/Classes/Sizes/ContentElement.php index 45aa4ce..aeef56c 100644 --- a/Classes/Sizes/ContentElement.php +++ b/Classes/Sizes/ContentElement.php @@ -44,11 +44,6 @@ public function __construct( $this->colPos = $data['colPos']; } - public static function make(mixed ...$arguments): static - { - return new static(...$arguments); - } - public function getData(?string $dataIdentifier = null): mixed { if ($dataIdentifier === null) { diff --git a/Classes/Sizes/ContentElementInterface.php b/Classes/Sizes/ContentElementInterface.php index 1242a4c..b931ca8 100644 --- a/Classes/Sizes/ContentElementInterface.php +++ b/Classes/Sizes/ContentElementInterface.php @@ -12,8 +12,6 @@ interface ContentElementInterface { public function __construct(array $data); - public static function make(mixed ...$arguments): static; - public function getData(?string $dataIdentifier = null): mixed; public function getContentType(): string; diff --git a/Classes/Sizes/Rootline.php b/Classes/Sizes/Rootline.php index 0c3fbd8..2173e3f 100644 --- a/Classes/Sizes/Rootline.php +++ b/Classes/Sizes/Rootline.php @@ -49,11 +49,6 @@ public function __construct(array $data) $this->calculateSizes(); } - public static function make(mixed ...$arguments): static - { - return new self(...$arguments); - } - public function getFinalSizes(): array { return $this->finalSizes; @@ -82,16 +77,16 @@ private function determineBackendLayout(): void ->getLayoutForPage($typoscriptFrontendController->page, $typoscriptFrontendController->rootLine) ; - $this->backendLayout = BackendLayout::make($backendLayoutIdentifier); + $this->backendLayout = new BackendLayout($backendLayoutIdentifier); } private function determineContentElement(array $data): ContentElementInterface { if (str_contains((string) $data['CType'], '_container-')) { - return Container::make($data); + return new Container($data); } - return ContentElement::make($data); + return new ContentElement($data); } private function determineRootline(): void diff --git a/README.md b/README.md index 91341c9..beba09f 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,7 @@ In this development state the extension is only used in one project. ## Missing Features The extension does not yet: -- contains tests. - work out of the box without configuration. -- handles b13/containers as optional. -- support other grid/container frameworks. +- support content block grids. - provide flexible enough configuration for more use cases. - support EXT:fluid_styled_content. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fbdc508..364905f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,41 +1,2 @@ parameters: ignoreErrors: - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: Classes/Sizes/BackendLayout.php - - - - message: "#^Cannot cast mixed to string\\.$#" - count: 1 - path: Classes/Sizes/BackendLayout.php - - - - message: "#^Parameter \\#1 \\$identifier of class Codappix\\\\ResponsiveImages\\\\Sizes\\\\BackendLayout constructor expects string, mixed given\\.$#" - count: 1 - path: Classes/Sizes/BackendLayout.php - - - - message: "#^Parameter \\#1 \\$identifier of class Codappix\\\\ResponsiveImages\\\\Sizes\\\\BackendLayout\\\\Column constructor expects string, mixed given\\.$#" - count: 1 - path: Classes/Sizes/BackendLayout/Column.php - - - - message: "#^Parameter \\#1 \\$identifier of class Codappix\\\\ResponsiveImages\\\\Sizes\\\\Breakpoint constructor expects string, mixed given\\.$#" - count: 1 - path: Classes/Sizes/Breakpoint.php - - - - message: "#^Parameter \\#1 \\$data of class Codappix\\\\ResponsiveImages\\\\Sizes\\\\ContentElement constructor expects array, mixed given\\.$#" - count: 1 - path: Classes/Sizes/ContentElement.php - - - - message: "#^Cannot call method getMultiplier\\(\\) on Codappix\\\\ResponsiveImages\\\\Sizes\\\\BackendLayout\\\\Column\\|null\\.$#" - count: 1 - path: Classes/Sizes/Rootline.php - - - - message: "#^Parameter \\#1 \\$data of class Codappix\\\\ResponsiveImages\\\\Sizes\\\\Rootline constructor expects array, mixed given\\.$#" - count: 1 - path: Classes/Sizes/Rootline.php