Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Merged
merged 4 commits into from
Jan 17, 2021

Conversation

thekid
Copy link
Member

@thekid thekid commented Jan 16, 2021

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'].

This resolver will be called for any unqualified names and can
check import statements as well as the current namespace, e.g.
@thekid
Copy link
Member Author

thekid commented Jan 17, 2021

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

image

@thekid thekid merged commit df35d07 into xp-framework:master Jan 17, 2021
@thekid thekid deleted the feature/resolve_all branch January 17, 2021 16:02
@thekid
Copy link
Member Author

thekid commented Jan 18, 2021

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant