Skip to content

Commit 364b564

Browse files
committed
Catch type error thrown for PHP versions above 8
1 parent 6ace3d5 commit 364b564

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Parser/ValueData.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public function call($func, $args) {
5252
}
5353

5454
public function methodExists($name) {
55-
return method_exists($this->data, $name);
55+
// PHP 8+ will throw a type error if not an object or string
56+
try {
57+
return method_exists($this->data, $name);
58+
} catch (\TypeError $e) {
59+
return false;
60+
}
5661
}
5762

5863
public function parseNested($parser, $token, $funcName) {

0 commit comments

Comments
 (0)