diff --git a/src/App/src/Handler/HomePageHandler.php b/src/App/src/Handler/HomePageHandler.php index dc629a7..0b35cfe 100644 --- a/src/App/src/Handler/HomePageHandler.php +++ b/src/App/src/Handler/HomePageHandler.php @@ -24,9 +24,9 @@ class HomePageHandler implements RequestHandlerInterface { public function __construct( - private string $containerName, - private RouterInterface $router, - private ?TemplateRendererInterface $template = null + private readonly string $containerName, + private readonly RouterInterface $router, + private readonly ?TemplateRendererInterface $template = null ) { } diff --git a/src/MezzioInstaller/OptionalPackages.php b/src/MezzioInstaller/OptionalPackages.php index a39588a..5270dca 100644 --- a/src/MezzioInstaller/OptionalPackages.php +++ b/src/MezzioInstaller/OptionalPackages.php @@ -175,7 +175,7 @@ class OptionalPackages ]; /** @var string Path to this file. */ - private string $installerSource; + private readonly string $installerSource; /** @var self::INSTALL_* Installation type selected. */ private string $installType = self::INSTALL_FLAT; @@ -214,8 +214,11 @@ public static function install(Event $event): void $installer->finalizePackage(); } - public function __construct(private IOInterface $io, private Composer $composer, ?string $projectRoot = null) - { + public function __construct( + private readonly IOInterface $io, + private readonly Composer $composer, + ?string $projectRoot = null + ) { // Get composer.json location $composerFile = Factory::getComposerFile(); diff --git a/test/MezzioInstallerTest/OptionalPackagesTestCase.php b/test/MezzioInstallerTest/OptionalPackagesTestCase.php index 2216347..306bc95 100644 --- a/test/MezzioInstallerTest/OptionalPackagesTestCase.php +++ b/test/MezzioInstallerTest/OptionalPackagesTestCase.php @@ -54,8 +54,8 @@ public static function assertPackage( OptionalPackages $installer, ?string $message = null ): void { - $message = $message ?? sprintf('Failed asserting that package "%s" is present in the installer', $package); - $found = false; + $message ??= sprintf('Failed asserting that package "%s" is present in the installer', $package); + $found = false; foreach (['composerRequires', 'composerDevRequires'] as $property) { $r = new ReflectionProperty($installer, $property); @@ -78,8 +78,8 @@ public static function assertNotPackage( OptionalPackages $installer, ?string $message = null ): void { - $message = $message ?? sprintf('Failed asserting that package "%s" is absent from the installer', $package); - $found = false; + $message ??= sprintf('Failed asserting that package "%s" is absent from the installer', $package); + $found = false; foreach (['composerRequires', 'composerDevRequires'] as $property) { $r = new ReflectionProperty($installer, $property); @@ -134,8 +134,8 @@ public static function assertWhitelisted( OptionalPackages $installer, ?string $message = null ): void { - $message = $message ?? sprintf('Failed asserting that package "%s" is whitelisted in composer.json', $package); - $found = false; + $message ??= sprintf('Failed asserting that package "%s" is whitelisted in composer.json', $package); + $found = false; $r = new ReflectionProperty($installer, 'composerDefinition'); @@ -167,8 +167,8 @@ protected function tearDown(): void */ protected function createOptionalPackages(?string $projectRoot = null): OptionalPackages { - $projectRoot = $projectRoot ?? $this->packageRoot; - $this->io = $this->createMock(IOInterface::class); + $projectRoot ??= $this->packageRoot; + $this->io = $this->createMock(IOInterface::class); return new OptionalPackages( $this->io, $this->createComposer(),