From 69a2acb1922dcf0d18f0da91079b9bc01870c6b3 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Mon, 6 Jul 2026 20:00:40 +0100 Subject: [PATCH] Freeze trim characters ahead of PHP 8.6 --- CHANGELOG.md | 5 +++++ src/AutoDiscover.php | 2 +- src/Browser/BrowserProcess.php | 8 ++++---- src/Input/KeyboardKeys.php | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb9b3226..db4d7c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # CHANGELOG +## 1.16.1 (Unreleased) + +* Pass explicit trim characters ahead of the PHP 8.6 trim default change + + ## 1.16.0 (2026-07-06) * Promote the returned `PageUtils` helper classes to the public API diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 6a046e92..f4f90704 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -42,7 +42,7 @@ public function guessChromeBinaryPath(): string case 'Windows': return self::getFromRegistry() ?? '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe'; default: - return \rtrim(\explode("\n", (string) self::shellExec('command -v google-chrome || command -v chromium-browser || command -v chrome || command -v chromium'), 2)[0]) ?: 'chrome'; + return \rtrim(\explode("\n", (string) self::shellExec('command -v google-chrome || command -v chromium-browser || command -v chrome || command -v chromium'), 2)[0], " \n\r\t\0\x0B") ?: 'chrome'; } } diff --git a/src/Browser/BrowserProcess.php b/src/Browser/BrowserProcess.php index 6ece66da..b4489366 100644 --- a/src/Browser/BrowserProcess.php +++ b/src/Browser/BrowserProcess.php @@ -434,7 +434,7 @@ private function waitForStartup(Process $process, int $timeout) // exception $message = 'Chrome process stopped before startup completed.'; - $error = \trim($process->getErrorOutput()); + $error = \trim($process->getErrorOutput(), " \n\r\t\0\x0B"); if (!empty($error)) { $message .= ' Additional info: '.$error; } @@ -442,7 +442,7 @@ private function waitForStartup(Process $process, int $timeout) throw new RuntimeException($message); } - $output = \trim($process->getIncrementalErrorOutput()); + $output = \trim($process->getIncrementalErrorOutput(), " \n\r\t\0\x0B"); if ($output) { // log @@ -451,7 +451,7 @@ private function waitForStartup(Process $process, int $timeout) $outputs = \explode(\PHP_EOL, $output); foreach ($outputs as $output) { - $output = \trim($output); + $output = \trim($output, " \n\r\t\0\x0B"); // ignore empty line if (empty($output)) { @@ -470,7 +470,7 @@ private function waitForStartup(Process $process, int $timeout) throw new RuntimeException('Devtools could not start'); } // log - $this->logger->debug('process: ignoring output:'.\trim($output)); + $this->logger->debug('process: ignoring output:'.\trim($output, " \n\r\t\0\x0B")); } } diff --git a/src/Input/KeyboardKeys.php b/src/Input/KeyboardKeys.php index 331296b1..cf2ca7cc 100644 --- a/src/Input/KeyboardKeys.php +++ b/src/Input/KeyboardKeys.php @@ -218,6 +218,6 @@ public function getPressedKeys(): array */ protected function setCurrentKey(string $key): void { - $this->currentKey = \ucfirst(\trim($key)); + $this->currentKey = \ucfirst(\trim($key, " \n\r\t\0\x0B")); } }