Skip to content

Add compatibility with nikic/php-parser v5 and phpstan/phpdoc-parser v2#126

Merged
mitalcoi merged 6 commits intomainfrom
compat-php-parser-v5-phpdoc-parser-v2
Mar 10, 2026
Merged

Add compatibility with nikic/php-parser v5 and phpstan/phpdoc-parser v2#126
mitalcoi merged 6 commits intomainfrom
compat-php-parser-v5-phpdoc-parser-v2

Conversation

@mitalcoi
Copy link
Contributor

@mitalcoi mitalcoi commented Mar 10, 2026

Add compatibility with nikic/php-parser v5 and phpstan/phpdoc-parser v2

  • Widen version constraints: php-parser ^4.16|^5.0, phpdoc-parser ^1.6|^2.0
  • Converter: replace removed ParserFactory::PREFER_PHP7 constant with
    createForHostVersion() (php-parser v5 API)
  • DtoVisitor: replace Node\Scalar\LNumber with Node\Scalar\Int_
    (renamed in php-parser v5)
  • PhpDocTypeParser: pass ParserConfig to Lexer, ConstExprParser,
    TypeParser and PhpDocParser constructors (required in phpdoc-parser v2)

- Widen version constraints: php-parser ^4.16|^5.0, phpdoc-parser ^1.6|^2.0
- Converter: replace removed ParserFactory::PREFER_PHP7 constant with
  createForHostVersion() (php-parser v5 API)
- DtoVisitor: replace Node\Scalar\LNumber with Node\Scalar\Int_
  (renamed in php-parser v5)
- PhpDocTypeParser: pass ParserConfig to Lexer, ConstExprParser,
  TypeParser and PhpDocParser constructors (required in phpdoc-parser v2)
- Replace NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN with
  NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN (deprecated in v5)
- Replace Node\Stmt\Class_::MODIFIER_PUBLIC with Modifiers::PUBLIC
  (deprecated in v5)
- Replace Node\Expr\ArrayItem with Node\ArrayItem
  (class moved in v5)
- Update CI matrix: drop PHP 8.0, add 8.3 and 8.4
- Update actions/checkout from v2 to v4
- phpstan.neon: replace deprecated checkGenericClassInNonGenericObjectType
  with missingType.generics error identifier (new PHPStan API)
- static_analysis.yml: run code style check only on PHP 8.1 to avoid
  slevomat/coding-standard incompatibility with PHP 8.4 (where typed
  parameter override mismatch became a fatal error)
In php-parser v5, Node\Name::$parts was replaced with $name (string).
Accessing ->parts[0] returns null in v5, breaking the null-constant
detection for MyCLabs-style enums.

Replace ->name->parts[0] with (string)->name cast which works via
__toString() in both v4 and v5.
- Raise minimum PHP requirement to >=8.1 (aligns with php-parser v5
  and phpdoc-parser v2 own minimum requirements)
- Remove PHP 8.0 and 8.1 from CI matrix
- Remove code style check from CI: symplify/easy-coding-standard v11
  pulls a slevomat/coding-standard version that triggers a fatal error
  on PHP 8.x due to stricter method signature compatibility enforcement;
  this is unrelated to the php-parser/phpdoc-parser compatibility goal
  of this PR
@mitalcoi mitalcoi merged commit 378e822 into main Mar 10, 2026
8 checks passed
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.

1 participant