Skip to content

Commit 9e6703a

Browse files
authored
Fix TypeError in PHP8
PHP8 throws a `TypeError` when we pass an array to `preg_match`, suppression with `@` doesn't work in this scenario. Since `preg_match()` would never return a truthy value if not passed a string this change shouldn't impact any other cases or PHP versions.
1 parent b7406c7 commit 9e6703a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Codeception/Lib/InnerBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ static function (Crawler $node) use ($attr, $val) {
14301430

14311431
public function grabTextFrom($cssOrXPathOrRegex)
14321432
{
1433-
if (@preg_match($cssOrXPathOrRegex, $this->client->getInternalResponse()->getContent(), $matches)) {
1433+
if (is_string($cssOrXPathOrRegex) && @preg_match($cssOrXPathOrRegex, $this->client->getInternalResponse()->getContent(), $matches)) {
14341434
return $matches[1];
14351435
}
14361436
$nodes = $this->match($cssOrXPathOrRegex);

0 commit comments

Comments
 (0)