Skip to content

Commit 8d34524

Browse files
committed
Changed code to be PSR-12 compliant and added better handling for when the PHP version is already set to the same as the .valetrc file
1 parent 3b2967f commit 8d34524

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cli/valet.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,17 @@
495495
*/
496496
$app->command('use [phpVersion] [--force]', function ($phpVersion, $force) {
497497
if (!$phpVersion) {
498-
if (file_exists($path = getcwd() . '/.valetrc')) {
499-
if ($phpVersion = trim(file_get_contents($path))) {
500-
info('Found \'' . $path . '/.valetrc\' with version <' . $phpVersion . '>');
501-
} else {
502-
return info('.valetrc does not contain a valid PHP version' . $phpVersion);
503-
}
504-
} else {
505-
return info('Valet is using ' . Brew::linkedPhp());
498+
$path = getcwd() . '/.valetrc';
499+
$linkedVersion = Brew::linkedPhp();
500+
if (!file_exists($path)) {
501+
return info(sprintf('Valet is using %s.', $linkedVersion));
502+
}
503+
504+
$phpVersion = trim(file_get_contents($path));
505+
info('Found \'' . $path . '\' with version: ' . $phpVersion);
506+
507+
if ($linkedVersion == $phpVersion) {
508+
return info(sprintf('Valet is already using %s.', $linkedVersion));
506509
}
507510
}
508511

0 commit comments

Comments
 (0)