Skip to content

Commit

Permalink
Strict: added support for the old way of adding extension methods [Cl…
Browse files Browse the repository at this point in the history
…oses #195]
  • Loading branch information
dg committed Nov 11, 2015
1 parent 98d1b2a commit 0cce3b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Dibi/Strict.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ public static function extensionMethod($name, $callback = NULL)
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];
Expand Down

0 comments on commit 0cce3b9

Please sign in to comment.