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 attribute resolver on promoted properties #337

Merged
merged 4 commits into from
Jul 19, 2024

Conversation

jlabedo
Copy link
Contributor

@jlabedo jlabedo commented Jul 17, 2024

Description

Allow attributes targeting parameters to be used on php>8 promoted properties

Fixes #336

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@jlabedo jlabedo requested a review from dgafka July 17, 2024 21:40
try {
$carry[] = $attribute->newInstance();
} catch (Error) {
// Do nothing: it is an attribute targeting a parameter promoted to a property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's assumption that this is the error :). We may be swallowing others errors too.
If we can't check by exception type, can we do an message type check e.g. string contains cannot target property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

} catch (Error $e) {
if (\preg_match("/Attribute \"(.*)\" cannot target property/", $e->getMessage())) {
// Do nothing: it is an attribute targeting a parameter promoted to a property
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also apply this to TypeResolver#86? It's other way around there and we ignore all exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, you found it ! I knew it was done elsewhere.

@jlabedo jlabedo requested a review from dgafka July 18, 2024 11:40
@jlabedo jlabedo merged commit 8da76ae into ecotoneframework:main Jul 19, 2024
19 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.

Attribute used in an CPP property is disallowed in attribute resolving callstack of command handlers
2 participants