diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 3078af7..ad2246d 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -280,7 +280,7 @@ public function linkedPhp() return $this->supportedPhpVersions()->first( function ($version) use ($resolvedPhpVersion) { - return $this->isPhpVersionsEqual($resolvedPhpVersion, $version); + return $this->arePhpVersionsEqual($resolvedPhpVersion, $version); }, function () use ($resolvedPhpVersion) { throw new DomainException("Unable to determine linked PHP when parsing '$resolvedPhpVersion'"); }); @@ -289,7 +289,7 @@ function ($version) use ($resolvedPhpVersion) { /** * Extract PHP executable path from PHP Version. * - * @param string $phpVersion + * @param string $phpVersion For example, "php@8.1" * @return string */ public function getPhpExecutablePath($phpVersion = null) @@ -314,7 +314,8 @@ public function getPhpExecutablePath($phpVersion = null) $resolvedPath = $this->files->readLink(BREW_PREFIX.'/opt/php'); $matches = $this->parsePhpPath($resolvedPath); $resolvedPhpVersion = $matches[3] ?: $matches[2]; - if ($this->isPhpVersionsEqual($resolvedPhpVersion, $phpVersion)) { + + if ($this->arePhpVersionsEqual($resolvedPhpVersion, $phpVersion)) { return BREW_PREFIX.'/opt/php/bin/php'; } } @@ -511,15 +512,15 @@ public function parsePhpPath($resolvedPath) /** * Check if two PHP versions are equal. * - * @param string $resolvedPhpVersion - * @param string $version + * @param string $versionA + * @param string $versionB * @return bool */ - public function isPhpVersionsEqual($resolvedPhpVersion, $version) + public function arePhpVersionsEqual($versionA, $version) { - $resolvedVersionNormalized = preg_replace('/[^\d]/', '', $resolvedPhpVersion); - $versionNormalized = preg_replace('/[^\d]/', '', $version); + $versionANormalized = preg_replace('/[^\d]/', '', $versionA); + $versionBNormalized = preg_replace('/[^\d]/', '', $versionB); - return $resolvedVersionNormalized === $versionNormalized; + return $versionANormalized === $versionBNormalized; } } diff --git a/cli/valet.php b/cli/valet.php index 972da2e..0edad92 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -583,7 +583,7 @@ ]); /** - * Proxy PHP commands with isolated site's PHP executable file. + * Proxy commands through to an isolated site's version of PHP. */ $app->command('php [command]', function ($command) { warning('It looks like you are running `cli/valet.php` directly; please use the `valet` script in the project root instead.'); @@ -592,7 +592,7 @@ ]); /** - * Proxy Composer commands with isolated site's PHP executable. + * Proxy commands through to an isolated site's version of Composer. */ $app->command('composer [command]', function ($command) { warning('It looks like you are running `cli/valet.php` directly; please use the `valet` script in the project root instead.'); diff --git a/tests/BrewTest.php b/tests/BrewTest.php index 56d4e94..c96f354 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -452,12 +452,12 @@ public function test_it_can_get_php_binary_path_from_php_version() public function test_it_can_compare_two_php_versions() { - $this->assertTrue(resolve(Brew::class)->isPhpVersionsEqual('php71', 'php@7.1')); - $this->assertTrue(resolve(Brew::class)->isPhpVersionsEqual('php71', 'php@71')); - $this->assertTrue(resolve(Brew::class)->isPhpVersionsEqual('php71', '71')); + $this->assertTrue(resolve(Brew::class)->arePhpVersionsEqual('php71', 'php@7.1')); + $this->assertTrue(resolve(Brew::class)->arePhpVersionsEqual('php71', 'php@71')); + $this->assertTrue(resolve(Brew::class)->arePhpVersionsEqual('php71', '71')); - $this->assertFalse(resolve(Brew::class)->isPhpVersionsEqual('php71', 'php@70')); - $this->assertFalse(resolve(Brew::class)->isPhpVersionsEqual('php71', '72')); + $this->assertFalse(resolve(Brew::class)->arePhpVersionsEqual('php71', 'php@70')); + $this->assertFalse(resolve(Brew::class)->arePhpVersionsEqual('php71', '72')); } /**