Comments (3)
Have you tried setting textBetweenTagsBelongsToDescription
in PhpDocParser to true?
These options are similar to PHPStan's bleeding edge. Right now they're set to false for BC reasons but they will be removed in 2.0 and code will behave the new modern way (as if these options were set to true).
Also check out options in TypeParser and ConstExprParser.
from phpdoc-parser.
Yes I did check those settings, those resulted in the same behavior.
I didn't check the other parsers but I assume they have nothing Todo with the issue we are facing as it is reproduced with just the description. In fact the text processing stops after an empty line in all cases I checked.
from phpdoc-parser.
I checked again... since I was using the parser just for a single tag this caused issues. So I do have a workaround that works for us right now. As we can simply consume all tokens from the lexer.
Which brings me to another issue, which might be one you also are facing when reconstructing docblocks. When I have a docblock line like this:
/**
* @param string $myParam this is a description of the param
*
* And this line also belongs to $myParam.
* @param array $other this is a new param.
*/
*/
The token on line 2 contains: \n
with type Lexer::TOKEN_PHPDOC_EOL
but as the parser sees this as a EOL
it will remove the trailing whitespace when building the description.
We fixed this by adding some post processing on the tokens:
private function tokenizeLine(string $tagLine): TokenIterator
{
$tokens = $this->lexer->tokenize($tagLine);
$fixed = [];
foreach ($tokens as $token) {
if ($token[1] === Lexer::TOKEN_PHPDOC_EOL) {
if (rtrim($token[0], " \t") !== $token[0]) {
$fixed[] = [rtrim($token[Lexer::VALUE_OFFSET], " \t"), Lexer::TOKEN_PHPDOC_EOL, $token[2] ?? null];
$fixed[] = [ltrim($token[Lexer::VALUE_OFFSET], "\n\r"), Lexer::TOKEN_HORIZONTAL_WS, ($token[2] ?? null) + 1];
continue;
}
}
$fixed[] = $token;
}
return new TokenIterator($fixed);;
}
But I think this is a bug in the way phpstan parses the docblocks. This expression: self::TOKEN_PHPDOC_EOL => '\\r?+\\n[\\x09\\x20]*+(?:\\*(?!/)\\x20?+)?',
seems to be to greedy.
Do you think it's worth fixing this?
from phpdoc-parser.
Related Issues (20)
- Union operator on a new line causes parsing error
- Multiline array shapes with 'comments'
- Shared shape definition for union of object and array
- Custom Phpstan rule tests broken after update to 1.20.0 HOT 16
- Printer must print float as float and never as int
- Custom Phpstan rule tests broken after update to 1.20.0 (still happens on 1.20.4) HOT 6
- Allowing whitespace between `array` and its "shape" HOT 3
- Call to a member function getNodeStartPointer() on null HOT 2
- Support for escaped quotes in Doctrine Annotation strings HOT 8
- InvalidTagValueNode when parsing Doctrine annotations HOT 4
- PHPStan report a Exception when upgrade to v1.10.34 HOT 5
- numeric postgres type resolves to mixed? HOT 2
- Comment not allowed in @phpstan-type
- Reading types from reflection, not from string HOT 3
- Return type in `@method` starting with `static` cannot be parsed HOT 6
- Documentation on retrieving the doc comment text HOT 4
- Add support for `@property $foo` syntax. HOT 6
- Rector error: Call to undefined method PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode::getParamImmediatelyInvokedCallableTagValues() HOT 2
- Add support for unsealed shapes with specified other elements' types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpdoc-parser.