Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"nette/utils": "^3.2",
"nikic/php-parser": "^4.16.0",
"ondram/ci-detector": "^4.1",
"phpstan/phpdoc-parser": "^1.21.3",
"phpstan/phpdoc-parser": "^1.23",
"phpstan/phpstan": "^1.10.26",
"react/event-loop": "^1.3",
"react/socket": "^1.12",
Expand Down
6 changes: 4 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@
$services->alias(PhpDocParser::class, BetterPhpDocParser::class);

$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
$services->set(TypeParser::class);
$services->set(ConstExprParser::class);
$services->set(TypeParser::class)
->arg('$usedAttributes', ['lines' => true, 'indexes' => true]);
$services->set(ConstExprParser::class)
->arg('$usedAttributes', ['lines' => true, 'indexes' => true]);

// tagged services
$services->set(PhpDocNodeMapper::class)
Expand Down
18 changes: 17 additions & 1 deletion packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,23 @@ public function __construct(
private readonly iterable $phpDocNodeDecorators,
private readonly PrivatesAccessor $privatesAccessor = new PrivatesAccessor(),
) {
parent::__construct($typeParser, $constExprParser);
parent::__construct(
// TypeParser
$typeParser,
// ConstExprParser
$constExprParser,
// requireWhitespaceBeforeDescription
false,
// preserveTypeAliasesWithInvalidTypes
false,
// usedAttributes
['lines' => true, 'indexes' => true],
Comment on lines +52 to +53
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is based on @ondrejmirtes suggestion at rectorphp/rector#7959 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to pass the same array also to other classes that use it - ConstExprParser, TypeParser, PhpDocParser.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ondrejmirtes, I will check 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ondrejmirtes I updated TypeParser and ConstExprParser usedAttributes 41a727a

// parseDoctrineAnnotations
false,
// textBetweenTagsBelongsToDescription, default to false, exists since 1.23.0
// @todo: make it true to allow next doc line text as part of current docblock
false
);
}

public function parse(TokenIterator $tokenIterator): PhpDocNode
Expand Down