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

Fix for the use of built-in class names in Collection annotations #736

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

27pchrisl
Copy link
Contributor

Hi, found this when upgrading from v3 to v4.

In v3 you could do

#[DataCollectionOf(Error::class)]

which would correctly pick up a class with the right namespace, even if its basename matches a builtin like \Error.

In v4 the same syntax is:

/** @var Collection<Error> */
public Collection $errors;

But due to the order in which the DataIterableAnnotationReader determines the correct class, it discovers \Error before App\Stuff\Error or similar.

This PR reorders the resolution code so that it finds properly qualified classes before builtins.

@27pchrisl 27pchrisl force-pushed the root-namespace-names branch from 06f4793 to bae4ab6 Compare April 4, 2024 13:09
@27pchrisl
Copy link
Contributor Author

Note this branch needs rebasing when tests pass again on main

@rubenvanassche
Copy link
Member

Looking great, thanks!

@rubenvanassche rubenvanassche merged commit 20aa4aa into spatie:main Apr 4, 2024
11 of 12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants