Skip to content

Commit

Permalink
Update to phpstan/phpdoc-parser 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 15, 2024
1 parent c72b104 commit d1ca607
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions SlevomatCodingStandard/Helpers/PhpDocParserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPStan\PhpDocParser\Parser\ConstExprParser;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;
use PHPStan\PhpDocParser\Printer\Printer;

/**
Expand All @@ -22,7 +23,7 @@ public static function getLexer(): Lexer
static $lexer;

if ($lexer === null) {
$lexer = new Lexer(true);
$lexer = new Lexer(self::getConfig());
}

return $lexer;
Expand All @@ -33,17 +34,12 @@ public static function getParser(): PhpDocParser
static $parser;

if ($parser === null) {
$usedAttributes = ['lines' => true, 'indexes' => true];

$constantExpressionParser = new ConstExprParser(true, true, $usedAttributes);
$config = self::getConfig();
$constantExpressionParser = new ConstExprParser($config);
$parser = new PhpDocParser(
new TypeParser($constantExpressionParser, true, $usedAttributes),
$constantExpressionParser,
true,
true,
$usedAttributes,
true,
true
$config,
new TypeParser($config, $constantExpressionParser),
$constantExpressionParser
);
}

Expand Down Expand Up @@ -79,4 +75,15 @@ public static function cloneNode(Node $node): Node
return $cloneNode;
}

private static function getConfig(): ParserConfig
{
static $config;

if ($config === null) {
$config = new ParserConfig(['lines' => true, 'indexes' => true]);
}

return $config;
}

}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^7.2 || ^8.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
"phpstan/phpdoc-parser": "^1.23.1",
"phpstan/phpdoc-parser": "^2.0",
"squizlabs/php_codesniffer": "^3.9.0"
},
"require-dev": {
Expand Down

0 comments on commit d1ca607

Please sign in to comment.