Skip to content

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