From 4c3b75c3d6e15895d9f5cbb117058e8c7d0ee998 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 24 Mar 2017 16:34:20 -0400 Subject: [PATCH] Remove static instance trait, remove codeCoverageIgnore annotations --- src/Enum.php | 13 ++++----- src/Friend.php | 1 - src/StaticInstance.php | 66 ------------------------------------------ src/View/HttpView.php | 2 -- 4 files changed, 6 insertions(+), 76 deletions(-) delete mode 100644 src/StaticInstance.php diff --git a/src/Enum.php b/src/Enum.php index 2d6e7e7..9793b78 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -26,33 +26,32 @@ use ReflectionClass; */ abstract class Enum { - use StaticInstance; - /** * Return the list of constant values for the Enum * * @return array */ - protected static function getConstList(): array + public static function getConstList(): array { static $self; - - if (is_null($self)) + + if (is_null($self)) { $class = \get_called_class(); $self = new $class; } - + $reflect = new ReflectionClass($self); return $reflect->getConstants(); } /** * Verify that a constant value is valid + * * @param mixed $key * @return boolean */ - protected static function isValid($key): bool + public static function isValid($key): bool { $values = array_values(static::getConstList()); return in_array($key, $values); diff --git a/src/Friend.php b/src/Friend.php index 2d22590..f276450 100644 --- a/src/Friend.php +++ b/src/Friend.php @@ -112,7 +112,6 @@ class Friend { /** * Iterates over parent classes to get a ReflectionProperty * - * @codeCoverageIgnore * @param string $name * @return ReflectionProperty|null */ diff --git a/src/StaticInstance.php b/src/StaticInstance.php deleted file mode 100644 index 7a84c48..0000000 --- a/src/StaticInstance.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright 2015 - 2017 Timothy J. Warren - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 2.0.0 - * @link https://git.timshomepage.net/timw4mail/ion - */ - -namespace Aviat\Ion; - -/** - * Trait to allow calling a method statically, - * as well as with an instance - */ -trait StaticInstance { - /** - * Instance for 'faking' static methods - * - * @var object - */ - private static $instance = []; - - /** - * Call protected methods to allow for - * static and instance calling - * - * @codeCoverageIgnore - * @param string $method - * @param array $args - * @return mixed - */ - public function __call(string $method, array $args) - { - $class = \get_called_class(); - if (method_exists($this, $method)) - { - return call_user_func_array([$this, $method], $args); - } - else if(method_exists($class, $method)) - { - return static::__callStatic($method, $args); - } - } - - /** - * Call non-static methods statically, so that - * an instance of the class isn't required - * - * @param string $method - * @param array $args - * @return mixed - */ - public static function __callStatic(string $method, array $args) - { - return call_user_func_array([\get_called_class(), $method], $args); - } -} -// End of StaticInstance.php \ No newline at end of file diff --git a/src/View/HttpView.php b/src/View/HttpView.php index caebfda..5735dfb 100644 --- a/src/View/HttpView.php +++ b/src/View/HttpView.php @@ -36,7 +36,6 @@ class HttpView extends BaseView { /** * Do a redirect * - * @codeCoverageIgnore * @param string $url * @param int $code * @return void @@ -86,7 +85,6 @@ class HttpView extends BaseView { /** * Send the appropriate response * - * @codeCoverageIgnore * @throws DoubleRenderException * @return void */