Skip to content

Commit

Permalink
support also current stable pre-2.0 phpdoc-parser
Browse files Browse the repository at this point in the history
[closes #689]
  • Loading branch information
hrach committed Oct 30, 2024
1 parent 844795b commit 60f4f14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"nette/caching": "~3.2 || ~3.1.3",
"nette/utils": "~3.0 || ~4.0",
"nextras/dbal": "dev-main",
"phpstan/phpdoc-parser": "2.0.x-dev"
"phpstan/phpdoc-parser": "^1.33.0 || 2.0.x-dev"
},
"require-dev": {
"doctrine/sql-formatter": "^1.5.1",
Expand Down
18 changes: 13 additions & 5 deletions src/Entity/Reflection/MetadataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ public function __construct(array $entityClassesMap)
$this->entityClassesMap = $entityClassesMap;
$this->modifierParser = new ModifierParser();

$config = new ParserConfig(usedAttributes: []);
$this->phpDocLexer = new Lexer($config);
$constExprParser = new ConstExprParser($config);
$typeParser = new TypeParser($config, $constExprParser);
$this->phpDocParser = new PhpDocParser($config, $typeParser, $constExprParser);
// phpdoc-parser 2.0
if (class_exists('PHPStan\PhpDocParser\ParserConfig')) {
$config = new ParserConfig(usedAttributes: []);
$this->phpDocLexer = new Lexer($config);
$constExprParser = new ConstExprParser($config);
$typeParser = new TypeParser($config, $constExprParser);
$this->phpDocParser = new PhpDocParser($config, $typeParser, $constExprParser);
} else {
$this->phpDocLexer = new Lexer();

Check failure on line 109 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Class PHPStan\PhpDocParser\Lexer\Lexer constructor invoked with 0 parameters, 1 required.

Check failure on line 109 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Class PHPStan\PhpDocParser\Lexer\Lexer constructor invoked with 0 parameters, 1 required.
$constExprParser = new ConstExprParser();

Check failure on line 110 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Class PHPStan\PhpDocParser\Parser\ConstExprParser constructor invoked with 0 parameters, 1 required.

Check failure on line 110 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Class PHPStan\PhpDocParser\Parser\ConstExprParser constructor invoked with 0 parameters, 1 required.
$typeParser = new TypeParser($constExprParser);

Check failure on line 111 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Class PHPStan\PhpDocParser\Parser\TypeParser constructor invoked with 1 parameter, 2 required.

Check failure on line 111 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Parameter #1 $config of class PHPStan\PhpDocParser\Parser\TypeParser constructor expects PHPStan\PhpDocParser\ParserConfig, PHPStan\PhpDocParser\Parser\ConstExprParser given.

Check failure on line 111 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Class PHPStan\PhpDocParser\Parser\TypeParser constructor invoked with 1 parameter, 2 required.

Check failure on line 111 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Parameter #1 $config of class PHPStan\PhpDocParser\Parser\TypeParser constructor expects PHPStan\PhpDocParser\ParserConfig, PHPStan\PhpDocParser\Parser\ConstExprParser given.
$this->phpDocParser = new PhpDocParser($typeParser, $constExprParser);

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Class PHPStan\PhpDocParser\Parser\PhpDocParser constructor invoked with 2 parameters, 3 required.

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Parameter #1 $config of class PHPStan\PhpDocParser\Parser\PhpDocParser constructor expects PHPStan\PhpDocParser\ParserConfig, PHPStan\PhpDocParser\Parser\TypeParser given.

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2)

Parameter #2 $typeParser of class PHPStan\PhpDocParser\Parser\PhpDocParser constructor expects PHPStan\PhpDocParser\Parser\TypeParser, PHPStan\PhpDocParser\Parser\ConstExprParser given.

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Class PHPStan\PhpDocParser\Parser\PhpDocParser constructor invoked with 2 parameters, 3 required.

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Parameter #1 $config of class PHPStan\PhpDocParser\Parser\PhpDocParser constructor expects PHPStan\PhpDocParser\ParserConfig, PHPStan\PhpDocParser\Parser\TypeParser given.

Check failure on line 112 in src/Entity/Reflection/MetadataParser.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Parameter #2 $typeParser of class PHPStan\PhpDocParser\Parser\PhpDocParser constructor expects PHPStan\PhpDocParser\Parser\TypeParser, PHPStan\PhpDocParser\Parser\ConstExprParser given.
}
}


Expand Down

0 comments on commit 60f4f14

Please sign in to comment.