Skip to content

PHP 8 compatibility #701

@ondrejmirtes

Description

@ondrejmirtes

I already did most of these steps in my fork because I want PHPStan to be ready for PHP 8 on day one or sonner.

This is what needs to be done in BetterReflection in order to fully support PHP 8:

  • Adapter signatures compatibility (ondrejmirtes@0acd452)
  • mixed type (ondrejmirtes@fabd259)
  • static type (ondrejmirtes@e6f9b72)
  • Reflecting union types (ondrejmirtes@ce858eb - this commit needs to be broken up because it mixes more things)
  • ReflectionType::__toString breaking change in PHP 8 - nullable type includes ? again (https://3v4l.org/CmTA1)
  • ReflectionSourceStubber misses to generate return types (ondrejmirtes@6a87721)
  • isBuiltin() is supposed to be only on ReflectionNamedType in PHP 8 (ondrejmirtes@86c5ce7)
  • Stringable (ondrejmirtes@e9f99da)
  • PhpStormStubsSourceStubberTest will fail a lot when building on PHP 8 because a lot of stuff changed between PHP 8 and PHP 7
  • Promoted properties in constructor - I plan to solve this by making ReflectionProperty an interface with two implementations - one based on Property node, the other based on Param node.
  • Only __construct methods can be considered constructors
  • Support for reading Attributes
  • Constant of value null as a default parameter value no longer makes the parameter type nullable

The Stringable commit and the obsoleted old-style constructors require an if based on the PHP version. I did that with a public static property on BetterReflection but a different way can be fine too.

Some of these items require a new major version, but some of them can be done in a minor version before that.

I'm creating this issue because I plan to send PRs for these (in case someone isn't faster than me) but I'd like to hear your opinions first :)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions