Skip to content

Conversation

@acrobat
Copy link
Contributor

@acrobat acrobat commented Aug 14, 2022

Gedmo annotations (attributes) are used by gedmo listeners to automatically write data to properties and some of the properties are only used by gedmo internally. This ReadWritePropertiesExtension solves the unused property errors for these cases.

 ------ ----------------------------------------------------------------------------------
  Line   Example.php
 ------ ----------------------------------------------------------------------------------
  22     Property App\Entity\Example::$locale is unused.
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ ----------------------------------------------------------------------------------

Fixes #231
Related to phpstan/phpstan#7758

@acrobat acrobat force-pushed the fix-gedmo-unused-properties branch 8 times, most recently from e37b23f to 5057e05 Compare August 14, 2022 09:49
@acrobat
Copy link
Contributor Author

acrobat commented Aug 14, 2022

The failing php 8.2 checks don't seem to be related to my change

@ondrejmirtes
Copy link
Member

One more idea - if the class isn't an entity, the extension should return false even if the annotations are present. Please implement this with a test.

Please use ObjectMetadataResolver::isTransient() for this.

@acrobat acrobat force-pushed the fix-gedmo-unused-properties branch 2 times, most recently from 665f80f to e725541 Compare August 15, 2022 12:39
@acrobat acrobat requested a review from ondrejmirtes August 15, 2022 12:41
@acrobat
Copy link
Contributor Author

acrobat commented Aug 15, 2022

@ondrejmirtes I've implemented the requested changes, thanks for the suggestions!

@acrobat acrobat force-pushed the fix-gedmo-unused-properties branch from e725541 to 5afea15 Compare August 15, 2022 12:52
@acrobat
Copy link
Contributor Author

acrobat commented Sep 6, 2022

@ondrejmirtes are there any other changes needed here?

@ondrejmirtes
Copy link
Member

I like this, thank you :)

@ondrejmirtes ondrejmirtes merged commit 62a3b42 into phpstan:1.3.x Sep 6, 2022
@acrobat acrobat deleted the fix-gedmo-unused-properties branch September 6, 2022 15:02
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.

[RFC] Support by default that Gedmo properties are always written

2 participants