xp-framework / core

The XP Framework is an all-purpose, object oriented PHP framework.
Other
19 stars 6 forks source link

Make it possible to pass a default resolver to Type::resolve() #256

Closed thekid closed 3 years ago

thekid commented 3 years ago

This resolver will be called for any unqualified names and can check import statements as well as the current namespace, e.g.

$t= Type::resolve($name, [
  'self'   => function() { return new XPClass(self::class); },
  'parent' => function() { return new XPClass(parent::class); },
  '*'      => function($type) {
    // TODO: Check imports
    return XPClass::forName(__NAMESPACE__.'\\'.$type);
  }
]);

To check for imports see xp-framework/rfc#339 - this would be done by using XPClass::detailsForClass($name)['use'].

thekid commented 3 years ago

Not quite sure the error below is coming from, the tests are green otherwise:

image

thekid commented 3 years ago

Released in https://github.com/xp-framework/core/releases/tag/v10.6.0