mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 08:10:07 +01:00
Apply suggestions from code review
This commit is contained in:
committed by
GitHub
parent
ca2924daca
commit
faeee5eb9a
@@ -326,7 +326,8 @@ public function whichPhp($phpVersion = null, $skipCache = false)
|
||||
}
|
||||
}
|
||||
|
||||
// Create a symlink to the Valet PHP version, so next time valet won't have to look for the executable path
|
||||
// If the symlinked Valet PHP path doesn't exist, then we need to look for the correct executable path
|
||||
// Create a symlink to the Valet PHP version, so next time Valet won't have to look for the executable path
|
||||
if ($phpExecutablePath = $this->getPhpExecutablePath($phpVersion)) {
|
||||
$this->files->symlinkAsUser($phpExecutablePath, $symlinkedValetPhpPath);
|
||||
}
|
||||
@@ -346,7 +347,6 @@ public function getPhpExecutablePath($phpVersion)
|
||||
{
|
||||
$phpExecutablePath = null;
|
||||
|
||||
// If the symlinked Valet PHP path doesn't exist, then we need to look for the correct executable path
|
||||
$cellar = $this->cli->runAsUser("brew --cellar $phpVersion"); // Example output: `/opt/homebrew/Cellar/php@8.0`
|
||||
$details = json_decode($this->cli->runAsUser("brew info --json $phpVersion"), true);
|
||||
$phpDirectory = data_get($details, '0.linked_keg');
|
||||
|
||||
@@ -562,7 +562,7 @@
|
||||
})->descriptions('List all sites using isolated versions of PHP.');
|
||||
|
||||
/**
|
||||
* Get PHP Executable
|
||||
* Get the PHP executable path for a site
|
||||
*/
|
||||
$app->command('which-php [site] [--skip-cache]', function ($site, $skipCache) {
|
||||
$host = Site::host($site ?: getcwd()).'.'.Configuration::read()['tld'];
|
||||
|
||||
@@ -397,7 +397,7 @@ public function test_restart_linked_php_will_pass_through_linked_php_formula_to_
|
||||
|
||||
public function test_it_can_get_php_binary_path_from_php_version_and_create_symlink()
|
||||
{
|
||||
// Scenario when there is no symlinked Valet PHP exists
|
||||
// When there is no symlinked Valet PHP exists
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -409,7 +409,7 @@ public function test_it_can_get_php_binary_path_from_php_version_and_create_syml
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@7.4/7.4.6/bin/php", $brewMock->whichPhp('php@7.4'));
|
||||
|
||||
// Scenario when there is a symlinked Valet PHP exists
|
||||
// When there is a symlinked Valet PHP exists
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -434,7 +434,7 @@ public function test_it_can_get_php_binary_path_from_php_version_and_create_syml
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@7.4/7.4.6/bin/php", $brewMock->whichPhp('php@7.4', true));
|
||||
|
||||
// Scenario when no PHP Version is proivided
|
||||
// When no PHP Version is provided
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
Mockery::mock(CommandLine::class),
|
||||
Mockery::mock(Filesystem::class)
|
||||
@@ -445,7 +445,7 @@ public function test_it_can_get_php_binary_path_from_php_version_and_create_syml
|
||||
|
||||
public function test_it_can_get_php_binary_path_from_php_version()
|
||||
{
|
||||
// Scenario when brew info has `linked_keg`
|
||||
// When brew info has `linked_keg` paramert
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
$cli = Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -457,7 +457,7 @@ public function test_it_can_get_php_binary_path_from_php_version()
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@7.4/7.4.6/bin/php", $brewMock->getPhpExecutablePath('php@7.4'));
|
||||
|
||||
// Scenario when brew info doesn't have `linked_keg`
|
||||
// When brew info doesn't have `linked_keg`
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
$cli = Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -469,7 +469,7 @@ public function test_it_can_get_php_binary_path_from_php_version()
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@8.0/8.0.5/bin/php", $brewMock->getPhpExecutablePath('php@8.0'));
|
||||
|
||||
// Scenario when brew info has a version with that was not installed_as_dependency
|
||||
// When brew info has a version that was manually installed
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
$cli = Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -482,7 +482,7 @@ public function test_it_can_get_php_binary_path_from_php_version()
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@8.1/8.1.2/bin/php", $brewMock->getPhpExecutablePath('php@8.1'));
|
||||
|
||||
// Scenario when brew info has no version that was installed manually, it should pick the last PHP version
|
||||
// When brew info has no version that was installed manually, it should pick the last PHP version
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
$cli = Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
@@ -495,7 +495,7 @@ public function test_it_can_get_php_binary_path_from_php_version()
|
||||
|
||||
$this->assertEquals(BREW_PREFIX."/Cellar/php@7.4/7.4.3/bin/php", $brewMock->getPhpExecutablePath('php@7.4'));
|
||||
|
||||
// Scenario when user has installed directly though shivammathur/homebrew-php
|
||||
// When user has installed directly though `shivammathur/homebrew-php`
|
||||
$brewMock = Mockery::mock(Brew::class, [
|
||||
$cli = Mockery::mock(CommandLine::class),
|
||||
$files = Mockery::mock(Filesystem::class)
|
||||
|
||||
Reference in New Issue
Block a user