Skip to content

Commit f53db7d

Browse files
authored
fix: php port replacement removes entire line in site config (#43)
Fixes #42. This pull request makes a minor update to the way the PHP port is replaced in the site configuration within the `replacePhpVersionInSiteConf` function. The change simplifies the usage of replacement variables in the `preg_replace` call, improving readability and maintainability. - Refactored the `preg_replace` replacement string in the `replacePhpVersionInSiteConf` function in `Site.php` to use string concatenation with `${1}` instead of double-quoted interpolation with `$1`, ensuring correct variable substitution and preventing entire line removal with the wrong interpretation of the backreference numbers. - Removed the limit of max replacements the `preg_replace` can do, ensuring all PHP port lines in multiple location blocks in the site configs are replaced.
2 parents bf301cd + eab4758 commit f53db7d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

cli/Valet/Site.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,8 @@ public function replacePhpVersionInSiteConf($siteConf, $phpPort, $phpVersion = n
992992
// or global variable, depending on whether the site is isolated or not.
993993
$siteConf = preg_replace(
994994
'/(^\s*set \$valet_site_php_port\s+)[^;]+(\s*;)/m',
995-
"$1{$phpPortValue}$2",
996-
$siteConf,
997-
1
995+
'${1}' . $phpPortValue . '$2',
996+
$siteConf
998997
);
999998

1000999
if ($phpVersion) {

0 commit comments

Comments
 (0)