Skip to content

Fix unserialize throw type for userland hooks - #6624

Open
hamza-topo wants to merge 2 commits into
phpstan:2.3.xfrom
hamza-topo:fix/unserialize-throw-type-15329
Open

hamza-topo wants to merge 2 commits into
phpstan:2.3.xfrom
hamza-topo:fix/unserialize-throw-type-15329

Conversation

@hamza-topo

Copy link
Copy Markdown

Fixes phpstan/phpstan#15329

unserialize() can propagate exceptions thrown from userland __wakeup() and __unserialize() methods.

This updates UnserializeFunctionThrowTypeExtension to account for these throwables when implicit throws are enabled, while preserving the existing precision for cases where no classes are allowed to be instantiated.

Added regression coverage for both __wakeup() and __unserialize(), including the implicitThrows: false behaviour.

Tests:

  • CatchWithUnthrownExceptionRuleTest
  • AbilityToDisableImplicitThrowsTest
  • PHP 7.4 behaviour simulated with phpVersion: 70400
  • make phpstan
  • PHP CodeSniffer

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.

dead catch reported in unserialize()

1 participant