Skip to content

Commit

Permalink
Add compatibility with phpstan/phpdoc-parser v2 (#442)
Browse files Browse the repository at this point in the history
* Add compatibility with phpstan/phpdoc-parser v2
* Drop support for phpdoc-parser v1

---------

Co-authored-by: Emil Masiakowski <[email protected]>
  • Loading branch information
EmilMassey and Emil Masiakowski authored Feb 18, 2025
1 parent 483b878 commit 766b5e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"nikic/php-parser": "~5",
"webmozart/assert": "^1.9",
"ext-json": "*",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpdoc-parser": "^2.0",
"ondram/ci-detector": "^4.1"
},
"require-dev": {
Expand Down
10 changes: 6 additions & 4 deletions src/Analyzer/NameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;

class NameResolver extends NodeVisitorAbstract
{
Expand Down Expand Up @@ -65,10 +66,11 @@ public function __construct(?ErrorHandler $errorHandler = null, array $options =
$this->replaceNodes = $options['replaceNodes'] ?? true;
$this->parseCustomAnnotations = $options['parseCustomAnnotations'] ?? true;

$typeParser = new TypeParser();
$constExprParser = new ConstExprParser();
$this->phpDocParser = new PhpDocParser($typeParser, $constExprParser);
$this->phpDocLexer = new Lexer();
$parserConfig = new ParserConfig([]);
$constExprParser = new ConstExprParser($parserConfig);
$typeParser = new TypeParser($parserConfig, $constExprParser);
$this->phpDocParser = new PhpDocParser($parserConfig, $typeParser, $constExprParser);
$this->phpDocLexer = new Lexer($parserConfig);
}

/**
Expand Down

0 comments on commit 766b5e2

Please sign in to comment.