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

Update phpRc reader to check cwd before checking config, if cwd specified

This commit is contained in:
Matt Stauffer
2023-02-07 18:40:18 -05:00
parent c3a2b0be24
commit 73b5e987e2
3 changed files with 21 additions and 6 deletions

View File

@@ -1178,16 +1178,27 @@ public function replaceSockFile($siteConf, $phpVersion)
* Get PHP version from .valetphprc for a site.
*
* @param string $site
* @param string $cwd In contexts in which a current working directory has been passed,
* the cwd, which is prioritized over looking for the site's information
* from the config.
* @return string|null
*/
public function phpRcVersion($site)
public function phpRcVersion($site, $cwd = null)
{
if ($cwd) {
$path = $cwd.'/.valetphprc';
}
if ($site = $this->parked()->merge($this->links())->where('site', $site)->first()) {
$path = data_get($site, 'path').'/.valetphprc';
}
if ($this->files->exists($path)) {
return PhpFpm::normalizePhpVersion(trim($this->files->get($path)));
}
if (! isset($path)) {
return;
}
if ($this->files->exists($path)) {
return PhpFpm::normalizePhpVersion(trim($this->files->get($path)));
}
}
}