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

implement MissingMagicSerializationMethodsRule #1711

Merged
merged 1 commit into from
Oct 16, 2022

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 8, 2022


if ($missingMagicSerialize) {
$messages[] = RuleErrorBuilder::message(sprintf(
'%s %s implements the Serializable interface, but does not implement __serialize().',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure about the error message... implementing magic serialize actually is only required in case you want to support old-phpversions in tandem.

@staabm
Copy link
Contributor Author

staabm commented Sep 8, 2022

not sure how to fix the phpstan error on 7.2

Error: Call to method getMethods() on an unknown class PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum.
 ------ --------------------------------------------------------------------- 
  Line   src/Rules/Methods/MissingMagicSerializationMethodsRule.php           
 ------ --------------------------------------------------------------------- 
  51     Call to method getMethods() on an unknown class                      
         PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum.          
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   
 ------ --------------------------------------------------------------------- 

conf/config.level0.neon Outdated Show resolved Hide resolved

try {
$nativeMethods = $classReflection->getNativeReflection()->getMethods();
} catch (IdentifierNotFound) {
Copy link
Member

Choose a reason for hiding this comment

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

When is this thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good question. I just copied it from ;)

try {
$nativeMethods = $classReflection->getNativeReflection()->getMethods();
} catch (IdentifierNotFound) {
return [];
}

Copy link
Member

Choose a reason for hiding this comment

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

Alright ,better to keep it, there's probably a reason.

src/Rules/Methods/MissingMagicSerializationMethodsRule.php Outdated Show resolved Hide resolved
src/Rules/Methods/MissingMagicSerializationMethodsRule.php Outdated Show resolved Hide resolved
@staabm staabm marked this pull request as ready for review September 8, 2022 14:11
conf/bleedingEdge.neon Outdated Show resolved Hide resolved
@staabm staabm force-pushed the serializable branch 3 times, most recently from c4981bd to 32e816b Compare September 22, 2022 10:21
@staabm
Copy link
Contributor Author

staabm commented Sep 22, 2022

except the one remaining problem mentioned in #1711 (comment) this should be good to go

@staabm staabm force-pushed the serializable branch 2 times, most recently from 33e5ea0 to 07261df Compare September 29, 2022 10:19
@staabm
Copy link
Contributor Author

staabm commented Sep 29, 2022

except the one remaining problem mentioned in #1711 (comment) this should be good to go

inspired by be1ce08 I figured, I should also add this error to the ignore list. I did so with 8680735

@staabm staabm force-pushed the serializable branch 2 times, most recently from 2206bb4 to f408e70 Compare October 5, 2022 15:46
@staabm staabm closed this Oct 5, 2022
@staabm staabm reopened this Oct 5, 2022
@staabm staabm force-pushed the serializable branch 3 times, most recently from 3102945 to 0351619 Compare October 7, 2022 20:29
@ondrejmirtes ondrejmirtes changed the base branch from 1.8.x to 1.9.x October 16, 2022 11:05
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the serializable branch October 16, 2022 11:25
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.

Issue errors when implementing deprecated Serializable interface without serialization magic methods
3 participants