Skip to content

Commit

Permalink
PHP 8+ fix for Model::isBuilderMethod()
Browse files Browse the repository at this point in the history
  • Loading branch information
robgridley committed Sep 19, 2022
1 parent d14d3e7 commit 1727959
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use ArrayAccess;
use JsonSerializable;
use Pace\XPath\Builder;
use Pace\Model\Attachments;
use Pace\XPath\Builder;
use ReflectionMethod;
use UnexpectedValueException;

class Model implements ArrayAccess, JsonSerializable
Expand Down Expand Up @@ -633,7 +634,16 @@ protected function guessPrimaryKey()
*/
protected function isBuilderMethod($name)
{
return method_exists(Builder::class, $name) && is_callable([Builder::class, $name]);
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
if (method_exists(Builder::class, $name)) {
$reflection = new ReflectionMethod(Builder::class, $name);
return $reflection->isPublic();
} else {
return false;
}
} else {
return method_exists(Builder::class, $name) && is_callable([Builder::class, $name]);
}
}

/**
Expand Down

0 comments on commit 1727959

Please sign in to comment.