Skip to content

Commit

Permalink
register ParserConfig as service
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 14, 2024
1 parent 7699965 commit d301344
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;
use Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface;
use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory;
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
Expand Down Expand Up @@ -46,13 +47,16 @@ final class BetterPhpDocParser extends PhpDocParser
* @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators
*/
public function __construct(
ParserConfig $parserConfig,
TypeParser $typeParser,
ConstExprParser $constExprParser,
private readonly TokenIteratorFactory $tokenIteratorFactory,
private readonly array $phpDocNodeDecorators,
private readonly PrivatesAccessor $privatesAccessor,
) {
parent::__construct(
// ParserConfig
$parserConfig,
// TypeParser
$typeParser,
// ConstExprParser
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPStan\PhpDoc\TypeNodeResolver;
use PHPStan\PhpDocParser\Parser\ConstExprParser;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;
use PHPStan\Reflection\BetterReflection\SourceLocator\CachingVisitor;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Application\ChangedNodeScopeRefresher;
Expand Down Expand Up @@ -671,6 +672,11 @@ static function (
->needs('$phpDocNodeVisitors')
->giveTagged(BasePhpDocNodeVisitorInterface::class);

$rectorConfig->singleton(
ParserConfig::class,
static fn (Container $container): ParserConfig => new ParserConfig([])
);

return $rectorConfig;
}

Expand Down

0 comments on commit d301344

Please sign in to comment.