1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

Strict: added support for the old way of adding extension methods [Closes #195]

This commit is contained in:
David Grudl
2015-11-11 13:34:02 +01:00
parent 98d1b2a519
commit 0cce3b9916

View File

@@ -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];