From e67a46e621df438317a7614b7c87c720fd740258 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 12 Jun 2023 15:56:25 +0200 Subject: [PATCH] Handle PCRE failures when attempting to trim body --- phpstan-baseline.neon | 5 ----- src/Exception/ExpectationException.php | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c54109ba9..82f05977c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,11 +10,6 @@ parameters: count: 1 path: src/Element/NodeElement.php - - - message: "#^Method Behat\\\\Mink\\\\Exception\\\\ExpectationException\\:\\:trimBody\\(\\) should return string but returns string\\|null\\.$#" - count: 1 - path: src/Exception/ExpectationException.php - - message: "#^Cannot cast array\\|bool\\|string\\|null to string\\.$#" count: 2 diff --git a/src/Exception/ExpectationException.php b/src/Exception/ExpectationException.php index 2e1179e8e..ba1b0d135 100644 --- a/src/Exception/ExpectationException.php +++ b/src/Exception/ExpectationException.php @@ -135,7 +135,7 @@ protected function pipeString($string) */ protected function trimBody($string) { - $string = preg_replace(array('/^.*/s', '/<\/body>.*$/s'), array('', ''), $string); + $string = preg_replace(array('/^.*/s', '/<\/body>.*$/s'), array('', ''), $string) ?? $string; return $string; }