From 0cce3b99160d1e7638bcb24370da9b3ba3f8a8c4 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 11 Nov 2015 13:34:02 +0100 Subject: [PATCH] Strict: added support for the old way of adding extension methods [Closes #195] --- src/Dibi/Strict.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Dibi/Strict.php b/src/Dibi/Strict.php index a0cef54c..a93e32c9 100644 --- a/src/Dibi/Strict.php +++ b/src/Dibi/Strict.php @@ -116,6 +116,19 @@ trait Strict list($class, $name) = explode('::', $name); $class = (new ReflectionClass($class))->getName(); } + + if (self::$extMethods === NULL) { // for backwards compatibility + $list = get_defined_functions(); + foreach ($list['user'] as $fce) { + $pair = explode('_prototype_', $fce); + if (count($pair) === 2) { + trigger_error("Extension method defined as $fce() is deprecated, use $class::extensionMethod('$name', ...).", E_USER_DEPRECATED); + self::$extMethods[$pair[1]][(new ReflectionClass($pair[0]))->getName()] = $fce; + self::$extMethods[$pair[1]][''] = NULL; + } + } + } + $list = & self::$extMethods[strtolower($name)]; if ($callback === NULL) { // getter $cache = & $list[''][$class];