1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

StyleCI Patch

This commit is contained in:
NasirNobin
2022-03-24 05:17:13 +06:00
parent 6d3d191f44
commit 23aebbe1d9
2 changed files with 14 additions and 16 deletions

View File

@@ -304,18 +304,18 @@ public function getPhpExecutablePath($phpVersion = null)
} }
// Check the `/opt/homebrew/opt/php71/bin/php` location for older installations // Check the `/opt/homebrew/opt/php71/bin/php` location for older installations
$phpVersion = str_replace(['@', '.'], '' , $phpVersion); // php@8.1 to php81 $phpVersion = str_replace(['@', '.'], '', $phpVersion); // php@8.1 to php81
if ($this->files->exists(BREW_PREFIX."/opt/{$phpVersion}/bin/php")) { if ($this->files->exists(BREW_PREFIX."/opt/{$phpVersion}/bin/php")) {
return BREW_PREFIX."/opt/{$phpVersion}/bin/php"; return BREW_PREFIX."/opt/{$phpVersion}/bin/php";
} }
// Check if the default PHP is the version we are looking for // Check if the default PHP is the version we are looking for
if ($this->files->isLink(BREW_PREFIX."/opt/php")) { if ($this->files->isLink(BREW_PREFIX.'/opt/php')) {
$resolvedPath = $this->files->readLink(BREW_PREFIX."/opt/php"); $resolvedPath = $this->files->readLink(BREW_PREFIX.'/opt/php');
$matches = $this->parsePhpPath($resolvedPath); $matches = $this->parsePhpPath($resolvedPath);
$resolvedPhpVersion = $matches[3] ?: $matches[2]; $resolvedPhpVersion = $matches[3] ?: $matches[2];
if ($this->isPhpVersionsEqual($resolvedPhpVersion, $phpVersion)) { if ($this->isPhpVersionsEqual($resolvedPhpVersion, $phpVersion)) {
return BREW_PREFIX."/opt/php/bin/php"; return BREW_PREFIX.'/opt/php/bin/php';
} }
} }
@@ -489,10 +489,9 @@ function ($exitCode, $errorOutput) {
} }
/** /**
* Parse homebrew PHP Path * Parse homebrew PHP Path.
* *
* @param string $resolvedPath * @param string $resolvedPath
*
* @return mixed * @return mixed
*/ */
public function parsePhpPath($resolvedPath) public function parsePhpPath($resolvedPath)
@@ -510,11 +509,10 @@ public function parsePhpPath($resolvedPath)
} }
/** /**
* Check if two PHP versions are equal * Check if two PHP versions are equal.
*
* @param string $resolvedPhpVersion
* @param string $version
* *
* @param string $resolvedPhpVersion
* @param string $version
* @return bool * @return bool
*/ */
public function isPhpVersionsEqual($resolvedPhpVersion, $version) public function isPhpVersionsEqual($resolvedPhpVersion, $version)

View File

@@ -425,9 +425,9 @@ public function test_it_can_get_php_binary_path_from_php_version()
$files->shouldReceive('exists')->once()->with(BREW_PREFIX.'/opt/php@7.4/bin/php')->andReturn(false); $files->shouldReceive('exists')->once()->with(BREW_PREFIX.'/opt/php@7.4/bin/php')->andReturn(false);
$files->shouldReceive('exists')->with(BREW_PREFIX.'/opt/php74/bin/php')->andReturn(false); $files->shouldReceive('exists')->with(BREW_PREFIX.'/opt/php74/bin/php')->andReturn(false);
$files->shouldReceive('isLink')->with(BREW_PREFIX."/opt/php")->andReturn(true); $files->shouldReceive('isLink')->with(BREW_PREFIX.'/opt/php')->andReturn(true);
$files->shouldReceive('readLink')->with(BREW_PREFIX."/opt/php")->andReturn('../Cellar/php@7.4/7.4.13/bin/php'); $files->shouldReceive('readLink')->with(BREW_PREFIX.'/opt/php')->andReturn('../Cellar/php@7.4/7.4.13/bin/php');
$this->assertEquals(BREW_PREFIX."/opt/php/bin/php", $brewMock->getPhpExecutablePath('php@7.4')); $this->assertEquals(BREW_PREFIX.'/opt/php/bin/php', $brewMock->getPhpExecutablePath('php@7.4'));
// When the default PHP is not the version we are looking for // When the default PHP is not the version we are looking for
$brewMock = Mockery::mock(Brew::class, [ $brewMock = Mockery::mock(Brew::class, [
@@ -437,9 +437,9 @@ public function test_it_can_get_php_binary_path_from_php_version()
$files->shouldReceive('exists')->once()->with(BREW_PREFIX.'/opt/php@7.4/bin/php')->andReturn(false); $files->shouldReceive('exists')->once()->with(BREW_PREFIX.'/opt/php@7.4/bin/php')->andReturn(false);
$files->shouldReceive('exists')->with(BREW_PREFIX.'/opt/php74/bin/php')->andReturn(false); $files->shouldReceive('exists')->with(BREW_PREFIX.'/opt/php74/bin/php')->andReturn(false);
$files->shouldReceive('isLink')->with(BREW_PREFIX."/opt/php")->andReturn(true); $files->shouldReceive('isLink')->with(BREW_PREFIX.'/opt/php')->andReturn(true);
$files->shouldReceive('readLink')->with(BREW_PREFIX."/opt/php")->andReturn('../Cellar/php@8.1/8.1.13/bin/php'); $files->shouldReceive('readLink')->with(BREW_PREFIX.'/opt/php')->andReturn('../Cellar/php@8.1/8.1.13/bin/php');
$this->assertEquals(BREW_PREFIX."/bin/php", $brewMock->getPhpExecutablePath('php@7.4')); // Could not find a version, so retuned the default binary $this->assertEquals(BREW_PREFIX.'/bin/php', $brewMock->getPhpExecutablePath('php@7.4')); // Could not find a version, so retuned the default binary
// When no PHP Version is provided // When no PHP Version is provided
$brewMock = Mockery::mock(Brew::class, [ $brewMock = Mockery::mock(Brew::class, [