diff --git a/src/Platform/TargetPhp/PhpBinaryPath.php b/src/Platform/TargetPhp/PhpBinaryPath.php index 9f4a5579..0025b3fa 100644 --- a/src/Platform/TargetPhp/PhpBinaryPath.php +++ b/src/Platform/TargetPhp/PhpBinaryPath.php @@ -422,12 +422,12 @@ private static function guessWithPhpConfig(self $phpBinaryPath): self private static function cleanWarningAndDeprecationsFromOutput(string $testOutput): string { // Note: xdebug can prefix `PHP ` onto warnings/deprecations, so filter them out too - return implode( + return trim(implode( "\n", array_filter( explode("\n", $testOutput), static fn (string $line) => ! preg_match('/^(Deprecated|Warning|PHP Warning|PHP Deprecated):/', $line), ), - ); + )); } } diff --git a/test/assets/valid-php-with-warnings.sh b/test/assets/valid-php-with-warnings.sh index 9289f248..37d7c4af 100755 --- a/test/assets/valid-php-with-warnings.sh +++ b/test/assets/valid-php-with-warnings.sh @@ -2,7 +2,9 @@ # These should be implicitly filtered out by PIE echo "PHP Warning: PHP Startup: Unable to load dynamic library 'redis' (tried: /path/to/redis (dlopen(/path/to/redis, 0x0009): [...] in Unknown on line 0" +echo "" # add some newlines... echo "Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /path/to/pdo_mysql (/path/to/pdo_mysql: cannot open shared object file: No such file or directory), /path/to/pdo_mysql.so (/path/to/pdo_mysql.so: undefined symbol: mysqlnd_debug_std_no_trace_funcs)) in Unknown on line 0" +echo " " # add some whitespace... echo "Deprecated: Function unsafe_function() is deprecated since 1.5, use safe_replacement() instead in example.php on line 9" echo "Deprecated: PHP Startup: session.sid_length INI setting is deprecated in Unknown on line 0" echo "PHP Deprecated: PHP Startup: session.sid_length INI setting is deprecated in Unknown on line 0"