bucket
bucket copied to clipboard
PHP 5.3 Namespace compability
Just wondering if there is some plan on making it compatible with PHP 5.3 namespaces?
There are some issues with relative vs absolute scope (which can be overcome) but the main issue is with the factory calls (cant make a new_\My\Name\Space\Class function). Without a proper rewrite there are two quick ways to resolve this:
- Translate the namespace separator to something else - in this case '_':
function create($classname) {
$classname = $this->scope->getImplementation($classname);
$funcname=strtr($classname,'\\','_');
if (isset($this->factory->{'new_' . strtolower($funcname)})) {
return call_user_func($this->factory->{'new_'.$funcname}, $this);
}
if (method_exists($this->factory, 'new_' . $funcname)) {
return $this->factory->{'new_'.$funcname}($this);
}
return $this->createThroughReflection($classname);
}
- Instead of checking for the existence of the 'new_
' function call it and require the factory to have a __call catchall method that either handles the classname conversion or returns false.
@jaanush There are no imminent plans. However, if you are still using bucket, you can create a pull request with tests, then will happily merge it in.