From 64d552be01d7711546c4910974cb779563fea94a Mon Sep 17 00:00:00 2001 From: Enea Date: Mon, 18 May 2026 21:40:26 +0200 Subject: [PATCH 01/11] refactor: update phpstan and rector dependencies, simplify rector config, and clean up unused code --- composer.json | 4 ++-- rector.php | 32 ++++++++++----------------- src/Api/ThemeJson.php | 18 +++++---------- src/Domain/Input/Settings/Presets.php | 2 +- 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index 04155d25..c611e1a9 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "phpcompatibility/php-compatibility": "*", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "phpstan/phpstan": "^1.12", + "phpstan/phpstan": "^2.1", "phpbench/phpbench": "^1.2", "phpmetrics/phpmetrics": "^2.8", @@ -63,7 +63,7 @@ "infection/infection": "^0.26.6", "infection/codeception-adapter": "^0.4.1", - "rector/rector": "^0.19.0", + "rector/rector": "^2.4", "symplify/easy-coding-standard": "^12.0", "italystrap/debug": "dev-master" diff --git a/rector.php b/rector.php index 42dce751..f2abfa53 100644 --- a/rector.php +++ b/rector.php @@ -4,38 +4,30 @@ use Rector\Config\RectorConfig; use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector; -use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -use Rector\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/bin', __DIR__ . '/functions', __DIR__ . '/src', __DIR__ . '/tests', - ]); - - $rectorConfig->skip([ - DisallowedShortTernaryRuleFixerRector::class, + ]) + ->withSkip([ __DIR__ . '/tests/_data', __DIR__ . '/tests/_output', __DIR__ . '/tests/_support/_generated', __DIR__ . '/tests/integration/Domain/Input/Styles/ProcessBlocksCustomCssTrait.php', - ]); - - // register a single rule - $rectorConfig->rule(StaticDataProviderClassMethodRector::class); - - // define sets of rules - $rectorConfig->sets([ + ]) + ->withRules([ + StaticDataProviderClassMethodRector::class, + ]) + ->withSets([ SetList::CODE_QUALITY, SetList::CODING_STYLE, -// SetList::DEAD_CODE, SetList::EARLY_RETURN, SetList::TYPE_DECLARATION, - SetList::STRICT_BOOLEANS, SetList::INSTANCEOF, - LevelSetList::UP_TO_PHP_74 - ]); -}; + ]) + ->withPhpSets() + ->withoutParallel(); diff --git a/src/Api/ThemeJson.php b/src/Api/ThemeJson.php index d3093d10..808298af 100644 --- a/src/Api/ThemeJson.php +++ b/src/Api/ThemeJson.php @@ -15,11 +15,9 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontSize; /** - * @template TKey as array-key - * @template TValue - * @template-extends Config + * @extends Config */ -final class ThemeJson extends Config implements \JsonSerializable +final class ThemeJson extends Config { public function setGlobalCss(string $css): bool { @@ -28,7 +26,9 @@ public function setGlobalCss(string $css): bool public function appendGlobalCss(string $css): bool { - $currentCss = (string)$this->get(SectionNames::STYLES . '.css'); + $currentCss = $this->get(SectionNames::STYLES . '.css'); + $currentCss = \is_string($currentCss) ? $currentCss : ''; + return $this->set(SectionNames::STYLES . '.css', $currentCss . $css); } @@ -83,12 +83,4 @@ public function setPresets(PresetsInterface $presets): bool return true; } - - /** - * @return array - */ - public function jsonSerialize(): array - { - return $this->getArrayCopy(); - } } diff --git a/src/Domain/Input/Settings/Presets.php b/src/Domain/Input/Settings/Presets.php index 093cae85..43c2a85f 100644 --- a/src/Domain/Input/Settings/Presets.php +++ b/src/Domain/Input/Settings/Presets.php @@ -18,7 +18,7 @@ class Presets implements PresetsInterface, \JsonSerializable use AccessValueInArrayWithNotationTrait; /** - * @var PresetInterface[] + * @var array */ private array $collection = []; From 6962f1927b7e0e45242c903412c9438add5593a0 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 09:22:31 +0200 Subject: [PATCH 02/11] refactor: Rector fix - add `readonly` properties, implement consistent constructor injection, improve type declarations, and apply minor code cleanups --- src/Api/ThemeJson.php | 2 +- src/Application/Commands/DumpCommand.php | 5 +- src/Application/Commands/InfoCommand.php | 6 +-- src/Application/Commands/InitCommand.php | 5 +- src/Application/Commands/ValidateCommand.php | 6 +-- src/Application/DumpMessage.php | 21 ++------ src/Application/Message.php | 10 ++-- src/Application/Middlewares/Dump.php | 10 +--- src/Application/Middlewares/Info.php | 7 +-- src/Application/Middlewares/Init.php | 8 +-- src/Application/Middlewares/Validate.php | 15 ++---- src/Application/ValidateMessage.php | 17 ++----- src/Bootstrap.php | 1 + src/Domain/Input/Settings/Color/Duotone.php | 10 ++-- src/Domain/Input/Settings/Color/Gradient.php | 16 ++---- src/Domain/Input/Settings/Color/Palette.php | 16 ++---- src/Domain/Input/Settings/Color/Shadow.php | 11 ++--- .../Utilities/AnalogousColorsExperimental.php | 7 +-- .../Settings/Color/Utilities/BoxShadow.php | 9 +++- .../Input/Settings/Color/Utilities/Color.php | 25 ++++------ .../Settings/Color/Utilities/ColorFactory.php | 4 +- .../Color/Utilities/ColorModifier.php | 7 +-- .../ComplementaryColorsExperimental.php | 7 +-- .../MonochromaticColorsExperimental.php | 15 ++---- .../Utilities/ShadesGeneratorExperimental.php | 31 +++--------- .../SplitComplementaryColorsExperimental.php | 10 ++-- .../Utilities/SquareColorsExperimental.php | 10 ++-- .../Utilities/TriadicColorsExperimental.php | 10 ++-- src/Domain/Input/Settings/Custom/Custom.php | 10 +--- .../Input/Settings/Custom/CustomToPresets.php | 13 ++--- .../Input/Settings/Typography/FontFamily.php | 16 ++---- .../Input/Settings/Typography/FontSize.php | 22 +++------ .../Settings/Typography/Utilities/Fluid.php | 12 ++--- .../Typography/Utilities/FontFace.php | 30 +++--------- .../Settings/Utilities/CalcExperimental.php | 2 +- .../Settings/Utilities/ClampExperimental.php | 18 ++----- .../Utilities/DimensionExperimental.php | 2 +- .../Utilities/SupportedUnitsExperimental.php | 2 +- src/Domain/Input/Styles/Css.php | 9 ++-- src/Domain/Input/Styles/Scss.php | 10 ++-- src/Domain/Input/Styles/Spacing.php | 49 +++++++++---------- .../Filesystem/DataFromJsonTrait.php | 2 +- src/Infrastructure/Filesystem/FilesFinder.php | 10 ++-- .../Filesystem/JsonFileWriter.php | 10 ++-- .../Filesystem/ScssFileWriter.php | 5 +- src/ModuleApplication.php | 44 ++++++++--------- tests/_support/Helper/Integration.php | 3 ++ tests/_support/IntegrationTester.php | 1 + .../Styles/CssExperimentalOnHoldTrait.php | 4 +- .../Middlewares/SchemaJsonTest.php | 3 +- .../Settings/Color/Utilities/ColorTest.php | 2 +- .../Input/Settings/Custom/CustomTest.php | 4 +- .../Input/Settings/PresetsIntegrationTest.php | 2 +- .../Domain/Input/Settings/PresetsTest.php | 5 +- .../Input/Styles/OnlyCtorPresetsParamTest.php | 2 +- 55 files changed, 209 insertions(+), 384 deletions(-) diff --git a/src/Api/ThemeJson.php b/src/Api/ThemeJson.php index 808298af..00c73b58 100644 --- a/src/Api/ThemeJson.php +++ b/src/Api/ThemeJson.php @@ -76,7 +76,7 @@ public function setPresets(PresetsInterface $presets): bool foreach ($keys as $key => $value) { try { $this->set($key, $presets->toArrayByCategory($value)); - } catch (\Exception $e) { + } catch (\Exception) { continue; } } diff --git a/src/Application/Commands/DumpCommand.php b/src/Application/Commands/DumpCommand.php index e8cae02c..1eb00444 100644 --- a/src/Application/Commands/DumpCommand.php +++ b/src/Application/Commands/DumpCommand.php @@ -46,12 +46,9 @@ final class DumpCommand extends Command */ public const FILE = 'file'; - private ConsoleHandler $handler; - public function __construct( - ConsoleHandler $handler + private ConsoleHandler $handler ) { - $this->handler = $handler; parent::__construct(); } diff --git a/src/Application/Commands/InfoCommand.php b/src/Application/Commands/InfoCommand.php index 1a9e3a69..35dcad61 100644 --- a/src/Application/Commands/InfoCommand.php +++ b/src/Application/Commands/InfoCommand.php @@ -18,14 +18,12 @@ class InfoCommand extends Command use RootFolderTrait; public const NAME = 'info'; - public const DESCRIPTION = 'Show info about JSON theme'; - private ConsoleHandler $handler; + public const DESCRIPTION = 'Show info about JSON theme'; public function __construct( - ConsoleHandler $handler + private ConsoleHandler $handler ) { - $this->handler = $handler; parent::__construct(); } diff --git a/src/Application/Commands/InitCommand.php b/src/Application/Commands/InitCommand.php index 3cd494bd..c427c52c 100644 --- a/src/Application/Commands/InitCommand.php +++ b/src/Application/Commands/InitCommand.php @@ -23,12 +23,9 @@ class InitCommand extends Command public const DESCRIPTION = 'Initialize theme.json file'; - private ConsoleHandler $handler; - public function __construct( - ConsoleHandler $handler, + private readonly ConsoleHandler $handler, ) { - $this->handler = $handler; parent::__construct(); } diff --git a/src/Application/Commands/ValidateCommand.php b/src/Application/Commands/ValidateCommand.php index 9a5fadd9..65d70e83 100644 --- a/src/Application/Commands/ValidateCommand.php +++ b/src/Application/Commands/ValidateCommand.php @@ -21,13 +21,13 @@ class ValidateCommand extends Command use DataFromJsonTrait; public const NAME = 'validate'; + public const DESCRIPTION = 'Validate theme.json file'; - private ConsoleHandler $handler; + public function __construct( - ConsoleHandler $handler + private readonly ConsoleHandler $handler ) { - $this->handler = $handler; parent::__construct(); } diff --git a/src/Application/DumpMessage.php b/src/Application/DumpMessage.php index 8213928e..79dc96d3 100644 --- a/src/Application/DumpMessage.php +++ b/src/Application/DumpMessage.php @@ -4,25 +4,14 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -class DumpMessage +readonly class DumpMessage { - private string $rootFolder = ''; - - private bool $dry_run; - - private string $sassFolder; - private string $file; - public function __construct( - string $rootFolder, - string $sassFolder, - bool $dry_run, - string $file + private string $rootFolder, + private string $sassFolder, + private bool $dry_run, + private string $file ) { - $this->rootFolder = $rootFolder; - $this->dry_run = $dry_run; - $this->sassFolder = $sassFolder; - $this->file = $file; } public function getRootFolder(): string diff --git a/src/Application/Message.php b/src/Application/Message.php index ee2f460b..f30962e7 100644 --- a/src/Application/Message.php +++ b/src/Application/Message.php @@ -4,13 +4,11 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -class Message +readonly class Message { - private string $rootFolder = ''; - - public function __construct(string $rootFolder) - { - $this->rootFolder = $rootFolder; + public function __construct( + private string $rootFolder + ) { } public function getRootFolder(): string diff --git a/src/Application/Middlewares/Dump.php b/src/Application/Middlewares/Dump.php index 6ea63ba3..6b2898b3 100644 --- a/src/Application/Middlewares/Dump.php +++ b/src/Application/Middlewares/Dump.php @@ -24,16 +24,10 @@ class Dump implements MiddlewareInterface public const JSON_FILE_SUFFIX = '.json'; - private FilesFinder $filesFinder; - - private ThemeJsonContainerFactoryInterface $containerFactory; - public function __construct( - FilesFinder $filesFinder, - ThemeJsonContainerFactoryInterface $containerFactory + private readonly FilesFinder $filesFinder, + private readonly ThemeJsonContainerFactoryInterface $containerFactory ) { - $this->filesFinder = $filesFinder; - $this->containerFactory = $containerFactory; } /** diff --git a/src/Application/Middlewares/Info.php b/src/Application/Middlewares/Info.php index a7a60023..e292c0a6 100644 --- a/src/Application/Middlewares/Info.php +++ b/src/Application/Middlewares/Info.php @@ -13,14 +13,11 @@ /** * @todo Implement the logic */ -class Info implements MiddlewareInterface +readonly class Info implements MiddlewareInterface { - private FilesFinder $filesFinder; - public function __construct( - FilesFinder $filesFinder + private FilesFinder $filesFinder ) { - $this->filesFinder = $filesFinder; } /** diff --git a/src/Application/Middlewares/Init.php b/src/Application/Middlewares/Init.php index 837de744..77f5ae8a 100644 --- a/src/Application/Middlewares/Init.php +++ b/src/Application/Middlewares/Init.php @@ -46,12 +46,8 @@ class Init implements MiddlewareInterface public const ENTRY_POINT_EXTENSION = '.php'; - private FilesFinder $filesFinder; - - public function __construct( - FilesFinder $filesFinder - ) { - $this->filesFinder = $filesFinder; + public function __construct(private FilesFinder $filesFinder) + { } /** diff --git a/src/Application/Middlewares/Validate.php b/src/Application/Middlewares/Validate.php index 3723accd..5a5f6b35 100644 --- a/src/Application/Middlewares/Validate.php +++ b/src/Application/Middlewares/Validate.php @@ -18,20 +18,11 @@ class Validate implements MiddlewareInterface { use DataFromJsonTrait; - private Validator $validator; - - private FilesFinder $filesFinder; - - private Compiler $compiler; - public function __construct( - Validator $validator, - Compiler $compiler, - FilesFinder $filesFinder + private readonly Validator $validator, + private readonly Compiler $compiler, + private readonly FilesFinder $filesFinder ) { - $this->validator = $validator; - $this->filesFinder = $filesFinder; - $this->compiler = $compiler; } /** diff --git a/src/Application/ValidateMessage.php b/src/Application/ValidateMessage.php index 19f52ed4..33d44ea4 100644 --- a/src/Application/ValidateMessage.php +++ b/src/Application/ValidateMessage.php @@ -4,22 +4,13 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -class ValidateMessage +readonly class ValidateMessage { - private string $rootFolder; - - private string $schemaPath; - - private bool $forceRecreate; - public function __construct( - string $rootFolder, - string $schemaPath, - bool $forceRecreate = false + private string $rootFolder, + private string $schemaPath, + private bool $forceRecreate = false ) { - $this->schemaPath = $schemaPath; - $this->rootFolder = $rootFolder; - $this->forceRecreate = $forceRecreate; } public function getSchemaPath(): string diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 6548fb9f..ba242879 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -29,6 +29,7 @@ public function container(): ContainerInterface return $builder->build(); } + public function run(): int { $container = $this->container(); diff --git a/src/Domain/Input/Settings/Color/Duotone.php b/src/Domain/Input/Settings/Color/Duotone.php index b6aca50c..e293eec0 100644 --- a/src/Domain/Input/Settings/Color/Duotone.php +++ b/src/Domain/Input/Settings/Color/Duotone.php @@ -18,15 +18,16 @@ class Duotone implements PresetInterface private string $name; - private string $slug; - /** * @var array $colors */ private array $colors = []; - public function __construct(string $slug, string $name, Palette ...$colors) - { + public function __construct( + private readonly string $slug, + string $name, + Palette ...$colors + ) { if ($name === '') { throw new \InvalidArgumentException('Duotone must have a name.'); } @@ -35,7 +36,6 @@ public function __construct(string $slug, string $name, Palette ...$colors) throw new \InvalidArgumentException('Duotone must have at least two colors.'); } - $this->slug = $slug; $this->name = $name; $this->colors = $this->assertValidColors(...$colors); } diff --git a/src/Domain/Input/Settings/Color/Gradient.php b/src/Domain/Input/Settings/Color/Gradient.php index a6059f58..42225901 100644 --- a/src/Domain/Input/Settings/Color/Gradient.php +++ b/src/Domain/Input/Settings/Color/Gradient.php @@ -17,17 +17,11 @@ class Gradient implements PresetInterface */ public const TYPE = 'gradient'; - private string $slug; - - private string $name; - - private GradientInterface $gradient; - - public function __construct(string $slug, string $name, GradientInterface $gradient) - { - $this->slug = $slug; - $this->name = $name; - $this->gradient = $gradient; + public function __construct( + private readonly string $slug, + private readonly string $name, + private readonly GradientInterface $gradient + ) { } /** diff --git a/src/Domain/Input/Settings/Color/Palette.php b/src/Domain/Input/Settings/Color/Palette.php index f7398c09..6b50e2bc 100644 --- a/src/Domain/Input/Settings/Color/Palette.php +++ b/src/Domain/Input/Settings/Color/Palette.php @@ -22,17 +22,11 @@ class Palette implements PresetInterface */ public const KEY = 'settings.color.palette'; - private string $slug; - - private string $name; - - private ColorInterface $color; - - public function __construct(string $slug, string $name, ColorInterface $color) - { - $this->slug = $slug; - $this->name = $name; - $this->color = $color; + public function __construct( + private readonly string $slug, + private readonly string $name, + private readonly ColorInterface $color + ) { } /** diff --git a/src/Domain/Input/Settings/Color/Shadow.php b/src/Domain/Input/Settings/Color/Shadow.php index ad885d4f..b73c3977 100644 --- a/src/Domain/Input/Settings/Color/Shadow.php +++ b/src/Domain/Input/Settings/Color/Shadow.php @@ -17,18 +17,17 @@ class Shadow implements PresetInterface */ public const TYPE = 'shadow'; - private string $slug; - private string $name; /** * @var BoxShadow[] */ private array $shadow; - public function __construct(string $slug, string $name, BoxShadow ...$shadow) - { - $this->slug = $slug; - $this->name = $name; + public function __construct( + private readonly string $slug, + private readonly string $name, + BoxShadow ...$shadow + ) { $this->shadow = $shadow; } diff --git a/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php index 310f6857..c1e9c27a 100644 --- a/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php @@ -4,13 +4,10 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class AnalogousColorsExperimental implements ColorsGenerator +readonly class AnalogousColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $colorModifier; - - public function __construct(ColorModifierInterface $colorModifier) + public function __construct(private ColorModifierInterface $colorModifier) { - $this->colorModifier = $colorModifier; } public function generate(): array diff --git a/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php b/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php index 949873c5..9d9e1d5f 100644 --- a/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php +++ b/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php @@ -6,13 +6,18 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -class BoxShadow +class BoxShadow implements \Stringable { private bool $inset = false; + private string $x = ''; + private string $y = ''; + private string $blur = ''; + private string $spread = ''; + private string $color = ''; public function inset(bool $inset = true): self @@ -91,7 +96,7 @@ public function __toString(): string ]; $this->reset(); - return \trim(\implode(' ', \array_filter($shadow, static fn($value) => $value !== ''))); + return \trim(\implode(' ', \array_filter($shadow, static fn(string $value): bool => $value !== ''))); } public function __clone() diff --git a/src/Domain/Input/Settings/Color/Utilities/Color.php b/src/Domain/Input/Settings/Color/Utilities/Color.php index e0423a4d..5fa6c06c 100644 --- a/src/Domain/Input/Settings/Color/Utilities/Color.php +++ b/src/Domain/Input/Settings/Color/Utilities/Color.php @@ -10,16 +10,13 @@ final class Color implements ColorInterface { - private SpatieColor $spatieColor; + private readonly SpatieColor $spatieColor; - private string $type; + private readonly string $type; - private Hsla $hsla; + private readonly Hsla $hsla; - /** - * @var string|float - */ - private $alpha = 1.0; + private float|string $alpha = 1.0; /** * Luminance of #808080 or rgb(128,128,128) or hsl(0,0%,50%) @@ -35,7 +32,6 @@ public function __construct(string $color) $this->type = $reflected->getShortName(); if ($reflected->hasProperty('alpha')) { $reflectionProperty = $reflected->getProperty('alpha'); - $reflectionProperty->setAccessible(true); $alpha = $reflectionProperty->getValue($this->spatieColor); if (!\is_string($alpha) && !\is_float($alpha) && !\is_int($alpha)) { throw new \RuntimeException(\sprintf( @@ -45,7 +41,6 @@ public function __construct(string $color) } $this->alpha = \is_int($alpha) ? (float)$alpha : $alpha; - $reflectionProperty->setAccessible(false); } $alpha = $this->fromHexToFloat($this->alpha); @@ -101,7 +96,7 @@ public function relativeLuminance(ColorInterface $color): float /** * @return string|int */ - public function red() + public function red(): string|int { $red = $this->spatieColor->red(); if (!\is_string($red) && !\is_int($red)) { @@ -114,7 +109,7 @@ public function red() /** * @return string|int */ - public function green() + public function green(): string|int { $green = $this->spatieColor->green(); if (!\is_string($green) && !\is_int($green)) { @@ -127,7 +122,7 @@ public function green() /** * @return string|int */ - public function blue() + public function blue(): string|int { $blue = $this->spatieColor->blue(); if (!\is_string($blue) && !\is_int($blue)) { @@ -152,7 +147,7 @@ public function lightness(): int return (int)\round($this->hsla->lightness()); } - public function alpha() + public function alpha(): float|string { return $this->alpha; } @@ -174,7 +169,7 @@ public function toHsl(): self public function toHsla(?float $alpha = null): self { - $alpha = $alpha ?? $this->fromHexToFloat($this->alpha); + $alpha ??= $this->fromHexToFloat($this->alpha); return new self((string) $this->spatieColor->toHsla($alpha)); } @@ -185,7 +180,7 @@ public function toRgb(): self public function toRgba(?float $alpha = null): self { - $alpha = $alpha ?? $this->fromHexToFloat($this->alpha); + $alpha ??= $this->fromHexToFloat($this->alpha); return new self((string) $this->spatieColor->toRgba($alpha)); } diff --git a/src/Domain/Input/Settings/Color/Utilities/ColorFactory.php b/src/Domain/Input/Settings/Color/Utilities/ColorFactory.php index 620ddbb0..740132d9 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ColorFactory.php +++ b/src/Domain/Input/Settings/Color/Utilities/ColorFactory.php @@ -27,7 +27,7 @@ public function fromColorString(string $color): ColorInterface */ public function hsla(int $hue, float $saturation, float $lightness, float $alpha = 1): ColorInterface { - return new Color("hsla($hue, $saturation%, $lightness%, $alpha)"); + return new Color(sprintf('hsla(%d, %s%%, %s%%, %s)', $hue, $saturation, $lightness, $alpha)); } /** @@ -35,6 +35,6 @@ public function hsla(int $hue, float $saturation, float $lightness, float $alpha */ public function rgba(int $red, int $green, int $blue, float $alpha = 1): ColorInterface { - return new Color("rgba($red, $green, $blue, $alpha)"); + return new Color(sprintf('rgba(%d, %d, %d, %s)', $red, $green, $blue, $alpha)); } } diff --git a/src/Domain/Input/Settings/Color/Utilities/ColorModifier.php b/src/Domain/Input/Settings/Color/Utilities/ColorModifier.php index 54351346..d7a6b490 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ColorModifier.php +++ b/src/Domain/Input/Settings/Color/Utilities/ColorModifier.php @@ -6,10 +6,8 @@ use Exception; -final class ColorModifier implements ColorModifierInterface +final readonly class ColorModifier implements ColorModifierInterface { - private ColorInterface $color; - private ColorFactoryInterface $color_factory; private string $initialType; @@ -17,9 +15,8 @@ final class ColorModifier implements ColorModifierInterface /** * @throws Exception */ - public function __construct(ColorInterface $color, ?ColorFactoryInterface $factory = null) + public function __construct(private ColorInterface $color, ?ColorFactoryInterface $factory = null) { - $this->color = $color; $this->color_factory = $factory ?? new ColorFactory(); $this->initialType = $this->color->type(); } diff --git a/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php index 65dc9381..2ec8a905 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php @@ -4,13 +4,10 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class ComplementaryColorsExperimental implements ColorsGenerator +readonly class ComplementaryColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $color; - - public function __construct(ColorModifierInterface $color) + public function __construct(private ColorModifierInterface $color) { - $this->color = $color; } public function generate(): array diff --git a/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php index 25a3d1dc..3f72a885 100644 --- a/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php @@ -6,20 +6,13 @@ class MonochromaticColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $colorModifier; - - /** - * @var array - */ - private array $steps = []; - /** * @param array $steps */ - public function __construct(ColorModifierInterface $color, array $steps) - { - $this->colorModifier = $color; - $this->steps = $steps; + public function __construct( + private readonly ColorModifierInterface $colorModifier, + private array $steps + ) { } public function generate(): array diff --git a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php index b1286cb6..5414c0b7 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php @@ -23,16 +23,6 @@ class ShadesGeneratorExperimental */ public const INCREMENT_BY = 100; - private ColorInterface $color; - - private string $slug; - - private int $min; - - private int $max; - - private int $increment_by; - public static function fromPalette( Palette $palette, int $min = self::MIN, @@ -65,17 +55,12 @@ public static function fromColorInfo( } public function __construct( - ColorInterface $color, - string $slug, - int $min = self::MIN, - int $max = self::MAX, - int $increment_by = self::INCREMENT_BY + private readonly ColorInterface $color, + private readonly string $slug, + private readonly int $min = self::MIN, + private readonly int $max = self::MAX, + private readonly int $increment_by = self::INCREMENT_BY ) { - $this->color = $color; - $this->slug = $slug; - $this->min = $min; - $this->max = $max; - $this->increment_by = $increment_by; } public function toColors(): array @@ -105,14 +90,14 @@ public function toPalettes(): array } /** - * This functionality create an array of shades of a given color + * This functionality creates an array of shades of a given color * The created shades are from 10% to 100% of the given color * If the color is dark, the shades will be lightened * If the color is light, the shades will be darkened * - * This method create an array of Palette of shades of a color + * This method creates an array of Palette of shades of a color * If the color generated is #000000 or #ffffff it will be skipped, - * and you will get only the shades of the color without duplicates values likes many #000000 or #ffffff + * and you will get only the shades of the color without duplicates values like many #000000 or #ffffff * * @throws \Exception */ diff --git a/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php index 81813ba4..adb945b4 100644 --- a/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php @@ -4,13 +4,11 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class SplitComplementaryColorsExperimental implements ColorsGenerator +readonly class SplitComplementaryColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $colorModifier; - - public function __construct(ColorModifierInterface $colorModifier) - { - $this->colorModifier = $colorModifier; + public function __construct( + private ColorModifierInterface $colorModifier + ) { } public function generate(): array diff --git a/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php index 5ccc94e1..3dae8425 100644 --- a/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php @@ -4,13 +4,11 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class SquareColorsExperimental implements ColorsGenerator +readonly class SquareColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $colorModifier; - - public function __construct(ColorModifierInterface $colorModifier) - { - $this->colorModifier = $colorModifier; + public function __construct( + private ColorModifierInterface $colorModifier + ) { } public function generate(): array diff --git a/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php index 2905b733..b8812f21 100644 --- a/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php @@ -4,13 +4,11 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class TriadicColorsExperimental implements ColorsGenerator +readonly class TriadicColorsExperimental implements ColorsGenerator { - private ColorModifierInterface $colorModifier; - - public function __construct(ColorModifierInterface $colorModifier) - { - $this->colorModifier = $colorModifier; + public function __construct( + private ColorModifierInterface $colorModifier + ) { } public function generate(): array diff --git a/src/Domain/Input/Settings/Custom/Custom.php b/src/Domain/Input/Settings/Custom/Custom.php index 81e5327a..cba7ddc9 100644 --- a/src/Domain/Input/Settings/Custom/Custom.php +++ b/src/Domain/Input/Settings/Custom/Custom.php @@ -16,19 +16,13 @@ class Custom implements PresetInterface */ public const TYPE = 'custom'; - private string $key; - - private string $value; - private string $name; public function __construct( - string $key, - string $value + private string $key, + private string $value ) { - $this->key = $key; $this->name = \ucfirst(\str_replace('.', ' ', $this->key)); - $this->value = $value; } public function slug(): string diff --git a/src/Domain/Input/Settings/Custom/CustomToPresets.php b/src/Domain/Input/Settings/Custom/CustomToPresets.php index e1f5adee..1ca88f7a 100644 --- a/src/Domain/Input/Settings/Custom/CustomToPresets.php +++ b/src/Domain/Input/Settings/Custom/CustomToPresets.php @@ -4,20 +4,13 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Custom; -class CustomToPresets +readonly class CustomToPresets { - /** - * @var array - */ - private array $customs = []; - /** * @param array $customs */ - public function __construct( - array $customs = [] - ) { - $this->customs = $customs; + public function __construct(private array $customs = []) + { } /** diff --git a/src/Domain/Input/Settings/Typography/FontFamily.php b/src/Domain/Input/Settings/Typography/FontFamily.php index 44cbaad6..9ce36843 100644 --- a/src/Domain/Input/Settings/Typography/FontFamily.php +++ b/src/Domain/Input/Settings/Typography/FontFamily.php @@ -16,17 +16,11 @@ class FontFamily implements PresetInterface */ public const TYPE = 'fontFamily'; - private string $slug; - - private string $name; - - private string $fontFamily; - - public function __construct(string $slug, string $name, string $fontFamily) - { - $this->slug = $slug; - $this->name = $name; - $this->fontFamily = $fontFamily; + public function __construct( + private readonly string $slug, + private readonly string $name, + private readonly string $fontFamily + ) { } /** diff --git a/src/Domain/Input/Settings/Typography/FontSize.php b/src/Domain/Input/Settings/Typography/FontSize.php index b3968be4..4d44649a 100644 --- a/src/Domain/Input/Settings/Typography/FontSize.php +++ b/src/Domain/Input/Settings/Typography/FontSize.php @@ -17,20 +17,12 @@ class FontSize implements PresetInterface */ public const TYPE = 'fontSize'; - private string $slug; - - private string $name; - - private string $size; - - private ?Fluid $fluid; - - public function __construct(string $slug, string $name, string $size, ?Fluid $fluid = null) - { - $this->slug = $slug; - $this->name = $name; - $this->size = $size; - $this->fluid = $fluid; + public function __construct( + private readonly string $slug, + private readonly string $name, + private readonly string $size, + private readonly ?Fluid $fluid = null + ) { } /** @@ -43,6 +35,6 @@ public function toArray(): array 'name' => $this->name, 'size' => $this->size, 'fluid' => $this->fluid, - ], static fn ($value): bool => null !== $value); + ], static fn (string|Fluid|null $value): bool => null !== $value); } } diff --git a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php index 9a2947fa..f1a057f8 100644 --- a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php +++ b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php @@ -21,14 +21,10 @@ class Fluid */ public const MAX = 'max'; - private string $min; - - private string $max; - - public function __construct(string $min, string $max) - { - $this->min = $min; - $this->max = $max; + public function __construct( + private readonly string $min, + private readonly string $max + ) { } /** diff --git a/src/Domain/Input/Settings/Typography/Utilities/FontFace.php b/src/Domain/Input/Settings/Typography/Utilities/FontFace.php index fca02c70..432c8e40 100644 --- a/src/Domain/Input/Settings/Typography/Utilities/FontFace.php +++ b/src/Domain/Input/Settings/Typography/Utilities/FontFace.php @@ -4,36 +4,18 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities; -class FontFace +readonly class FontFace { - private string $fontFamily; - - private string $fontWeight; - - private string $fontStyle; - - private string $fontStretch; - - /** - * @var string[] - */ - private array $src; - /** * @param string[] $src */ public function __construct( - string $fontFamily, - string $fontWeight, - string $fontStyle, - string $fontStretch, - array $src + private string $fontFamily, + private string $fontWeight, + private string $fontStyle, + private string $fontStretch, + private array $src ) { - $this->fontFamily = $fontFamily; - $this->fontWeight = $fontWeight; - $this->fontStyle = $fontStyle; - $this->fontStretch = $fontStretch; - $this->src = $src; } /** diff --git a/src/Domain/Input/Settings/Utilities/CalcExperimental.php b/src/Domain/Input/Settings/Utilities/CalcExperimental.php index 75a438cc..76617d9f 100644 --- a/src/Domain/Input/Settings/Utilities/CalcExperimental.php +++ b/src/Domain/Input/Settings/Utilities/CalcExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -class CalcExperimental +readonly class CalcExperimental implements \Stringable { private string $value; diff --git a/src/Domain/Input/Settings/Utilities/ClampExperimental.php b/src/Domain/Input/Settings/Utilities/ClampExperimental.php index 4190deb3..639a73ca 100644 --- a/src/Domain/Input/Settings/Utilities/ClampExperimental.php +++ b/src/Domain/Input/Settings/Utilities/ClampExperimental.php @@ -4,22 +4,10 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -class ClampExperimental +readonly class ClampExperimental implements \Stringable { - private string $value; - - private string $min; - - private string $max; - - public function __construct( - string $value, - string $min, - string $max - ) { - $this->value = $value; - $this->min = $min; - $this->max = $max; + public function __construct(private string $value, private string $min, private string $max) + { } public function __toString(): string diff --git a/src/Domain/Input/Settings/Utilities/DimensionExperimental.php b/src/Domain/Input/Settings/Utilities/DimensionExperimental.php index 38e55c0a..55a765d9 100644 --- a/src/Domain/Input/Settings/Utilities/DimensionExperimental.php +++ b/src/Domain/Input/Settings/Utilities/DimensionExperimental.php @@ -10,7 +10,7 @@ * https://github.com/PhpUnitsOfMeasure/php-units-of-measure * https://wiki.php.net/rfc/clamp */ -final class DimensionExperimental +final readonly class DimensionExperimental implements \Stringable { private string $value; diff --git a/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php b/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php index a2b64930..d12b7c12 100644 --- a/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php +++ b/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -class SupportedUnitsExperimental implements UnitInterfaceExperimental +readonly class SupportedUnitsExperimental implements UnitInterfaceExperimental { private array $units; diff --git a/src/Domain/Input/Styles/Css.php b/src/Domain/Input/Styles/Css.php index 72b53f4d..6aeded9a 100644 --- a/src/Domain/Input/Styles/Css.php +++ b/src/Domain/Input/Styles/Css.php @@ -21,8 +21,10 @@ */ class Css implements CssInterface { - private PresetsInterface $presets; + private readonly PresetsInterface $presets; + private bool $isCompressed = true; + private bool $shouldResolveVariables = true; public function __construct( @@ -101,6 +103,7 @@ public function parse(string $css, string $selector = ''): string $cssBlock .= $space . $rule->getRule() . ': ' . (string)$rule->getValue() . $important . ';' . $newLine; // phpcs:enable } + $cssBlock .= '}' . $newLineAfterBlock; $additionalSelectors[] = $cssBlock; } @@ -180,10 +183,10 @@ private function duplicateRulesForSelectorList(string $css): string $rules = $matches[0]; foreach ($selectorArray as $selector) { - $cssFinal .= \rtrim($selector) . " $rules\n"; + $cssFinal .= \rtrim($selector) . sprintf(' %s%s', $rules, PHP_EOL); } - $cssFinal .= \rtrim($lastSelector) . " $rules\n"; + $cssFinal .= \rtrim($lastSelector) . sprintf(' %s%s', $rules, PHP_EOL); return $cssFinal; } diff --git a/src/Domain/Input/Styles/Scss.php b/src/Domain/Input/Styles/Scss.php index 3af4d1db..1beede6e 100644 --- a/src/Domain/Input/Styles/Scss.php +++ b/src/Domain/Input/Styles/Scss.php @@ -15,9 +15,7 @@ */ class Scss implements CssInterface { - private Css $css; - private Compiler $compiler; - private PresetsInterface $presets; + private readonly PresetsInterface $presets; /** * @var 'compressed'|'expanded' @@ -25,12 +23,10 @@ class Scss implements CssInterface private string $outputStyle = OutputStyle::COMPRESSED; public function __construct( - Css $css, - Compiler $compiler, + private readonly Css $css, + private readonly Compiler $compiler, ?PresetsInterface $presets = null ) { - $this->css = $css; - $this->compiler = $compiler; $this->presets = $presets ?? new NullPresets(); } diff --git a/src/Domain/Input/Styles/Spacing.php b/src/Domain/Input/Styles/Spacing.php index 2711cbbb..01a04963 100644 --- a/src/Domain/Input/Styles/Spacing.php +++ b/src/Domain/Input/Styles/Spacing.php @@ -62,33 +62,28 @@ public function left(string $value): self */ public function shorthand(array $values): self { - switch (\count($values)) { - case 1: - return $this->setProperty(self::TOP, (string)$values[0]) - ->setProperty(self::RIGHT, (string)$values[0]) - ->setProperty(self::BOTTOM, (string)$values[0]) - ->setProperty(self::LEFT, (string)$values[0]); - case 2: - return $this->setProperty(self::TOP, (string)$values[0]) - ->setProperty(self::RIGHT, (string)$values[1]) - ->setProperty(self::BOTTOM, (string)$values[0]) - ->setProperty(self::LEFT, (string)$values[1]); - case 3: - return $this->setProperty(self::TOP, (string)$values[0]) - ->setProperty(self::RIGHT, (string)$values[1]) - ->setProperty(self::BOTTOM, (string)$values[2]) - ->setProperty(self::LEFT, (string)$values[1]); - case 4: - return $this->setProperty(self::TOP, (string)$values[0]) - ->setProperty(self::RIGHT, (string)$values[1]) - ->setProperty(self::BOTTOM, (string)$values[2]) - ->setProperty(self::LEFT, (string)$values[3]); - default: - throw new \InvalidArgumentException(\sprintf( - 'The shorthand method accept only 1, 2, 3 or 4 values, %d given', - \count($values) - )); - } + return match (\count($values)) { + 1 => $this->setProperty(self::TOP, (string)$values[0]) + ->setProperty(self::RIGHT, (string)$values[0]) + ->setProperty(self::BOTTOM, (string)$values[0]) + ->setProperty(self::LEFT, (string)$values[0]), + 2 => $this->setProperty(self::TOP, (string)$values[0]) + ->setProperty(self::RIGHT, (string)$values[1]) + ->setProperty(self::BOTTOM, (string)$values[0]) + ->setProperty(self::LEFT, (string)$values[1]), + 3 => $this->setProperty(self::TOP, (string)$values[0]) + ->setProperty(self::RIGHT, (string)$values[1]) + ->setProperty(self::BOTTOM, (string)$values[2]) + ->setProperty(self::LEFT, (string)$values[1]), + 4 => $this->setProperty(self::TOP, (string)$values[0]) + ->setProperty(self::RIGHT, (string)$values[1]) + ->setProperty(self::BOTTOM, (string)$values[2]) + ->setProperty(self::LEFT, (string)$values[3]), + default => throw new \InvalidArgumentException(\sprintf( + 'The shorthand method accept only 1, 2, 3 or 4 values, %d given', + \count($values) + )), + }; } public function vertical(string $value): self diff --git a/src/Infrastructure/Filesystem/DataFromJsonTrait.php b/src/Infrastructure/Filesystem/DataFromJsonTrait.php index 70e76dc1..b4ee68a7 100644 --- a/src/Infrastructure/Filesystem/DataFromJsonTrait.php +++ b/src/Infrastructure/Filesystem/DataFromJsonTrait.php @@ -22,7 +22,7 @@ private function objectFromPath(string $path): object /** * @return array|object */ - private function fromPath(string $path, ?bool $isAssociative) + private function fromPath(string $path, ?bool $isAssociative): object|array { $json = \file_get_contents($path); if ($json === false) { diff --git a/src/Infrastructure/Filesystem/FilesFinder.php b/src/Infrastructure/Filesystem/FilesFinder.php index f51c0e67..34dea403 100644 --- a/src/Infrastructure/Filesystem/FilesFinder.php +++ b/src/Infrastructure/Filesystem/FilesFinder.php @@ -14,12 +14,8 @@ class FilesFinder public const JSON_FILE_SUFFIX = '.json'; - private FinderInterface $finder; - - public function __construct( - FinderInterface $finder - ) { - $this->finder = $finder; + public function __construct(private readonly FinderInterface $finder) + { } /** @@ -88,7 +84,7 @@ public function resolveJsonFile(\SplFileInfo $file): string throw new \RuntimeException('Unable to read the style.css file'); } - if (\strpos($styleCssContent, 'Theme Name:') === false) { + if (!str_contains($styleCssContent, 'Theme Name:')) { throw new \RuntimeException('The style.css file is not a valid WordPress theme'); } diff --git a/src/Infrastructure/Filesystem/JsonFileWriter.php b/src/Infrastructure/Filesystem/JsonFileWriter.php index a4ba15a0..5b928f03 100644 --- a/src/Infrastructure/Filesystem/JsonFileWriter.php +++ b/src/Infrastructure/Filesystem/JsonFileWriter.php @@ -7,16 +7,14 @@ use ItalyStrap\Config\ConfigInterface; use Webimpress\SafeWriter; -class JsonFileWriter implements FileWriter +readonly class JsonFileWriter implements FileWriter { - private string $path; - /** * @param string $path */ - public function __construct(string $path) - { - $this->path = $path; + public function __construct( + private string $path + ) { } /** diff --git a/src/Infrastructure/Filesystem/ScssFileWriter.php b/src/Infrastructure/Filesystem/ScssFileWriter.php index bcb740ec..c18a3cef 100644 --- a/src/Infrastructure/Filesystem/ScssFileWriter.php +++ b/src/Infrastructure/Filesystem/ScssFileWriter.php @@ -11,14 +11,11 @@ class ScssFileWriter implements FileWriter { use ConvertCase; - private string $path; - /** * @param string $path */ - public function __construct(string $path) + public function __construct(private string $path) { - $this->path = $path; } /** diff --git a/src/ModuleApplication.php b/src/ModuleApplication.php index 43a16205..ed2d80e4 100644 --- a/src/ModuleApplication.php +++ b/src/ModuleApplication.php @@ -33,28 +33,28 @@ public function __invoke(): array ThemeJsonContainerFactoryInterface::class => ThemeJsonContainerFactory::class, ], AurynConfig::FACTORIES => [ - InitCommand::class => function (ContainerInterface $container): InitCommand { - return new InitCommand(new ConsoleHandler( - $container->get(Init::class) - )); - }, - DumpCommand::class => function (ContainerInterface $container): DumpCommand { - return new DumpCommand(new ConsoleHandler( - $container->get(Dump::class), - )); - }, - ValidateCommand::class => function (ContainerInterface $container): ValidateCommand { - return new ValidateCommand(new ConsoleHandler( - new DeleteSchemaJson(), - new SchemaJson(), - $container->get(Validate::class) - )); - }, - InfoCommand::class => function (ContainerInterface $container): InfoCommand { - return new InfoCommand(new ConsoleHandler( - $container->get(Info::class) - )); - }, + InitCommand::class + => fn(ContainerInterface $container): InitCommand + => new InitCommand(new ConsoleHandler( + $container->get(Init::class) + )), + DumpCommand::class + => fn(ContainerInterface $container): DumpCommand + => new DumpCommand(new ConsoleHandler( + $container->get(Dump::class), + )), + ValidateCommand::class + => fn(ContainerInterface $container): ValidateCommand + => new ValidateCommand(new ConsoleHandler( + new DeleteSchemaJson(), + new SchemaJson(), + $container->get(Validate::class) + )), + InfoCommand::class + => fn(ContainerInterface $container): InfoCommand + => new InfoCommand(new ConsoleHandler( + $container->get(Info::class) + )), ], ]; } diff --git a/tests/_support/Helper/Integration.php b/tests/_support/Helper/Integration.php index 5f17c156..06fc9abe 100644 --- a/tests/_support/Helper/Integration.php +++ b/tests/_support/Helper/Integration.php @@ -1,4 +1,7 @@ tester->deleteFile($schemaPath); } + $this->tester->writeToFile($schemaPath, '{}'); $actual = $this->makeInstance(); diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php index 51803146..ddac1ce4 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php @@ -137,7 +137,7 @@ public static function colorProvider(): \Generator /** * @dataProvider colorProvider */ - public function testItShouldGerRed(string $color, $r, $g, $b): void + public function testItShouldGerRed(string $color, string|int $r, string|int $g, string|int $b): void { $sut = $this->makeInstance($color); diff --git a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php index 122446ed..52acb93f 100644 --- a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php +++ b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php @@ -24,11 +24,11 @@ private function makeInstance(): Custom ); } - public function testSlug() + public function testSlug(): void { } - public function testProp() + public function testProp(): void { } } diff --git a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php index a21f835a..d286c910 100644 --- a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php @@ -280,7 +280,7 @@ public function testFonts(): void // codecept_debug($font->getFontWeight()); $fontFace[] = [ 'fontFamily' => $font->getFontName(), - 'fontStyle' => \mb_strtolower($font->getFontSubfamily()), + 'fontStyle' => \mb_strtolower((string) $font->getFontSubfamily()), 'fontWeight' => $font->getFontWeight(), 'src' => [ \sprintf( diff --git a/tests/unit/Domain/Input/Settings/PresetsTest.php b/tests/unit/Domain/Input/Settings/PresetsTest.php index 1c8d6ad4..9500d461 100644 --- a/tests/unit/Domain/Input/Settings/PresetsTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsTest.php @@ -81,11 +81,8 @@ public function testItShouldBeJsonSerializableByTag(): void private function prepareFakeItem(string $val = ''): PresetInterface { return new class ($val) implements PresetInterface { - private string $val; - - public function __construct(string $val = '') + public function __construct(private readonly string $val = '') { - $this->val = $val; } public function slug(): string diff --git a/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php b/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php index aa93f3d2..48f9ba3a 100644 --- a/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php +++ b/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php @@ -50,7 +50,7 @@ public function testClassesThatNeedPresetsAsParameter(string $class): void \sprintf( "The constructor of %s does not have a parameter named \$preset, found: %s", $class, - \implode(', ', \array_map(fn(\ReflectionParameter $p) => '$' . $p->getName(), $parameters)) + \implode(', ', \array_map(fn(\ReflectionParameter $p): string => '$' . $p->getName(), $parameters)) ) ); } From 0162baf51d35dd7c0d3a640b9ec268de898350ad Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 10:53:24 +0200 Subject: [PATCH 03/11] refactor: declare all test classes as `final` for consistency --- tests/_support/FunctionalTester.php | 2 +- tests/_support/Helper/Functional.php | 2 +- tests/_support/Helper/Integration.php | 2 +- tests/_support/Helper/Unit.php | 2 +- tests/_support/IntegrationTester.php | 2 +- tests/_support/UnitTester.php | 2 +- tests/benchmarks/Domain/Input/Styles/StyleBench.php | 2 +- tests/functional/CommandsCest.php | 2 +- tests/integration/Domain/Input/Styles/CssTest.php | 2 +- tests/unit/Api/ThemeJsonTest.php | 2 +- tests/unit/Domain/Input/Settings/Color/DuotoneTest.php | 2 +- tests/unit/Domain/Input/Settings/Color/GradientTest.php | 2 +- tests/unit/Domain/Input/Settings/Color/PaletteTest.php | 2 +- tests/unit/Domain/Input/Settings/Color/ShadowTest.php | 2 +- .../Input/Settings/Color/Utilities/AchromaticColorsTest.php | 2 +- .../Input/Settings/Color/Utilities/AnalogousColorsTest.php | 2 +- .../Domain/Input/Settings/Color/Utilities/BoxShadowTest.php | 2 +- .../Domain/Input/Settings/Color/Utilities/ColorFactoryTest.php | 2 +- .../Input/Settings/Color/Utilities/ColorModifiertTest.php | 2 +- tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php | 2 +- .../Input/Settings/Color/Utilities/LinearGradientTest.php | 2 +- .../Input/Settings/Color/Utilities/MonochromaticColorsTest.php | 2 +- tests/unit/Domain/Input/Settings/CommonTest.php | 2 +- .../unit/Domain/Input/Settings/Custom/CollectionAdapterTest.php | 2 +- tests/unit/Domain/Input/Settings/Custom/CustomTest.php | 2 +- tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php | 2 +- tests/unit/Domain/Input/Settings/PresetsTest.php | 2 +- tests/unit/Domain/Input/Settings/Typography/FontFamilyTest.php | 2 +- tests/unit/Domain/Input/Settings/Typography/FontSizeTest.php | 2 +- tests/unit/Domain/Input/Styles/BorderTest.php | 2 +- tests/unit/Domain/Input/Styles/ColorTest.php | 2 +- tests/unit/Domain/Input/Styles/CssTest.php | 2 +- tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php | 2 +- tests/unit/Domain/Input/Styles/OutlineTest.php | 2 +- tests/unit/Domain/Input/Styles/ScssTest.php | 2 +- tests/unit/Domain/Input/Styles/SpacingTest.php | 2 +- tests/unit/Domain/Input/Styles/TypographyTest.php | 2 +- tests/unit/Domain/Output/DumpTest.php | 2 +- tests/unit/Domain/Output/InitTest.php | 2 +- tests/unit/Domain/Output/ValidateTest.php | 2 +- .../Infrastructure/Filesystem/FilesFinderIntegrationTest.php | 2 +- .../Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php | 2 +- tests/unit/Infrastructure/Filesystem/JsonFileWriterTest.php | 2 +- tests/unit/Infrastructure/Filesystem/SassFileWriterTest.php | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index 3ffe4c21..cd145b03 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -18,7 +18,7 @@ * * @SuppressWarnings(PHPMD) */ -class FunctionalTester extends \Codeception\Actor +final class FunctionalTester extends \Codeception\Actor { use _generated\FunctionalTesterActions; diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php index 6d6d5e23..020234b4 100644 --- a/tests/_support/Helper/Functional.php +++ b/tests/_support/Helper/Functional.php @@ -7,6 +7,6 @@ // here you can define custom actions // all public methods declared in helper class will be available in $I -class Functional extends \Codeception\Module +final class Functional extends \Codeception\Module { } diff --git a/tests/_support/Helper/Integration.php b/tests/_support/Helper/Integration.php index 06fc9abe..37795b30 100644 --- a/tests/_support/Helper/Integration.php +++ b/tests/_support/Helper/Integration.php @@ -7,7 +7,7 @@ // here you can define custom actions // all public methods declared in helper class will be available in $I -class Integration extends \Codeception\Module +final class Integration extends \Codeception\Module { } diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 7a222b39..ddb58e41 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -7,6 +7,6 @@ // here you can define custom actions // all public methods declared in helper class will be available in $I -class Unit extends \Codeception\Module +final class Unit extends \Codeception\Module { } diff --git a/tests/_support/IntegrationTester.php b/tests/_support/IntegrationTester.php index d62ef6da..4a5810d8 100644 --- a/tests/_support/IntegrationTester.php +++ b/tests/_support/IntegrationTester.php @@ -17,7 +17,7 @@ * * @SuppressWarnings(PHPMD) */ -class IntegrationTester extends \Codeception\Actor +final class IntegrationTester extends \Codeception\Actor { use _generated\IntegrationTesterActions; diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php index 8ad27fbf..21caf593 100644 --- a/tests/_support/UnitTester.php +++ b/tests/_support/UnitTester.php @@ -18,7 +18,7 @@ * * @SuppressWarnings(PHPMD) */ -class UnitTester extends \Codeception\Actor +final class UnitTester extends \Codeception\Actor { use _generated\UnitTesterActions; diff --git a/tests/benchmarks/Domain/Input/Styles/StyleBench.php b/tests/benchmarks/Domain/Input/Styles/StyleBench.php index d3b5ac5e..25bfa7cd 100644 --- a/tests/benchmarks/Domain/Input/Styles/StyleBench.php +++ b/tests/benchmarks/Domain/Input/Styles/StyleBench.php @@ -6,7 +6,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\CommonTrait; -class StyleBench +final class StyleBench { private object $styles; diff --git a/tests/functional/CommandsCest.php b/tests/functional/CommandsCest.php index ffde386d..97b799ff 100644 --- a/tests/functional/CommandsCest.php +++ b/tests/functional/CommandsCest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\FunctionalTestCase; use ItalyStrap\ThemeJsonGenerator\Application\Middlewares\Dump; -class CommandsCest extends FunctionalTestCase +final class CommandsCest extends FunctionalTestCase { public function testDump(FunctionalTester $i): void { diff --git a/tests/integration/Domain/Input/Styles/CssTest.php b/tests/integration/Domain/Input/Styles/CssTest.php index 1ad3591e..4c19a69e 100644 --- a/tests/integration/Domain/Input/Styles/CssTest.php +++ b/tests/integration/Domain/Input/Styles/CssTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\IntegrationTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Css; -class CssTest extends IntegrationTestCase +final class CssTest extends IntegrationTestCase { use ProcessBlocksCustomCssTrait; use CssStyleStringProviderTrait { diff --git a/tests/unit/Api/ThemeJsonTest.php b/tests/unit/Api/ThemeJsonTest.php index 0d0413e0..a9fcd489 100644 --- a/tests/unit/Api/ThemeJsonTest.php +++ b/tests/unit/Api/ThemeJsonTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Api\ThemeJson; -class ThemeJsonTest extends UnitTestCase +final class ThemeJsonTest extends UnitTestCase { private function makeInstance(): ThemeJson { diff --git a/tests/unit/Domain/Input/Settings/Color/DuotoneTest.php b/tests/unit/Domain/Input/Settings/Color/DuotoneTest.php index 91d1c36a..abb61b36 100644 --- a/tests/unit/Domain/Input/Settings/Color/DuotoneTest.php +++ b/tests/unit/Domain/Input/Settings/Color/DuotoneTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Duotone; -class DuotoneTest extends UnitTestCase +final class DuotoneTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/Color/GradientTest.php b/tests/unit/Domain/Input/Settings/Color/GradientTest.php index a36bf765..b15c195c 100644 --- a/tests/unit/Domain/Input/Settings/Color/GradientTest.php +++ b/tests/unit/Domain/Input/Settings/Color/GradientTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Gradient; -class GradientTest extends UnitTestCase +final class GradientTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/Color/PaletteTest.php b/tests/unit/Domain/Input/Settings/Color/PaletteTest.php index 8fcf7f38..f43580d9 100644 --- a/tests/unit/Domain/Input/Settings/Color/PaletteTest.php +++ b/tests/unit/Domain/Input/Settings/Color/PaletteTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -class PaletteTest extends UnitTestCase +final class PaletteTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/Color/ShadowTest.php b/tests/unit/Domain/Input/Settings/Color/ShadowTest.php index 0c771133..a98c013b 100644 --- a/tests/unit/Domain/Input/Settings/Color/ShadowTest.php +++ b/tests/unit/Domain/Input/Settings/Color/ShadowTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Shadow; -class ShadowTest extends UnitTestCase +final class ShadowTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/AchromaticColorsTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/AchromaticColorsTest.php index 1c378d55..66f930f5 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/AchromaticColorsTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/AchromaticColorsTest.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\AchromaticColorsExperimental; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorInterface; -class AchromaticColorsTest extends UnitTestCase +final class AchromaticColorsTest extends UnitTestCase { protected function makeInstance(): AchromaticColorsExperimental { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/AnalogousColorsTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/AnalogousColorsTest.php index dfd1baeb..e45ee35a 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/AnalogousColorsTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/AnalogousColorsTest.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorInterface; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorModifier; -class AnalogousColorsTest extends UnitTestCase +final class AnalogousColorsTest extends UnitTestCase { protected function makeInstance(string $color): AnalogousColorsExperimental { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/BoxShadowTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/BoxShadowTest.php index 35f6bc57..4bf68155 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/BoxShadowTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/BoxShadowTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\BoxShadow; -class BoxShadowTest extends UnitTestCase +final class BoxShadowTest extends UnitTestCase { private function makeInstance(): BoxShadow { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorFactoryTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorFactoryTest.php index 889d46a0..23e0cbbe 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorFactoryTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorFactoryTest.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\Color; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorFactory; -class ColorFactoryTest extends UnitTestCase +final class ColorFactoryTest extends UnitTestCase { protected function makeInstance(): ColorFactory { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorModifiertTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorModifiertTest.php index 7e3222d8..3178550f 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorModifiertTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorModifiertTest.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\Color; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorModifier; -class ColorModifiertTest extends UnitTestCase +final class ColorModifiertTest extends UnitTestCase { protected function makeInstance(string $color): ColorModifier { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php index ddac1ce4..2a9ed043 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\Color; -class ColorTest extends UnitTestCase +final class ColorTest extends UnitTestCase { protected function makeInstance(string $color): Color { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/LinearGradientTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/LinearGradientTest.php index f182aece..a29677ac 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/LinearGradientTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/LinearGradientTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\LinearGradient; -class LinearGradientTest extends UnitTestCase +final class LinearGradientTest extends UnitTestCase { private function makeInstance(): LinearGradient { diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/MonochromaticColorsTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/MonochromaticColorsTest.php index 4aaff065..6c082fae 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/MonochromaticColorsTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/MonochromaticColorsTest.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\ColorModifier; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities\MonochromaticColorsExperimental; -class MonochromaticColorsTest extends UnitTestCase +final class MonochromaticColorsTest extends UnitTestCase { protected function makeInstance(ColorInterface $color, array $steps): MonochromaticColorsExperimental { diff --git a/tests/unit/Domain/Input/Settings/CommonTest.php b/tests/unit/Domain/Input/Settings/CommonTest.php index 4f0f79fc..b2e0a0e8 100644 --- a/tests/unit/Domain/Input/Settings/CommonTest.php +++ b/tests/unit/Domain/Input/Settings/CommonTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; -class CommonTest extends UnitTestCase +final class CommonTest extends UnitTestCase { use PresetTrait; diff --git a/tests/unit/Domain/Input/Settings/Custom/CollectionAdapterTest.php b/tests/unit/Domain/Input/Settings/Custom/CollectionAdapterTest.php index 3bc9df88..54c5d729 100644 --- a/tests/unit/Domain/Input/Settings/Custom/CollectionAdapterTest.php +++ b/tests/unit/Domain/Input/Settings/Custom/CollectionAdapterTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Custom\CustomToPresets; -class CollectionAdapterTest extends UnitTestCase +final class CollectionAdapterTest extends UnitTestCase { private array $items = []; diff --git a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php index 52acb93f..02bb0878 100644 --- a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php +++ b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Custom\Custom; -class CustomTest extends UnitTestCase +final class CustomTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php index d286c910..d186e367 100644 --- a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php @@ -13,7 +13,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontSize; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Typography; -class PresetsIntegrationTest extends UnitTestCase +final class PresetsIntegrationTest extends UnitTestCase { private function makeInstance(): Presets { diff --git a/tests/unit/Domain/Input/Settings/PresetsTest.php b/tests/unit/Domain/Input/Settings/PresetsTest.php index 9500d461..e6dca63d 100644 --- a/tests/unit/Domain/Input/Settings/PresetsTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsTest.php @@ -9,7 +9,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class PresetsTest extends UnitTestCase +final class PresetsTest extends UnitTestCase { private function makeInstance(): Presets { diff --git a/tests/unit/Domain/Input/Settings/Typography/FontFamilyTest.php b/tests/unit/Domain/Input/Settings/Typography/FontFamilyTest.php index 4dcc52f9..4fd460b1 100644 --- a/tests/unit/Domain/Input/Settings/Typography/FontFamilyTest.php +++ b/tests/unit/Domain/Input/Settings/Typography/FontFamilyTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontFamily; -class FontFamilyTest extends UnitTestCase +final class FontFamilyTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Settings/Typography/FontSizeTest.php b/tests/unit/Domain/Input/Settings/Typography/FontSizeTest.php index f966376c..95db0c5e 100644 --- a/tests/unit/Domain/Input/Settings/Typography/FontSizeTest.php +++ b/tests/unit/Domain/Input/Settings/Typography/FontSizeTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\FontSize; -class FontSizeTest extends UnitTestCase +final class FontSizeTest extends UnitTestCase { use PresetCommonTrait; diff --git a/tests/unit/Domain/Input/Styles/BorderTest.php b/tests/unit/Domain/Input/Styles/BorderTest.php index db666374..9a8058e3 100644 --- a/tests/unit/Domain/Input/Styles/BorderTest.php +++ b/tests/unit/Domain/Input/Styles/BorderTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Border; -class BorderTest extends UnitTestCase +final class BorderTest extends UnitTestCase { use CommonTests; diff --git a/tests/unit/Domain/Input/Styles/ColorTest.php b/tests/unit/Domain/Input/Styles/ColorTest.php index 40e309b5..8d162a2a 100644 --- a/tests/unit/Domain/Input/Styles/ColorTest.php +++ b/tests/unit/Domain/Input/Styles/ColorTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Color; -class ColorTest extends UnitTestCase +final class ColorTest extends UnitTestCase { use CommonTests; diff --git a/tests/unit/Domain/Input/Styles/CssTest.php b/tests/unit/Domain/Input/Styles/CssTest.php index 40ccab00..608e3ff4 100644 --- a/tests/unit/Domain/Input/Styles/CssTest.php +++ b/tests/unit/Domain/Input/Styles/CssTest.php @@ -11,7 +11,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Scss; use ScssPhp\ScssPhp\Compiler; -class CssTest extends UnitTestCase +final class CssTest extends UnitTestCase { use CssStyleStringProviderTrait { CssStyleStringProviderTrait::styleProvider as styleProviderTrait; diff --git a/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php b/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php index 48f9ba3a..7bf90e74 100644 --- a/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php +++ b/tests/unit/Domain/Input/Styles/OnlyCtorPresetsParamTest.php @@ -13,7 +13,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Spacing; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Typography; -class OnlyCtorPresetsParamTest extends UnitTestCase +final class OnlyCtorPresetsParamTest extends UnitTestCase { public static function classNameDataProvider(): iterable { diff --git a/tests/unit/Domain/Input/Styles/OutlineTest.php b/tests/unit/Domain/Input/Styles/OutlineTest.php index 5469284e..be86030f 100644 --- a/tests/unit/Domain/Input/Styles/OutlineTest.php +++ b/tests/unit/Domain/Input/Styles/OutlineTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Outline; -class OutlineTest extends UnitTestCase +final class OutlineTest extends UnitTestCase { use CommonTests; diff --git a/tests/unit/Domain/Input/Styles/ScssTest.php b/tests/unit/Domain/Input/Styles/ScssTest.php index bc90fd9d..7376f6c2 100644 --- a/tests/unit/Domain/Input/Styles/ScssTest.php +++ b/tests/unit/Domain/Input/Styles/ScssTest.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Scss; use ScssPhp\ScssPhp\Compiler; -class ScssTest extends UnitTestCase +final class ScssTest extends UnitTestCase { use CssStyleStringProviderTrait { CssStyleStringProviderTrait::newStyleProvider as newStyleProviderTrait; diff --git a/tests/unit/Domain/Input/Styles/SpacingTest.php b/tests/unit/Domain/Input/Styles/SpacingTest.php index ad4e591d..6a7355f5 100644 --- a/tests/unit/Domain/Input/Styles/SpacingTest.php +++ b/tests/unit/Domain/Input/Styles/SpacingTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Spacing; -class SpacingTest extends UnitTestCase +final class SpacingTest extends UnitTestCase { use CommonTests; diff --git a/tests/unit/Domain/Input/Styles/TypographyTest.php b/tests/unit/Domain/Input/Styles/TypographyTest.php index f9b8388e..c5c1fff9 100644 --- a/tests/unit/Domain/Input/Styles/TypographyTest.php +++ b/tests/unit/Domain/Input/Styles/TypographyTest.php @@ -7,7 +7,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Typography; -class TypographyTest extends UnitTestCase +final class TypographyTest extends UnitTestCase { use CommonTests; diff --git a/tests/unit/Domain/Output/DumpTest.php b/tests/unit/Domain/Output/DumpTest.php index ef235445..efb4b6fb 100644 --- a/tests/unit/Domain/Output/DumpTest.php +++ b/tests/unit/Domain/Output/DumpTest.php @@ -11,7 +11,7 @@ use ItalyStrap\ThemeJsonGenerator\Infrastructure\Container\ThemeJsonContainerFactory; use Prophecy\Argument; -class DumpTest extends UnitTestCase +final class DumpTest extends UnitTestCase { private function makeInstance(): Dump { diff --git a/tests/unit/Domain/Output/InitTest.php b/tests/unit/Domain/Output/InitTest.php index 10ea58c8..ed13cbf5 100644 --- a/tests/unit/Domain/Output/InitTest.php +++ b/tests/unit/Domain/Output/InitTest.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Application\Middlewares\Init; use Prophecy\Argument; -class InitTest extends UnitTestCase +final class InitTest extends UnitTestCase { private function makeInstance(): Init { diff --git a/tests/unit/Domain/Output/ValidateTest.php b/tests/unit/Domain/Output/ValidateTest.php index f1edabd7..1cf8d4f8 100644 --- a/tests/unit/Domain/Output/ValidateTest.php +++ b/tests/unit/Domain/Output/ValidateTest.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Application\ValidateMessage; use Prophecy\Argument; -class ValidateTest extends UnitTestCase +final class ValidateTest extends UnitTestCase { private function makeInstance(): Validate { diff --git a/tests/unit/Infrastructure/Filesystem/FilesFinderIntegrationTest.php b/tests/unit/Infrastructure/Filesystem/FilesFinderIntegrationTest.php index 61cfaa22..b0faf6ac 100644 --- a/tests/unit/Infrastructure/Filesystem/FilesFinderIntegrationTest.php +++ b/tests/unit/Infrastructure/Filesystem/FilesFinderIntegrationTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Filesystem\FilesFinder; -class FilesFinderIntegrationTest extends UnitTestCase +final class FilesFinderIntegrationTest extends UnitTestCase { private function makeInstance(): FilesFinder { diff --git a/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php b/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php index c42c0eaf..0210cf12 100644 --- a/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php +++ b/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php @@ -14,7 +14,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Typography; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Filesystem\JsonFileWriter; -class JsonFileWriterIntegrationTest extends UnitTestCase +final class JsonFileWriterIntegrationTest extends UnitTestCase { public const COLOR_HEADING_TEXT = Palette::TYPE . '.headingColor'; diff --git a/tests/unit/Infrastructure/Filesystem/JsonFileWriterTest.php b/tests/unit/Infrastructure/Filesystem/JsonFileWriterTest.php index b694455a..bb41738b 100644 --- a/tests/unit/Infrastructure/Filesystem/JsonFileWriterTest.php +++ b/tests/unit/Infrastructure/Filesystem/JsonFileWriterTest.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Api\ThemeJson; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Filesystem\JsonFileWriter; -class JsonFileWriterTest extends UnitTestCase +final class JsonFileWriterTest extends UnitTestCase { private string $theme_json_path; diff --git a/tests/unit/Infrastructure/Filesystem/SassFileWriterTest.php b/tests/unit/Infrastructure/Filesystem/SassFileWriterTest.php index 12f0b1f8..0aed521a 100644 --- a/tests/unit/Infrastructure/Filesystem/SassFileWriterTest.php +++ b/tests/unit/Infrastructure/Filesystem/SassFileWriterTest.php @@ -8,7 +8,7 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Filesystem\ScssFileWriter; -class SassFileWriterTest extends UnitTestCase +final class SassFileWriterTest extends UnitTestCase { /** * @var string From 40811228d46f011f11fc65eacfc3794bb26c41ef Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 11:37:44 +0200 Subject: [PATCH 04/11] refactor: mark all classes as `final` and `readonly` where applicable, add bootstrap for unit tests to make final classes testable, and update composer dev dependencies --- composer.json | 2 ++ src/Application/Commands/InfoCommand.php | 2 +- src/Application/Commands/InitCommand.php | 2 +- src/Application/Commands/ValidateCommand.php | 2 +- src/Application/DumpMessage.php | 2 +- src/Application/Message.php | 2 +- src/Application/Middlewares/DeleteSchemaJson.php | 2 +- src/Application/Middlewares/Dump.php | 2 +- src/Application/Middlewares/Info.php | 2 +- src/Application/Middlewares/Init.php | 2 +- src/Application/Middlewares/SchemaJson.php | 2 +- src/Application/Middlewares/Validate.php | 2 +- src/Application/ValidateMessage.php | 2 +- src/Domain/Input/Settings/Color/Duotone.php | 2 +- src/Domain/Input/Settings/Color/Gradient.php | 2 +- src/Domain/Input/Settings/Color/Palette.php | 2 +- src/Domain/Input/Settings/Color/Shadow.php | 2 +- .../Color/Utilities/AchromaticColorsExperimental.php | 2 +- .../Color/Utilities/AnalogousColorsExperimental.php | 2 +- src/Domain/Input/Settings/Color/Utilities/BoxShadow.php | 2 +- .../Color/Utilities/ComplementaryColorsExperimental.php | 2 +- .../Input/Settings/Color/Utilities/LinearGradient.php | 2 +- .../Color/Utilities/MonochromaticColorsExperimental.php | 2 +- .../Color/Utilities/ShadesGeneratorExperimental.php | 2 +- .../Utilities/SplitComplementaryColorsExperimental.php | 2 +- .../Color/Utilities/SquareColorsExperimental.php | 2 +- .../Color/Utilities/TriadicColorsExperimental.php | 2 +- src/Domain/Input/Settings/Custom/Custom.php | 2 +- src/Domain/Input/Settings/Custom/CustomToPresets.php | 2 +- src/Domain/Input/Settings/NullPresets.php | 2 +- src/Domain/Input/Settings/Presets.php | 2 +- src/Domain/Input/Settings/Typography/FontFamily.php | 2 +- src/Domain/Input/Settings/Typography/FontSize.php | 2 +- src/Domain/Input/Settings/Typography/Utilities/Fluid.php | 2 +- .../Input/Settings/Typography/Utilities/FontFace.php | 2 +- src/Domain/Input/Settings/Utilities/CalcExperimental.php | 2 +- .../Input/Settings/Utilities/ClampExperimental.php | 2 +- .../Settings/Utilities/SupportedUnitsExperimental.php | 2 +- src/Domain/Input/Styles/Css.php | 2 +- src/Domain/Input/Styles/Outline.php | 2 +- src/Domain/Input/Styles/Scss.php | 2 +- src/Infrastructure/Filesystem/FilesFinder.php | 2 +- src/Infrastructure/Filesystem/JsonFileWriter.php | 2 +- src/Infrastructure/Filesystem/ScssFileWriter.php | 2 +- src/ModuleApplication.php | 2 +- src/ModuleInfrastructure.php | 2 +- tests/unit.suite.yml | 1 + tests/unit/bootstrap.php | 9 +++++++++ 48 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 tests/unit/bootstrap.php diff --git a/composer.json b/composer.json index c611e1a9..3d72d26b 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ "require-dev": { "lucatume/wp-browser": "^4.5", "phpspec/prophecy-phpunit": "^2.0", + "dg/bypass-finals": "^1.9", "codeception/module-asserts": "^3.0", "codeception/module-phpbrowser": "^3.0", @@ -64,6 +65,7 @@ "infection/codeception-adapter": "^0.4.1", "rector/rector": "^2.4", + "rector/swiss-knife": "^2.3", "symplify/easy-coding-standard": "^12.0", "italystrap/debug": "dev-master" diff --git a/src/Application/Commands/InfoCommand.php b/src/Application/Commands/InfoCommand.php index 35dcad61..d482650d 100644 --- a/src/Application/Commands/InfoCommand.php +++ b/src/Application/Commands/InfoCommand.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand(name: InfoCommand::NAME, description: InfoCommand::DESCRIPTION)] -class InfoCommand extends Command +final class InfoCommand extends Command { use RootFolderTrait; diff --git a/src/Application/Commands/InitCommand.php b/src/Application/Commands/InitCommand.php index c427c52c..a1c13545 100644 --- a/src/Application/Commands/InitCommand.php +++ b/src/Application/Commands/InitCommand.php @@ -14,7 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand(name: InitCommand::NAME, description: InitCommand::DESCRIPTION)] -class InitCommand extends Command +final class InitCommand extends Command { use RootFolderTrait; use DataFromJsonTrait; diff --git a/src/Application/Commands/ValidateCommand.php b/src/Application/Commands/ValidateCommand.php index 65d70e83..3da55854 100644 --- a/src/Application/Commands/ValidateCommand.php +++ b/src/Application/Commands/ValidateCommand.php @@ -15,7 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand(name: ValidateCommand::NAME, description: ValidateCommand::DESCRIPTION)] -class ValidateCommand extends Command +final class ValidateCommand extends Command { use RootFolderTrait; use DataFromJsonTrait; diff --git a/src/Application/DumpMessage.php b/src/Application/DumpMessage.php index 79dc96d3..71f4bf77 100644 --- a/src/Application/DumpMessage.php +++ b/src/Application/DumpMessage.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -readonly class DumpMessage +final readonly class DumpMessage { public function __construct( private string $rootFolder, diff --git a/src/Application/Message.php b/src/Application/Message.php index f30962e7..f62026a0 100644 --- a/src/Application/Message.php +++ b/src/Application/Message.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -readonly class Message +final readonly class Message { public function __construct( private string $rootFolder diff --git a/src/Application/Middlewares/DeleteSchemaJson.php b/src/Application/Middlewares/DeleteSchemaJson.php index 98dade27..c190ce6a 100644 --- a/src/Application/Middlewares/DeleteSchemaJson.php +++ b/src/Application/Middlewares/DeleteSchemaJson.php @@ -9,7 +9,7 @@ use ItalyStrap\ThemeJsonGenerator\Application\ValidateMessage; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Handler\ConsoleHandler; -class DeleteSchemaJson implements MiddlewareInterface +final class DeleteSchemaJson implements MiddlewareInterface { /** * @phpstan-param ValidateMessage $message diff --git a/src/Application/Middlewares/Dump.php b/src/Application/Middlewares/Dump.php index 6b2898b3..6e691d7d 100644 --- a/src/Application/Middlewares/Dump.php +++ b/src/Application/Middlewares/Dump.php @@ -15,7 +15,7 @@ use ItalyStrap\ThemeJsonGenerator\Infrastructure\Handler\ConsoleHandler; use Symfony\Component\Console\Output\OutputInterface; -class Dump implements MiddlewareInterface +final class Dump implements MiddlewareInterface { /** * @var string diff --git a/src/Application/Middlewares/Info.php b/src/Application/Middlewares/Info.php index e292c0a6..3993ab5d 100644 --- a/src/Application/Middlewares/Info.php +++ b/src/Application/Middlewares/Info.php @@ -13,7 +13,7 @@ /** * @todo Implement the logic */ -readonly class Info implements MiddlewareInterface +final readonly class Info implements MiddlewareInterface { public function __construct( private FilesFinder $filesFinder diff --git a/src/Application/Middlewares/Init.php b/src/Application/Middlewares/Init.php index 77f5ae8a..b0dd96f3 100644 --- a/src/Application/Middlewares/Init.php +++ b/src/Application/Middlewares/Init.php @@ -21,7 +21,7 @@ use Webimpress\SafeWriter\FileWriter; use Webmozart\Assert\Assert; -class Init implements MiddlewareInterface +final class Init implements MiddlewareInterface { use DataFromJsonTrait; diff --git a/src/Application/Middlewares/SchemaJson.php b/src/Application/Middlewares/SchemaJson.php index e4c5e618..dad0fa1b 100644 --- a/src/Application/Middlewares/SchemaJson.php +++ b/src/Application/Middlewares/SchemaJson.php @@ -10,7 +10,7 @@ use ItalyStrap\ThemeJsonGenerator\Infrastructure\Handler\ConsoleHandler; use Webimpress\SafeWriter\FileWriter; -class SchemaJson implements MiddlewareInterface +final class SchemaJson implements MiddlewareInterface { /** * @phpstan-param ValidateMessage $message diff --git a/src/Application/Middlewares/Validate.php b/src/Application/Middlewares/Validate.php index 5a5f6b35..c21b7ccf 100644 --- a/src/Application/Middlewares/Validate.php +++ b/src/Application/Middlewares/Validate.php @@ -14,7 +14,7 @@ use ScssPhp\ScssPhp\Compiler; use Symfony\Component\Console\Output\OutputInterface; -class Validate implements MiddlewareInterface +final class Validate implements MiddlewareInterface { use DataFromJsonTrait; diff --git a/src/Application/ValidateMessage.php b/src/Application/ValidateMessage.php index 33d44ea4..5b9da8e4 100644 --- a/src/Application/ValidateMessage.php +++ b/src/Application/ValidateMessage.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application; -readonly class ValidateMessage +final readonly class ValidateMessage { public function __construct( private string $rootFolder, diff --git a/src/Domain/Input/Settings/Color/Duotone.php b/src/Domain/Input/Settings/Color/Duotone.php index e293eec0..e8bac5a4 100644 --- a/src/Domain/Input/Settings/Color/Duotone.php +++ b/src/Domain/Input/Settings/Color/Duotone.php @@ -7,7 +7,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class Duotone implements PresetInterface +final class Duotone implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Color/Gradient.php b/src/Domain/Input/Settings/Color/Gradient.php index 42225901..142aecf3 100644 --- a/src/Domain/Input/Settings/Color/Gradient.php +++ b/src/Domain/Input/Settings/Color/Gradient.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class Gradient implements PresetInterface +final class Gradient implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Color/Palette.php b/src/Domain/Input/Settings/Color/Palette.php index 6b50e2bc..c389eae3 100644 --- a/src/Domain/Input/Settings/Color/Palette.php +++ b/src/Domain/Input/Settings/Color/Palette.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class Palette implements PresetInterface +final class Palette implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Color/Shadow.php b/src/Domain/Input/Settings/Color/Shadow.php index b73c3977..e9910d3b 100644 --- a/src/Domain/Input/Settings/Color/Shadow.php +++ b/src/Domain/Input/Settings/Color/Shadow.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; -class Shadow implements PresetInterface +final class Shadow implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Color/Utilities/AchromaticColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/AchromaticColorsExperimental.php index 4b845b86..a3b340e0 100644 --- a/src/Domain/Input/Settings/Color/Utilities/AchromaticColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/AchromaticColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class AchromaticColorsExperimental implements ColorsGenerator +final class AchromaticColorsExperimental implements ColorsGenerator { public function generate(): array { diff --git a/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php index c1e9c27a..d9a66bcf 100644 --- a/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/AnalogousColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -readonly class AnalogousColorsExperimental implements ColorsGenerator +final readonly class AnalogousColorsExperimental implements ColorsGenerator { public function __construct(private ColorModifierInterface $colorModifier) { diff --git a/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php b/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php index 9d9e1d5f..25955919 100644 --- a/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php +++ b/src/Domain/Input/Settings/Color/Utilities/BoxShadow.php @@ -6,7 +6,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -class BoxShadow implements \Stringable +final class BoxShadow implements \Stringable { private bool $inset = false; diff --git a/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php index 2ec8a905..daa15b07 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/ComplementaryColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -readonly class ComplementaryColorsExperimental implements ColorsGenerator +final readonly class ComplementaryColorsExperimental implements ColorsGenerator { public function __construct(private ColorModifierInterface $color) { diff --git a/src/Domain/Input/Settings/Color/Utilities/LinearGradient.php b/src/Domain/Input/Settings/Color/Utilities/LinearGradient.php index 451d47c6..3400ac9d 100644 --- a/src/Domain/Input/Settings/Color/Utilities/LinearGradient.php +++ b/src/Domain/Input/Settings/Color/Utilities/LinearGradient.php @@ -6,7 +6,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -class LinearGradient implements GradientInterface +final class LinearGradient implements GradientInterface { private string $direction = ''; diff --git a/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php index 3f72a885..1b559b54 100644 --- a/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/MonochromaticColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -class MonochromaticColorsExperimental implements ColorsGenerator +final class MonochromaticColorsExperimental implements ColorsGenerator { /** * @param array $steps diff --git a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php index 5414c0b7..49223e1c 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php @@ -6,7 +6,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -class ShadesGeneratorExperimental +final class ShadesGeneratorExperimental { /** * @var int diff --git a/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php index adb945b4..b2996e14 100644 --- a/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/SplitComplementaryColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -readonly class SplitComplementaryColorsExperimental implements ColorsGenerator +final readonly class SplitComplementaryColorsExperimental implements ColorsGenerator { public function __construct( private ColorModifierInterface $colorModifier diff --git a/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php index 3dae8425..9db16e56 100644 --- a/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/SquareColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -readonly class SquareColorsExperimental implements ColorsGenerator +final readonly class SquareColorsExperimental implements ColorsGenerator { public function __construct( private ColorModifierInterface $colorModifier diff --git a/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php b/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php index b8812f21..8c5836a7 100644 --- a/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/TriadicColorsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Utilities; -readonly class TriadicColorsExperimental implements ColorsGenerator +final readonly class TriadicColorsExperimental implements ColorsGenerator { public function __construct( private ColorModifierInterface $colorModifier diff --git a/src/Domain/Input/Settings/Custom/Custom.php b/src/Domain/Input/Settings/Custom/Custom.php index cba7ddc9..382f2e99 100644 --- a/src/Domain/Input/Settings/Custom/Custom.php +++ b/src/Domain/Input/Settings/Custom/Custom.php @@ -7,7 +7,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class Custom implements PresetInterface +final class Custom implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Custom/CustomToPresets.php b/src/Domain/Input/Settings/Custom/CustomToPresets.php index 1ca88f7a..6e0b4462 100644 --- a/src/Domain/Input/Settings/Custom/CustomToPresets.php +++ b/src/Domain/Input/Settings/Custom/CustomToPresets.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Custom; -readonly class CustomToPresets +final readonly class CustomToPresets { /** * @param array $customs diff --git a/src/Domain/Input/Settings/NullPresets.php b/src/Domain/Input/Settings/NullPresets.php index 011d4668..f18340b8 100644 --- a/src/Domain/Input/Settings/NullPresets.php +++ b/src/Domain/Input/Settings/NullPresets.php @@ -7,7 +7,7 @@ /** * @infection-ignore-all */ -class NullPresets implements PresetsInterface +final class NullPresets implements PresetsInterface { public function add(PresetInterface $item): PresetsInterface { diff --git a/src/Domain/Input/Settings/Presets.php b/src/Domain/Input/Settings/Presets.php index 43c2a85f..898a871e 100644 --- a/src/Domain/Input/Settings/Presets.php +++ b/src/Domain/Input/Settings/Presets.php @@ -13,7 +13,7 @@ * @see PresetsTest * @see PresetsIntegrationTest */ -class Presets implements PresetsInterface, \JsonSerializable +final class Presets implements PresetsInterface, \JsonSerializable { use AccessValueInArrayWithNotationTrait; diff --git a/src/Domain/Input/Settings/Typography/FontFamily.php b/src/Domain/Input/Settings/Typography/FontFamily.php index 9ce36843..f0bcff0c 100644 --- a/src/Domain/Input/Settings/Typography/FontFamily.php +++ b/src/Domain/Input/Settings/Typography/FontFamily.php @@ -7,7 +7,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -class FontFamily implements PresetInterface +final class FontFamily implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Typography/FontSize.php b/src/Domain/Input/Settings/Typography/FontSize.php index 4d44649a..d8b2ebfb 100644 --- a/src/Domain/Input/Settings/Typography/FontSize.php +++ b/src/Domain/Input/Settings/Typography/FontSize.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities\Fluid; -class FontSize implements PresetInterface +final class FontSize implements PresetInterface { use PresetTrait; diff --git a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php index f1a057f8..b61258c4 100644 --- a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php +++ b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities; -class Fluid +final class Fluid { /** * @var string diff --git a/src/Domain/Input/Settings/Typography/Utilities/FontFace.php b/src/Domain/Input/Settings/Typography/Utilities/FontFace.php index 432c8e40..dcb96162 100644 --- a/src/Domain/Input/Settings/Typography/Utilities/FontFace.php +++ b/src/Domain/Input/Settings/Typography/Utilities/FontFace.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities; -readonly class FontFace +final readonly class FontFace { /** * @param string[] $src diff --git a/src/Domain/Input/Settings/Utilities/CalcExperimental.php b/src/Domain/Input/Settings/Utilities/CalcExperimental.php index 76617d9f..5ad06f11 100644 --- a/src/Domain/Input/Settings/Utilities/CalcExperimental.php +++ b/src/Domain/Input/Settings/Utilities/CalcExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -readonly class CalcExperimental implements \Stringable +final readonly class CalcExperimental implements \Stringable { private string $value; diff --git a/src/Domain/Input/Settings/Utilities/ClampExperimental.php b/src/Domain/Input/Settings/Utilities/ClampExperimental.php index 639a73ca..9e1841d2 100644 --- a/src/Domain/Input/Settings/Utilities/ClampExperimental.php +++ b/src/Domain/Input/Settings/Utilities/ClampExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -readonly class ClampExperimental implements \Stringable +final readonly class ClampExperimental implements \Stringable { public function __construct(private string $value, private string $min, private string $max) { diff --git a/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php b/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php index d12b7c12..ab2a60a4 100644 --- a/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php +++ b/src/Domain/Input/Settings/Utilities/SupportedUnitsExperimental.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Utilities; -readonly class SupportedUnitsExperimental implements UnitInterfaceExperimental +final readonly class SupportedUnitsExperimental implements UnitInterfaceExperimental { private array $units; diff --git a/src/Domain/Input/Styles/Css.php b/src/Domain/Input/Styles/Css.php index 6aeded9a..e8dc5586 100644 --- a/src/Domain/Input/Styles/Css.php +++ b/src/Domain/Input/Styles/Css.php @@ -19,7 +19,7 @@ * * @see CssTest */ -class Css implements CssInterface +final class Css implements CssInterface { private readonly PresetsInterface $presets; diff --git a/src/Domain/Input/Styles/Outline.php b/src/Domain/Input/Styles/Outline.php index ff80abcb..b8cd2c69 100644 --- a/src/Domain/Input/Styles/Outline.php +++ b/src/Domain/Input/Styles/Outline.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles; -class Outline implements ArrayableInterface, \JsonSerializable +final class Outline implements ArrayableInterface, \JsonSerializable { use CommonTrait; diff --git a/src/Domain/Input/Styles/Scss.php b/src/Domain/Input/Styles/Scss.php index 1beede6e..e96fb36a 100644 --- a/src/Domain/Input/Styles/Scss.php +++ b/src/Domain/Input/Styles/Scss.php @@ -13,7 +13,7 @@ /** * @see ScssTest */ -class Scss implements CssInterface +final class Scss implements CssInterface { private readonly PresetsInterface $presets; diff --git a/src/Infrastructure/Filesystem/FilesFinder.php b/src/Infrastructure/Filesystem/FilesFinder.php index 34dea403..58d8f09c 100644 --- a/src/Infrastructure/Filesystem/FilesFinder.php +++ b/src/Infrastructure/Filesystem/FilesFinder.php @@ -6,7 +6,7 @@ use ItalyStrap\Finder\FinderInterface; -class FilesFinder +final class FilesFinder { public const ROOT_FILE_NAME = 'theme'; diff --git a/src/Infrastructure/Filesystem/JsonFileWriter.php b/src/Infrastructure/Filesystem/JsonFileWriter.php index 5b928f03..35795911 100644 --- a/src/Infrastructure/Filesystem/JsonFileWriter.php +++ b/src/Infrastructure/Filesystem/JsonFileWriter.php @@ -7,7 +7,7 @@ use ItalyStrap\Config\ConfigInterface; use Webimpress\SafeWriter; -readonly class JsonFileWriter implements FileWriter +final readonly class JsonFileWriter implements FileWriter { /** * @param string $path diff --git a/src/Infrastructure/Filesystem/ScssFileWriter.php b/src/Infrastructure/Filesystem/ScssFileWriter.php index c18a3cef..282ccda2 100644 --- a/src/Infrastructure/Filesystem/ScssFileWriter.php +++ b/src/Infrastructure/Filesystem/ScssFileWriter.php @@ -7,7 +7,7 @@ use ItalyStrap\Config\ConfigInterface; use Webimpress\SafeWriter; -class ScssFileWriter implements FileWriter +final class ScssFileWriter implements FileWriter { use ConvertCase; diff --git a/src/ModuleApplication.php b/src/ModuleApplication.php index ed2d80e4..3ce20f65 100644 --- a/src/ModuleApplication.php +++ b/src/ModuleApplication.php @@ -21,7 +21,7 @@ use ItalyStrap\ThemeJsonGenerator\Infrastructure\Handler\ConsoleHandler; use Psr\Container\ContainerInterface; -class ModuleApplication implements ModuleInterface +final class ModuleApplication implements ModuleInterface { /** * @return array diff --git a/src/ModuleInfrastructure.php b/src/ModuleInfrastructure.php index 84bd9990..f68b7d3a 100644 --- a/src/ModuleInfrastructure.php +++ b/src/ModuleInfrastructure.php @@ -10,7 +10,7 @@ use ItalyStrap\Finder\FinderInterface; use Psr\EventDispatcher\EventDispatcherInterface; -class ModuleInfrastructure implements \ItalyStrap\Empress\ModuleInterface +final class ModuleInfrastructure implements \ItalyStrap\Empress\ModuleInterface { /** * @return array diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml index ec2f0314..fcaa8789 100644 --- a/tests/unit.suite.yml +++ b/tests/unit.suite.yml @@ -3,6 +3,7 @@ # Suite for unit or integration tests. actor: UnitTester +bootstrap: bootstrap.php modules: enabled: - Asserts diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php new file mode 100644 index 00000000..8aa16d04 --- /dev/null +++ b/tests/unit/bootstrap.php @@ -0,0 +1,9 @@ + Date: Tue, 19 May 2026 19:54:37 +0200 Subject: [PATCH 05/11] refactor: add `readonly` keyword to applicable classes and remove `readonly` from constructor properties for consistency --- src/Application/Middlewares/Dump.php | 6 +++--- src/Application/Middlewares/Validate.php | 8 ++++---- src/Domain/Input/Settings/Color/Gradient.php | 8 ++++---- src/Domain/Input/Settings/Color/Palette.php | 8 ++++---- .../Color/Utilities/ShadesGeneratorExperimental.php | 12 ++++++------ src/Domain/Input/Settings/Typography/FontFamily.php | 8 ++++---- src/Domain/Input/Settings/Typography/FontSize.php | 10 +++++----- .../Input/Settings/Typography/Utilities/Fluid.php | 6 +++--- src/Infrastructure/Filesystem/FilesFinder.php | 4 ++-- tests/unit/bootstrap.php | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Application/Middlewares/Dump.php b/src/Application/Middlewares/Dump.php index 6e691d7d..34110418 100644 --- a/src/Application/Middlewares/Dump.php +++ b/src/Application/Middlewares/Dump.php @@ -15,7 +15,7 @@ use ItalyStrap\ThemeJsonGenerator\Infrastructure\Handler\ConsoleHandler; use Symfony\Component\Console\Output\OutputInterface; -final class Dump implements MiddlewareInterface +final readonly class Dump implements MiddlewareInterface { /** * @var string @@ -25,8 +25,8 @@ final class Dump implements MiddlewareInterface public const JSON_FILE_SUFFIX = '.json'; public function __construct( - private readonly FilesFinder $filesFinder, - private readonly ThemeJsonContainerFactoryInterface $containerFactory + private FilesFinder $filesFinder, + private ThemeJsonContainerFactoryInterface $containerFactory ) { } diff --git a/src/Application/Middlewares/Validate.php b/src/Application/Middlewares/Validate.php index c21b7ccf..cdc26ffc 100644 --- a/src/Application/Middlewares/Validate.php +++ b/src/Application/Middlewares/Validate.php @@ -14,14 +14,14 @@ use ScssPhp\ScssPhp\Compiler; use Symfony\Component\Console\Output\OutputInterface; -final class Validate implements MiddlewareInterface +final readonly class Validate implements MiddlewareInterface { use DataFromJsonTrait; public function __construct( - private readonly Validator $validator, - private readonly Compiler $compiler, - private readonly FilesFinder $filesFinder + private Validator $validator, + private Compiler $compiler, + private FilesFinder $filesFinder ) { } diff --git a/src/Domain/Input/Settings/Color/Gradient.php b/src/Domain/Input/Settings/Color/Gradient.php index 142aecf3..48d3539f 100644 --- a/src/Domain/Input/Settings/Color/Gradient.php +++ b/src/Domain/Input/Settings/Color/Gradient.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -final class Gradient implements PresetInterface +final readonly class Gradient implements PresetInterface { use PresetTrait; @@ -18,9 +18,9 @@ final class Gradient implements PresetInterface public const TYPE = 'gradient'; public function __construct( - private readonly string $slug, - private readonly string $name, - private readonly GradientInterface $gradient + private string $slug, + private string $name, + private GradientInterface $gradient ) { } diff --git a/src/Domain/Input/Settings/Color/Palette.php b/src/Domain/Input/Settings/Color/Palette.php index c389eae3..bc19b80e 100644 --- a/src/Domain/Input/Settings/Color/Palette.php +++ b/src/Domain/Input/Settings/Color/Palette.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -final class Palette implements PresetInterface +final readonly class Palette implements PresetInterface { use PresetTrait; @@ -23,9 +23,9 @@ final class Palette implements PresetInterface public const KEY = 'settings.color.palette'; public function __construct( - private readonly string $slug, - private readonly string $name, - private readonly ColorInterface $color + private string $slug, + private string $name, + private ColorInterface $color ) { } diff --git a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php index 49223e1c..6fd537a7 100644 --- a/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php +++ b/src/Domain/Input/Settings/Color/Utilities/ShadesGeneratorExperimental.php @@ -6,7 +6,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; -final class ShadesGeneratorExperimental +final readonly class ShadesGeneratorExperimental { /** * @var int @@ -55,11 +55,11 @@ public static function fromColorInfo( } public function __construct( - private readonly ColorInterface $color, - private readonly string $slug, - private readonly int $min = self::MIN, - private readonly int $max = self::MAX, - private readonly int $increment_by = self::INCREMENT_BY + private ColorInterface $color, + private string $slug, + private int $min = self::MIN, + private int $max = self::MAX, + private int $increment_by = self::INCREMENT_BY ) { } diff --git a/src/Domain/Input/Settings/Typography/FontFamily.php b/src/Domain/Input/Settings/Typography/FontFamily.php index f0bcff0c..b479d213 100644 --- a/src/Domain/Input/Settings/Typography/FontFamily.php +++ b/src/Domain/Input/Settings/Typography/FontFamily.php @@ -7,7 +7,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetTrait; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; -final class FontFamily implements PresetInterface +final readonly class FontFamily implements PresetInterface { use PresetTrait; @@ -17,9 +17,9 @@ final class FontFamily implements PresetInterface public const TYPE = 'fontFamily'; public function __construct( - private readonly string $slug, - private readonly string $name, - private readonly string $fontFamily + private string $slug, + private string $name, + private string $fontFamily ) { } diff --git a/src/Domain/Input/Settings/Typography/FontSize.php b/src/Domain/Input/Settings/Typography/FontSize.php index d8b2ebfb..1c786518 100644 --- a/src/Domain/Input/Settings/Typography/FontSize.php +++ b/src/Domain/Input/Settings/Typography/FontSize.php @@ -8,7 +8,7 @@ use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities\Fluid; -final class FontSize implements PresetInterface +final readonly class FontSize implements PresetInterface { use PresetTrait; @@ -18,10 +18,10 @@ final class FontSize implements PresetInterface public const TYPE = 'fontSize'; public function __construct( - private readonly string $slug, - private readonly string $name, - private readonly string $size, - private readonly ?Fluid $fluid = null + private string $slug, + private string $name, + private string $size, + private ?Fluid $fluid = null ) { } diff --git a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php index b61258c4..c706c32c 100644 --- a/src/Domain/Input/Settings/Typography/Utilities/Fluid.php +++ b/src/Domain/Input/Settings/Typography/Utilities/Fluid.php @@ -4,7 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Typography\Utilities; -final class Fluid +final readonly class Fluid { /** * @var string @@ -22,8 +22,8 @@ final class Fluid public const MAX = 'max'; public function __construct( - private readonly string $min, - private readonly string $max + private string $min, + private string $max ) { } diff --git a/src/Infrastructure/Filesystem/FilesFinder.php b/src/Infrastructure/Filesystem/FilesFinder.php index 58d8f09c..0a8545c9 100644 --- a/src/Infrastructure/Filesystem/FilesFinder.php +++ b/src/Infrastructure/Filesystem/FilesFinder.php @@ -6,7 +6,7 @@ use ItalyStrap\Finder\FinderInterface; -final class FilesFinder +final readonly class FilesFinder { public const ROOT_FILE_NAME = 'theme'; @@ -14,7 +14,7 @@ final class FilesFinder public const JSON_FILE_SUFFIX = '.json'; - public function __construct(private readonly FinderInterface $finder) + public function __construct(private FinderInterface $finder) { } diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 8aa16d04..8bc0c325 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -4,6 +4,6 @@ use DG\BypassFinals; -(function () { +(function (): void { BypassFinals::enable(); })(); From d70576c37af93830f19c063d71d8853b407f8a62 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 20:13:26 +0200 Subject: [PATCH 06/11] refactor: update assertions in test classes for stricter type and precision checks, and remove unused test methods --- .../Input/Settings/Color/Utilities/ColorTest.php | 10 +++++----- tests/unit/Domain/Input/Settings/Custom/CustomTest.php | 8 -------- tests/unit/Domain/Input/Styles/SpacingTest.php | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php index 2a9ed043..2edd395b 100644 --- a/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php +++ b/tests/unit/Domain/Input/Settings/Color/Utilities/ColorTest.php @@ -265,30 +265,30 @@ public function testItShouldReturnLuminanceValue(): void { $sut = $this->makeInstance('#ff0000'); - $this->assertSame(0.2126, $sut->luminance(), ''); + $this->assertEqualsWithDelta(0.2126, $sut->luminance(), PHP_FLOAT_EPSILON, ''); } public function testItShouldReturnRelativeLuminanceValue(): void { $sut = $this->makeInstance('#000000'); $color = $this->makeInstance('#ffffff'); - $this->assertSame(21.0, $sut->relativeLuminance($color), ''); + $this->assertEqualsWithDelta(21.0, $sut->relativeLuminance($color), PHP_FLOAT_EPSILON, ''); $sut = $this->makeInstance('#000000'); $color = $this->makeInstance('#bada55'); - $this->assertTrue($sut->relativeLuminance($color) >= 4.5, ''); + $this->assertGreaterThanOrEqual(4.5, $sut->relativeLuminance($color), ''); } public function testConversionToDifferentFormat(): void { $sut = $this->makeInstance('rgba(0,0,0,0.25)'); - $this->assertSame(0.25, $sut->alpha(), ''); + $this->assertEqualsWithDelta(0.25, $sut->alpha(), PHP_FLOAT_EPSILON, ''); $sut = $this->makeInstance('#000000'); $this->assertSame('ff', $sut->alpha(), ''); $sut = $this->makeInstance('hsla(0,0,0,0.25)'); - $this->assertSame(0.25, $sut->alpha(), ''); + $this->assertEqualsWithDelta(0.25, $sut->alpha(), PHP_FLOAT_EPSILON, ''); $this->assertStringMatchesFormat('#000000', (string)$sut->toHex(), ''); $this->assertStringMatchesFormat('rgb(0,0,0)', (string)$sut->toRgb(), ''); diff --git a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php index 02bb0878..539d3a25 100644 --- a/tests/unit/Domain/Input/Settings/Custom/CustomTest.php +++ b/tests/unit/Domain/Input/Settings/Custom/CustomTest.php @@ -23,12 +23,4 @@ private function makeInstance(): Custom $this->name ); } - - public function testSlug(): void - { - } - - public function testProp(): void - { - } } diff --git a/tests/unit/Domain/Input/Styles/SpacingTest.php b/tests/unit/Domain/Input/Styles/SpacingTest.php index 6a7355f5..bb0db448 100644 --- a/tests/unit/Domain/Input/Styles/SpacingTest.php +++ b/tests/unit/Domain/Input/Styles/SpacingTest.php @@ -140,7 +140,7 @@ public function testItShouldReturnTheCorrectValue(): void ->bottom('50px') ->left('5rem'); - $this->assertEquals( + $this->assertSame( [ 'top' => '25px', 'right' => '25px', From fbb07cab08d37e4b5abff774a4ff3d2392fde1df Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 20:17:25 +0200 Subject: [PATCH 07/11] refactor: remove unused imports across command and test classes for cleaner codebase --- src/Application/Commands/DumpCommand.php | 1 - tests/unit/Domain/Input/Settings/PresetsTest.php | 1 - tests/unit/Domain/Input/Styles/CssTest.php | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/Application/Commands/DumpCommand.php b/src/Application/Commands/DumpCommand.php index 1eb00444..60d4ce46 100644 --- a/src/Application/Commands/DumpCommand.php +++ b/src/Application/Commands/DumpCommand.php @@ -12,7 +12,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Process\Process; #[AsCommand(name: DumpCommand::NAME, description: DumpCommand::DESCRIPTION)] final class DumpCommand extends Command diff --git a/tests/unit/Domain/Input/Settings/PresetsTest.php b/tests/unit/Domain/Input/Settings/PresetsTest.php index e6dca63d..cb52ab4e 100644 --- a/tests/unit/Domain/Input/Settings/PresetsTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsTest.php @@ -6,7 +6,6 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Presets; -use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\PresetInterface; final class PresetsTest extends UnitTestCase diff --git a/tests/unit/Domain/Input/Styles/CssTest.php b/tests/unit/Domain/Input/Styles/CssTest.php index 608e3ff4..4a7507f5 100644 --- a/tests/unit/Domain/Input/Styles/CssTest.php +++ b/tests/unit/Domain/Input/Styles/CssTest.php @@ -8,8 +8,6 @@ use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Css; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\CssInterface; -use ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Scss; -use ScssPhp\ScssPhp\Compiler; final class CssTest extends UnitTestCase { From 67044ee3fcb42c4d94d80ce8747bd637666eee63 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 20:21:40 +0200 Subject: [PATCH 08/11] refactor: simplify imports and class declarations across middleware and test classes, replacing fully qualified names with use statements for clarity and consistency --- src/Application/Commands/InitCommand.php | 3 ++- src/Application/Middlewares/Dump.php | 3 ++- src/Application/Middlewares/Init.php | 3 ++- src/Application/Middlewares/Validate.php | 3 ++- src/ModuleInfrastructure.php | 8 +++++--- tests/_support/FunctionalTester.php | 7 +++++-- tests/_support/Helper/Functional.php | 5 +++-- tests/_support/Helper/Integration.php | 5 +++-- tests/_support/Helper/Unit.php | 5 +++-- tests/_support/IntegrationTester.php | 7 +++++-- tests/_support/UnitTester.php | 7 +++++-- .../unit/Domain/Input/Settings/PresetsIntegrationTest.php | 6 ++++-- .../Filesystem/JsonFileWriterIntegrationTest.php | 2 +- 13 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/Application/Commands/InitCommand.php b/src/Application/Commands/InitCommand.php index a1c13545..001c9a61 100644 --- a/src/Application/Commands/InitCommand.php +++ b/src/Application/Commands/InitCommand.php @@ -4,6 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application\Commands; +use Symfony\Component\Console\Input\InputOption; use ItalyStrap\ThemeJsonGenerator\Application\Commands\Utils\RootFolderTrait; use ItalyStrap\ThemeJsonGenerator\Application\Message; use ItalyStrap\ThemeJsonGenerator\Infrastructure\Filesystem\DataFromJsonTrait; @@ -37,7 +38,7 @@ protected function configure(): void $this->addOption( 'styles', 's', - \Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, + InputOption::VALUE_OPTIONAL, 'Init JSON file inside styles folder' ); } diff --git a/src/Application/Middlewares/Dump.php b/src/Application/Middlewares/Dump.php index 34110418..2ab10b83 100644 --- a/src/Application/Middlewares/Dump.php +++ b/src/Application/Middlewares/Dump.php @@ -4,6 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application\Middlewares; +use Symfony\Component\Console\Output\ConsoleOutput; use ItalyStrap\Pipeline\HandlerInterface; use ItalyStrap\Pipeline\MiddlewareInterface; use ItalyStrap\ThemeJsonGenerator\Api\ThemeJson; @@ -39,7 +40,7 @@ public function process(object $message, HandlerInterface $handler): int /** * OutputInterface $output */ - $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + $output = new ConsoleOutput(); $count = 0; diff --git a/src/Application/Middlewares/Init.php b/src/Application/Middlewares/Init.php index b0dd96f3..270904d0 100644 --- a/src/Application/Middlewares/Init.php +++ b/src/Application/Middlewares/Init.php @@ -4,6 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application\Middlewares; +use Symfony\Component\Console\Output\ConsoleOutput; use Brick\VarExporter\VarExporter; use ItalyStrap\Pipeline\HandlerInterface; use ItalyStrap\Pipeline\MiddlewareInterface; @@ -58,7 +59,7 @@ public function process(object $message, HandlerInterface $handler): int /** * OutputInterface $output */ - $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + $output = new ConsoleOutput(); foreach ($this->filesFinder->find($message->getRootFolder(), 'json') as $file) { $this->generateEntryPointDataFile($output, $file); diff --git a/src/Application/Middlewares/Validate.php b/src/Application/Middlewares/Validate.php index cdc26ffc..9b15f9b8 100644 --- a/src/Application/Middlewares/Validate.php +++ b/src/Application/Middlewares/Validate.php @@ -4,6 +4,7 @@ namespace ItalyStrap\ThemeJsonGenerator\Application\Middlewares; +use Symfony\Component\Console\Output\ConsoleOutput; use ItalyStrap\Pipeline\HandlerInterface; use ItalyStrap\Pipeline\MiddlewareInterface; use ItalyStrap\ThemeJsonGenerator\Application\ValidateMessage; @@ -34,7 +35,7 @@ public function process(object $message, HandlerInterface $handler): mixed /** * OutputInterface $output */ - $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + $output = new ConsoleOutput(); foreach ($this->filesFinder->find($message->getRootFolder(), 'json') as $file) { $output->writeln('========================'); diff --git a/src/ModuleInfrastructure.php b/src/ModuleInfrastructure.php index f68b7d3a..1fb8f33d 100644 --- a/src/ModuleInfrastructure.php +++ b/src/ModuleInfrastructure.php @@ -4,13 +4,15 @@ namespace ItalyStrap\ThemeJsonGenerator; +use ItalyStrap\Empress\ModuleInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use ItalyStrap\Empress\AurynConfig; use ItalyStrap\Finder\Finder; use ItalyStrap\Finder\FinderFactory; use ItalyStrap\Finder\FinderInterface; use Psr\EventDispatcher\EventDispatcherInterface; -final class ModuleInfrastructure implements \ItalyStrap\Empress\ModuleInterface +final class ModuleInfrastructure implements ModuleInterface { /** * @return array @@ -20,11 +22,11 @@ public function __invoke(): array return [ AurynConfig::ALIASES => [ FinderInterface::class => Finder::class, - EventDispatcherInterface::class => \Symfony\Component\EventDispatcher\EventDispatcher::class, + EventDispatcherInterface::class => EventDispatcher::class, ], AurynConfig::SHARING => [ EventDispatcherInterface::class, - \Symfony\Component\EventDispatcher\EventDispatcher::class + EventDispatcher::class ], AurynConfig::FACTORIES => [ Finder::class => static fn (): FinderInterface => (new FinderFactory())->make(), diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index cd145b03..1d759e7c 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -2,6 +2,9 @@ declare(strict_types=1); +use Codeception\Actor; +use _generated\FunctionalTesterActions; + /** * Inherited Methods @@ -18,9 +21,9 @@ * * @SuppressWarnings(PHPMD) */ -final class FunctionalTester extends \Codeception\Actor +final class FunctionalTester extends Actor { - use _generated\FunctionalTesterActions; + use FunctionalTesterActions; /** * Define custom actions here diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php index 020234b4..1ff87bb6 100644 --- a/tests/_support/Helper/Functional.php +++ b/tests/_support/Helper/Functional.php @@ -4,9 +4,10 @@ namespace Helper; +use Codeception\Module; + // here you can define custom actions // all public methods declared in helper class will be available in $I - -final class Functional extends \Codeception\Module +final class Functional extends Module { } diff --git a/tests/_support/Helper/Integration.php b/tests/_support/Helper/Integration.php index 37795b30..a6477ff1 100644 --- a/tests/_support/Helper/Integration.php +++ b/tests/_support/Helper/Integration.php @@ -4,10 +4,11 @@ namespace Helper; +use Codeception\Module; + // here you can define custom actions // all public methods declared in helper class will be available in $I - -final class Integration extends \Codeception\Module +final class Integration extends Module { } diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index ddb58e41..f199b5e0 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -4,9 +4,10 @@ namespace Helper; +use Codeception\Module; + // here you can define custom actions // all public methods declared in helper class will be available in $I - -final class Unit extends \Codeception\Module +final class Unit extends Module { } diff --git a/tests/_support/IntegrationTester.php b/tests/_support/IntegrationTester.php index 4a5810d8..a40addab 100644 --- a/tests/_support/IntegrationTester.php +++ b/tests/_support/IntegrationTester.php @@ -2,6 +2,9 @@ declare(strict_types=1); +use Codeception\Actor; +use _generated\IntegrationTesterActions; + /** * Inherited Methods * @method void wantToTest($text) @@ -17,9 +20,9 @@ * * @SuppressWarnings(PHPMD) */ -final class IntegrationTester extends \Codeception\Actor +final class IntegrationTester extends Actor { - use _generated\IntegrationTesterActions; + use IntegrationTesterActions; /** * Define custom actions here diff --git a/tests/_support/UnitTester.php b/tests/_support/UnitTester.php index 21caf593..4e4da746 100644 --- a/tests/_support/UnitTester.php +++ b/tests/_support/UnitTester.php @@ -2,6 +2,9 @@ declare(strict_types=1); +use Codeception\Actor; +use _generated\UnitTesterActions; + /** * Inherited Methods @@ -18,9 +21,9 @@ * * @SuppressWarnings(PHPMD) */ -final class UnitTester extends \Codeception\Actor +final class UnitTester extends Actor { - use _generated\UnitTesterActions; + use UnitTesterActions; /** * Define custom actions here diff --git a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php index d186e367..b598d88e 100644 --- a/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php +++ b/tests/unit/Domain/Input/Settings/PresetsIntegrationTest.php @@ -4,6 +4,8 @@ namespace ItalyStrap\Tests\Unit\Domain\Input\Settings; +use FontLib\Font; +use FontLib\TrueType\File; use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Presets; use ItalyStrap\ThemeJsonGenerator\Domain\Input\Settings\Color\Palette; @@ -266,8 +268,8 @@ public function testFonts(): void $files = \glob(\codecept_data_dir($relativePath . '**/*'), GLOB_BRACE); foreach ($files as $file) { break; - $font = \FontLib\Font::load($file); - if (!$font instanceof \FontLib\TrueType\File) { + $font = Font::load($file); + if (!$font instanceof File) { continue; } diff --git a/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php b/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php index 0210cf12..2f1f7d76 100644 --- a/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php +++ b/tests/unit/Infrastructure/Filesystem/JsonFileWriterIntegrationTest.php @@ -30,7 +30,7 @@ final class JsonFileWriterIntegrationTest extends UnitTestCase private ?\ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Color $colorIntegration = null; - private ?\ItalyStrap\ThemeJsonGenerator\Domain\Input\Styles\Typography $typographyIntegration = null; + private ?Typography $typographyIntegration = null; protected function makeInstance(): JsonFileWriter { From 782c3e2ae18356778aeac5527ec0f5bb8ed86a59 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 20:25:44 +0200 Subject: [PATCH 09/11] refactor: update Rector configuration for better rules organization, enable unused import removal, and apply coding style improvements --- rector.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/rector.php b/rector.php index f2abfa53..7052a33c 100644 --- a/rector.php +++ b/rector.php @@ -22,12 +22,21 @@ ->withRules([ StaticDataProviderClassMethodRector::class, ]) - ->withSets([ - SetList::CODE_QUALITY, - SetList::CODING_STYLE, - SetList::EARLY_RETURN, - SetList::TYPE_DECLARATION, - SetList::INSTANCEOF, - ]) + ->withPreparedSets( +// deadCode: true, // Not yet, this removes also some commented code that I need to keep. + codeQuality: true, + codingStyle: true, + typeDeclarations: true, + privatization: true, + instanceOf: true, + earlyReturn: true, +// carbon: true, + phpunitCodeQuality: true, + ) + ->withImportNames( + importDocBlockNames: false, + importShortClasses: false, + removeUnusedImports: true, + ) ->withPhpSets() ->withoutParallel(); From 6cad7f0efa98e33799abf20d5b10c6f1f6403c32 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 20:26:04 +0200 Subject: [PATCH 10/11] refactor: update class aliasing logic to ensure aliases are only created if the target class does not already exist --- namespace-bc-aliases.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/namespace-bc-aliases.php b/namespace-bc-aliases.php index b7fda12f..2f206016 100644 --- a/namespace-bc-aliases.php +++ b/namespace-bc-aliases.php @@ -2,7 +2,12 @@ declare(strict_types=1); -\class_alias( - 'ItalyStrap\ThemeJsonGenerator\Api\ThemeJson', - 'ItalyStrap\ThemeJsonGenerator\Application\Config\Blueprint' -); +$aliases = [ + 'ItalyStrap\ThemeJsonGenerator\Api\ThemeJson' => 'ItalyStrap\ThemeJsonGenerator\Application\Config\Blueprint', +]; + +foreach ($aliases as $class => $alias) { + if (!\class_exists($alias)) { + \class_alias($class, $alias); + } +} From 1cbbcfdfe372b17ed4060f1941b13e187b5a2abd Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 19 May 2026 21:31:44 +0200 Subject: [PATCH 11/11] refactor: update Docker setup to handle host user and group mappings, improve permissions management, and align code execution with `www-data` user --- .docker/codecept | 6 +++++- .docker/composer | 7 ++++++- .docker/docker-compose.yml | 2 ++ .docker/wordpress/Dockerfile | 14 ++++++++++++-- Makefile | 7 ++++++- rector.php | 2 +- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.docker/codecept b/.docker/codecept index 6a4eb803..79d34f10 100755 --- a/.docker/codecept +++ b/.docker/codecept @@ -3,4 +3,8 @@ # Get project name from .env file PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"') -docker exec -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh -c "vendor/bin/codecept ${*}" \ No newline at end of file +docker exec \ + --user www-data \ + -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" \ + "${PROJECT_NAME}"_test \ + sh -c "vendor/bin/codecept ${*}" diff --git a/.docker/composer b/.docker/composer index 2d5d5da6..bfb45f3a 100755 --- a/.docker/composer +++ b/.docker/composer @@ -3,4 +3,9 @@ # Get project name from .env file PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"') -docker-compose run -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" --rm wordpress sh -c "composer ${*}" +docker-compose run \ + --user www-data \ + -w /var/www/html/wp-content/plugins/"${PROJECT_NAME}" \ + --rm \ + wordpress \ + sh -c "composer ${*}" diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 4ef25bf5..05b4b8c6 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -5,6 +5,8 @@ services: args: PHP_VERSION: ${PHP_VERSION} WP_VERSION: ${WP_VERSION} + HOST_UID: ${HOST_UID:-1000} + HOST_GID: ${HOST_GID:-1000} container_name: ${PROJECT_NAME:-wordpress}_test restart: always ports: diff --git a/.docker/wordpress/Dockerfile b/.docker/wordpress/Dockerfile index 4e5757ed..558dc707 100644 --- a/.docker/wordpress/Dockerfile +++ b/.docker/wordpress/Dockerfile @@ -1,8 +1,18 @@ -ARG PHP_VERSION -ARG WP_VERSION +ARG PHP_VERSION=8.2 +ARG WP_VERSION=6 +ARG HOST_UID=1000 +ARG HOST_GID=1000 FROM wordpress:${WP_VERSION}-php${PHP_VERSION} +ARG HOST_UID +ARG HOST_GID + +RUN set -eux; \ + groupmod -o -g "${HOST_GID}" www-data; \ + usermod -o -u "${HOST_UID}" -g "${HOST_GID}" www-data; \ + chown -R www-data:www-data /var/www + # Install pcov for code coverage RUN set -eux; \ pecl install pcov; \ diff --git a/Makefile b/Makefile index 21dfe3a9..1bcd3b3a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ DOCKER_FOLDER = .docker DOCKER_DIR = cd $(DOCKER_FOLDER) && -HOST_OWNER = $(shell id -u):$(shell id -g) +HOST_UID = $(shell id -u) +HOST_GID = $(shell id -g) +HOST_OWNER = $(HOST_UID):$(HOST_GID) FILES_OWNERSHIP = sudo chown -R $(HOST_OWNER) . DB_USER = $(shell cat .docker/.env | grep DB_USER | cut -d '=' -f2) DB_PASSWORD = $(shell cat .docker/.env | grep DB_PASSWORD | cut -d '=' -f2) DB_NAME = $(shell cat .docker/.env | grep DB_NAME | cut -d '=' -f2) +export HOST_UID +export HOST_GID + default: help # https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html diff --git a/rector.php b/rector.php index 7052a33c..6138090a 100644 --- a/rector.php +++ b/rector.php @@ -30,7 +30,7 @@ privatization: true, instanceOf: true, earlyReturn: true, -// carbon: true, + // carbon: true, phpunitCodeQuality: true, ) ->withImportNames(