diff --git a/src/Traits/Getter.php b/src/Traits/Getter.php index ca65baf..3aa4161 100644 --- a/src/Traits/Getter.php +++ b/src/Traits/Getter.php @@ -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 . '".'); } } diff --git a/src/Traits/Setter.php b/src/Traits/Setter.php index 3da6171..1bd8652 100644 --- a/src/Traits/Setter.php +++ b/src/Traits/Setter.php @@ -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 . '".'); } } diff --git a/src/Traits/Singleton.php b/src/Traits/Singleton.php index 0c4a6b9..593222c 100644 --- a/src/Traits/Singleton.php +++ b/src/Traits/Singleton.php @@ -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; } /**