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

Add support for target class attributes #1210

Merged

Conversation

rneudorf-godaddy
Copy link
Contributor

Resolves #1209.

This PR adds support for target class attributes. The #[\AllowDynamicProperties] attribute is the most straightfoward way to resolve PHP 8.2 compatibility issue mentioned in #1209.

Details

TargetClassInterface Update

  • Added getAttributes() which returns an array of attributes
  • Updated DefinedTargetClass to return an empty array.
  • Updated UndefinedTargetClass to return \AllowDynamicProperties 👈 i.e. the fix

Added ClassAttributesPass

  • This pass inserts the attributes just before the class declaration.
  • Updated StringManipulationGenerator to use this pass.

Test Updates

  • A few test were taking dynamically declaring properties in their mocks, updated those.
  • Added a test for ClassAttributesPass

@rneudorf-godaddy rneudorf-godaddy changed the title Add support target class attributes Add support for target class attributes Jan 31, 2023
Copy link

@thestalnakergroup thestalnakergroup left a comment

Choose a reason for hiding this comment

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

I'd love to be able to use this on a project I'm working on.

@unfulvio-godaddy
Copy link

@davedevelopment @GrahamCampbell is this something that you would consider reviewing/merging? has tests

thank you

@davedevelopment
Copy link
Collaborator

Thank you for this, I've not been able to replicate those test failures yet.

@davedevelopment
Copy link
Collaborator

git pull git@github.com:rneudorf-godaddy/mockery.git 1209/add-support-for-class-attributes

Scratch that, hadn't pulled the branch down yet 🤣

@ghostwriter ghostwriter added this to the 1.5.2 milestone Apr 20, 2023
@ghostwriter ghostwriter changed the base branch from master to 1.5.x April 21, 2023 13:34
@ghostwriter
Copy link
Member

Hi,

I just wanted to apologize for the delay in reviewing your pull request.

I'm going to rebase, finalize and merge this pull request to 1.5.x branch.

Thanks for your patience and for your contribution to the project!

Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
@ghostwriter ghostwriter modified the milestones: 2.1.0, 1.6.0 Apr 21, 2023
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Copy link
Member

@ghostwriter ghostwriter left a comment

Choose a reason for hiding this comment

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

Target is 1.6.0 because we're adding new functionality in a backward-compatible manner.

@ghostwriter ghostwriter changed the base branch from 1.5.x to 1.6.x April 21, 2023 17:33
@ghostwriter ghostwriter merged commit 9eb7fad into mockery:1.6.x Apr 21, 2023
6 checks passed
@ghostwriter ghostwriter added Minor Backwards compatible changes Added for new features or functionality labels Apr 30, 2023
@rneudorf-godaddy
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added for new features or functionality Minor Backwards compatible changes
Projects
None yet
6 participants