Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 5.3 Namespace compability #5

Open
jaanush opened this issue Feb 11, 2010 · 1 comment
Open

PHP 5.3 Namespace compability #5

jaanush opened this issue Feb 11, 2010 · 1 comment

Comments

@jaanush
Copy link

jaanush commented Feb 11, 2010

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:

  1. 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);
}
  1. 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.
@lsolesen
Copy link
Collaborator

lsolesen commented Apr 4, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants