From 1f31c41dc92f8a300001ece2979962a738e76a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20W=C3=BCnsch?= Date: Fri, 22 Nov 2024 10:16:26 +0100 Subject: [PATCH 1/2] PHP 8.4: Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead. --- src/Cli/PhpProcess.php | 4 ++-- src/Cli/PhpToolProcess.php | 2 +- src/Cli/PhpToolProcessFactory.php | 2 +- src/Cli/SystemProcess.php | 6 +++--- src/Config/Result.php | 4 ++-- src/Env/WordPressEnvBridge.php | 8 ++++---- src/Io/Io.php | 2 +- src/Io/Question.php | 2 +- src/Step/EnvExampleStep.php | 2 +- src/Util/Paths.php | 2 +- src/Util/WpVersion.php | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Cli/PhpProcess.php b/src/Cli/PhpProcess.php index 0bf1365..dde5b95 100644 --- a/src/Cli/PhpProcess.php +++ b/src/Cli/PhpProcess.php @@ -53,7 +53,7 @@ public function withEnvironment(array $environment): PhpProcess * @param string|null $cwd * @return bool */ - public function execute(string $command, string $cwd = null): bool + public function execute(string $command, ?string $cwd = null): bool { return $this->process->execute("{$this->phpPath} {$command}", $cwd); } @@ -63,7 +63,7 @@ public function execute(string $command, string $cwd = null): bool * @param string|null $cwd * @return bool */ - public function executeSilently(string $command, string $cwd = null): bool + public function executeSilently(string $command, ?string $cwd = null): bool { return $this->process->executeSilently("{$this->phpPath} {$command}", $cwd); } diff --git a/src/Cli/PhpToolProcess.php b/src/Cli/PhpToolProcess.php index 55f6307..343827d 100644 --- a/src/Cli/PhpToolProcess.php +++ b/src/Cli/PhpToolProcess.php @@ -94,7 +94,7 @@ public function execute(string $command): bool * @param string|null $cwd * @return bool */ - public function executeSilently(string $command, string $cwd = null): bool + public function executeSilently(string $command, ?string $cwd = null): bool { return $this->phpProcess->executeSilently( $this->tool->prepareCommand( diff --git a/src/Cli/PhpToolProcessFactory.php b/src/Cli/PhpToolProcessFactory.php index 3b4f3f4..a9b8c0d 100644 --- a/src/Cli/PhpToolProcessFactory.php +++ b/src/Cli/PhpToolProcessFactory.php @@ -62,7 +62,7 @@ public function __construct( * @param string|null $phpPath * @return PhpToolProcess */ - public function create(PhpTool $command, string $phpPath = null): PhpToolProcess + public function create(PhpTool $command, ?string $phpPath = null): PhpToolProcess { ($phpPath === null) and $phpPath = (new PhpExecutableFinder())->find(); if (!$phpPath) { diff --git a/src/Cli/SystemProcess.php b/src/Cli/SystemProcess.php index e6f6617..760f5ff 100644 --- a/src/Cli/SystemProcess.php +++ b/src/Cli/SystemProcess.php @@ -63,7 +63,7 @@ public function withEnvironment(array $environment): SystemProcess * @param string|null $cwd * @return bool */ - public function execute(string $command, string $cwd = null): bool + public function execute(string $command, ?string $cwd = null): bool { try { is_string($cwd) or $cwd = $this->paths->root(); @@ -93,7 +93,7 @@ public function execute(string $command, string $cwd = null): bool * @param string|null $cwd * @return bool */ - public function executeSilently(string $command, string $cwd = null): bool + public function executeSilently(string $command, ?string $cwd = null): bool { try { is_string($cwd) or $cwd = $this->paths->root(); @@ -113,7 +113,7 @@ public function executeSilently(string $command, string $cwd = null): bool * @param string|null $cwd * @return Process */ - private function factoryProcess(string $command, string $cwd = null): Process + private function factoryProcess(string $command, ?string $cwd = null): Process { if (method_exists(Process::class, 'fromShellCommandline')) { return Process::fromShellCommandline($command, $cwd, $this->environment ?: null); diff --git a/src/Config/Result.php b/src/Config/Result.php index def4ae8..b5c7193 100644 --- a/src/Config/Result.php +++ b/src/Config/Result.php @@ -60,7 +60,7 @@ public static function none(): Result * @param \Throwable|null $error * @return Result */ - public static function error(\Throwable $error = null): Result + public static function error(?\Throwable $error = null): Result { return new static(null, $error ?: new \Error('Error.')); } @@ -92,7 +92,7 @@ public static function promise(callable $provider): Result * * phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration */ - private function __construct($value = null, \Throwable $error = null) + private function __construct($value = null, ?\Throwable $error = null) { // phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration diff --git a/src/Env/WordPressEnvBridge.php b/src/Env/WordPressEnvBridge.php index 6618f01..7461f7d 100644 --- a/src/Env/WordPressEnvBridge.php +++ b/src/Env/WordPressEnvBridge.php @@ -307,7 +307,7 @@ public static function loadedVars(): array /** * @param Dotenv|null $dotenv */ - public function __construct(Dotenv $dotenv = null) + public function __construct(?Dotenv $dotenv = null) { $this->dotenv = $dotenv; } @@ -317,7 +317,7 @@ public function __construct(Dotenv $dotenv = null) * @param string|null $path Environment file path * @return void */ - public function load(string $file = '.env', string $path = null) + public function load(string $file = '.env', ?string $path = null) { $this->loadFile($this->fullpathFor($file, $path)); } @@ -375,7 +375,7 @@ public function loadFile(string $path) * @param string|null $path * @return void */ - public function loadAppended(string $file, string $path = null) + public function loadAppended(string $file, ?string $path = null) { if (self::$loadedVars === null) { $this->load($file, $path); @@ -729,7 +729,7 @@ private function isWritable(string $name): bool * @param string|null $basePath * @return string */ - private function fullpathFor(string $filename, string $basePath = null): string + private function fullpathFor(string $filename, ?string $basePath = null): string { $basePath === null and $basePath = getcwd(); diff --git a/src/Io/Io.php b/src/Io/Io.php index ad99cef..df6c4d1 100644 --- a/src/Io/Io.php +++ b/src/Io/Io.php @@ -32,7 +32,7 @@ class Io * @param IOInterface $io * @param Formatter|null $formatter */ - public function __construct(IOInterface $io, Formatter $formatter = null) + public function __construct(IOInterface $io, ?Formatter $formatter = null) { $this->io = $io; $this->formatter = $formatter ?: new Formatter(); diff --git a/src/Io/Question.php b/src/Io/Question.php index ab56fb8..e5d1fbb 100644 --- a/src/Io/Question.php +++ b/src/Io/Question.php @@ -38,7 +38,7 @@ class Question * @param array $answers * @param string|null $default */ - public function __construct(array $lines, array $answers = [], string $default = null) + public function __construct(array $lines, array $answers = [], ?string $default = null) { $this->lines = array_filter( $lines, diff --git a/src/Step/EnvExampleStep.php b/src/Step/EnvExampleStep.php index e47ae52..0570c7f 100644 --- a/src/Step/EnvExampleStep.php +++ b/src/Step/EnvExampleStep.php @@ -170,7 +170,7 @@ private function download(string $url, string $destination): int * @param string|null $source * @return int */ - private function copy(Paths $paths, string $destination, string $source = null): int + private function copy(Paths $paths, string $destination, ?string $source = null): int { if ($source === null) { $source = $paths->template('.env.example'); diff --git a/src/Util/Paths.php b/src/Util/Paths.php index 54563cf..28c36ee 100644 --- a/src/Util/Paths.php +++ b/src/Util/Paths.php @@ -297,7 +297,7 @@ public function offsetUnset($offset) * @param string|null $root * @return array */ - private function parse(string $root = null): array + private function parse(?string $root = null): array { $vendorDir = (string)$this->config->get('vendor-dir'); $binDir = (string)$this->config->get('bin-dir'); diff --git a/src/Util/WpVersion.php b/src/Util/WpVersion.php index 313b49b..97caa2c 100644 --- a/src/Util/WpVersion.php +++ b/src/Util/WpVersion.php @@ -67,7 +67,7 @@ public static function normalize(string $version): string public function __construct( PackageFinder $packageFinder, Io $io, - string $fallbackVersion = null + ?string $fallbackVersion = null ) { $this->packageFinder = $packageFinder; From 4f9e70fca45f0ac50bd07e015ee2e8ed2ae4aa03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20W=C3=BCnsch?= Date: Fri, 22 Nov 2024 10:29:38 +0100 Subject: [PATCH 2/2] PHP 8.4: Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead. --- src/Env/WordPressEnvBridge.php | 2 +- tests/integration/Cli/PhpToolProcessFactoryTest.php | 2 +- tests/integration/Cli/WpCliToolTest.php | 2 +- tests/src/IntegrationTestCase.php | 8 ++++---- tests/src/TestCase.php | 2 +- tests/unit/Util/RequirementsTest.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Env/WordPressEnvBridge.php b/src/Env/WordPressEnvBridge.php index 5576d76..7f3dc2f 100644 --- a/src/Env/WordPressEnvBridge.php +++ b/src/Env/WordPressEnvBridge.php @@ -331,7 +331,7 @@ public static function loadedVars(): array /** * @param Dotenv|null $dotenv */ - public function __construct(Dotenv $dotenv = null) + public function __construct(?Dotenv $dotenv = null) { $this->dotenv = $dotenv; } diff --git a/tests/integration/Cli/PhpToolProcessFactoryTest.php b/tests/integration/Cli/PhpToolProcessFactoryTest.php index 29fa6e3..f2c5747 100644 --- a/tests/integration/Cli/PhpToolProcessFactoryTest.php +++ b/tests/integration/Cli/PhpToolProcessFactoryTest.php @@ -215,7 +215,7 @@ private function assertProcessWorks(PhpToolProcess $process): void * @return PhpToolProcessFactory */ private function factoryPhpToolProcessFactory( - UrlDownloader $urlDownloader = null + ?UrlDownloader $urlDownloader = null ): PhpToolProcessFactory { $composer = $this->factoryComposer(); diff --git a/tests/integration/Cli/WpCliToolTest.php b/tests/integration/Cli/WpCliToolTest.php index 8d5b540..18fbf75 100644 --- a/tests/integration/Cli/WpCliToolTest.php +++ b/tests/integration/Cli/WpCliToolTest.php @@ -151,7 +151,7 @@ public function testCheckPharError(): void * @param string|null $cwd * @return WpCliTool */ - private function factoryTool(string $cwd = null): WpCliTool + private function factoryTool(?string $cwd = null): WpCliTool { return new WpCliTool( new Config( diff --git a/tests/src/IntegrationTestCase.php b/tests/src/IntegrationTestCase.php index 5277f4a..ec45c60 100644 --- a/tests/src/IntegrationTestCase.php +++ b/tests/src/IntegrationTestCase.php @@ -142,7 +142,7 @@ protected function factoryComposerIo( * @return Paths */ protected function factoryPaths( - string $cwd = null, + ?string $cwd = null, int $verbosity = OutputInterface::VERBOSITY_NORMAL, string $input = '', array $extra = [] @@ -171,7 +171,7 @@ protected function factoryPaths( protected function factoryComposerConfig( string $input = '', int $verbosity = OutputInterface::VERBOSITY_NORMAL, - string $cwd = null + ?string $cwd = null ): Composer\Config { return Composer\Factory::createConfig( @@ -194,7 +194,7 @@ protected function factoryComposer(): Composer\Composer * @param string $cwd * @return SystemProcess */ - protected function factorySystemProcess(string $cwd = null): SystemProcess + protected function factorySystemProcess(?string $cwd = null): SystemProcess { return new SystemProcess( $this->factoryPaths($cwd), @@ -206,7 +206,7 @@ protected function factorySystemProcess(string $cwd = null): SystemProcess * @param string $cwd * @return PhpProcess */ - protected function factoryPhpProcess(string $cwd = null): PhpProcess + protected function factoryPhpProcess(?string $cwd = null): PhpProcess { $php = (new PhpExecutableFinder())->find() ?: 'php'; diff --git a/tests/src/TestCase.php b/tests/src/TestCase.php index 7949f70..e630408 100644 --- a/tests/src/TestCase.php +++ b/tests/src/TestCase.php @@ -154,7 +154,7 @@ protected function factoryLocator(...$objects): Util\Locator * @param array|null $extra * @return Util\Paths */ - protected function factoryPaths(array $extra = null): Util\Paths + protected function factoryPaths(?array $extra = null): Util\Paths { $root = $this->fixturesPath() . '/paths-root'; diff --git a/tests/unit/Util/RequirementsTest.php b/tests/unit/Util/RequirementsTest.php index 7e66109..17487de 100644 --- a/tests/unit/Util/RequirementsTest.php +++ b/tests/unit/Util/RequirementsTest.php @@ -175,7 +175,7 @@ public function testConfigsLoadedFromDefaultFileAreMerged() * @param string $customRoot * @return mixed */ - private function executeExtractConfig(array $extra, string $customRoot = null): array + private function executeExtractConfig(array $extra, ?string $customRoot = null): array { $tester = \Closure::bind( function (string $rootPath) use ($extra): array {