Fix for late static binding

This commit is contained in:
Sebastian Meyer 2023-10-11 13:31:51 +02:00
parent b5ddbab61f
commit 2006073f94
3 changed files with 10 additions and 10 deletions

View File

@ -43,12 +43,12 @@ trait Getter
{
$method = '_get' . ucfirst($property);
if (
property_exists(__CLASS__, $property)
&& method_exists(__CLASS__, $method)
property_exists(get_called_class(), $property)
&& method_exists(get_called_class(), $method)
) {
return $this->$method();
} else {
throw new \InvalidArgumentException('Invalid property or missing getter method for property "' . __CLASS__ . '->' . $property . '".');
throw new \InvalidArgumentException('Invalid property or missing getter method for property "' . get_called_class() . '->' . $property . '".');
}
}

View File

@ -44,12 +44,12 @@ trait Setter
{
$method = '_set' . ucfirst($property);
if (
property_exists(__CLASS__, $property)
&& method_exists(__CLASS__, $method)
property_exists(get_called_class(), $property)
&& method_exists(get_called_class(), $method)
) {
$this->$method($value);
} else {
throw new \InvalidArgumentException('Invalid property or missing setter method for property "' . __CLASS__ . '->' . $property . '".');
throw new \InvalidArgumentException('Invalid property or missing setter method for property "' . get_called_class() . '->' . $property . '".');
}
}

View File

@ -40,11 +40,11 @@ trait Singleton
*/
final public static function getInstance(): self
{
if (!isset(self::$singleton)) {
$reflectionClass = new \ReflectionClass(__CLASS__);
self::$instance = $reflectionClass->newInstanceArgs(func_get_args());
if (!isset(static::$singleton)) {
$reflectionClass = new \ReflectionClass(get_called_class());
static::$singleton = $reflectionClass->newInstanceArgs(func_get_args());
}
return self::$singleton;
return static::$singleton;
}
/**