Closed weierophinney closed 3 years ago
@laminas/technical-steering-committee Here's a simpler patch for 8.1 support that should make the transition far easier.
:ship:
Thanks for the stellar work, @matbech @weierophinney.
Thanks for the tip on the annotation, @nikic: it turned indeed out to be a simple missing import that was messing with us!
Thanks for the tip on the annotation, @nikic: it turned indeed out to be a simple missing import that was messing with us!
You're not the first one falling into that particular trap... I wonder whether our deprecation message should suggest #[\ReturnTypeWillChange]
instead of #[ReturnTypeWillChange]
? That's not the preferred style for most people, but at least it's always valid to use in that form.
@nikic That would have definitely resolved it for me - it's easy to forget that attributes are resolved via the current namespace, and the fact that I continued to get the deprecation errors even after adding it made me assume it just didn't work. Having the message include the scoping operator makes it clear it's a globally resolved name; I would have had immediate success AND would have likely gone and added the import statement immediately anyways.
I've opened https://github.com/php/php-src/pull/7454 to adjust the deprecation message.
This patch builds on #34, but uses a different direction for providing full compatibility with PHP 8.1.
Instead of using polyfills, we can use the
#[ReturnValueWillChange]
attribute on signatures that extend/implement internal class/interface methods (along with importing theReturnValueWillChange
virtual attribute). Recent updates to phpcs allow this to work, and Psalm discovers the annotation and considers it when determining if a signature change poses a compatibility problem.Additionally, this patch:
__unserialize()
/__serialize()
methods from theunserialize()
/serialize()
methodsFixes #24