Skip to content

Commit

Permalink
Handle PCRE failures when attempting to trim body
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Jun 12, 2023
1 parent d57832a commit e67a46e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ExpectationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function pipeString($string)
*/
protected function trimBody($string)
{
$string = preg_replace(array('/^.*<body>/s', '/<\/body>.*$/s'), array('<body>', '</body>'), $string);
$string = preg_replace(array('/^.*<body>/s', '/<\/body>.*$/s'), array('<body>', '</body>'), $string) ?? $string;

return $string;
}
Expand Down

0 comments on commit e67a46e

Please sign in to comment.