-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DocBlockDriver unable to parse single-line DocBlocks #1259
Comments
Thank you for this cool addition by the way! Combining this with attributes and named parameters from PHP 8 will be my absolute favorite way to go in future. My vision would be something like this (some random modifier ideas thrown into the mix as well 😄): class Foo
{
/** @var Bar[] */
#[Serializer\Property(
name: 'theBars',
nullIfEmpty: true, // for deserialization of strings and arrays
nullIfWhitespace: true, // for deserialization of strings
ignoreIfNull: true, // for serialization
ignoreIfEmpty: true, // for serialization of strings and arrays
ignoreIfWhitespace: true, // for serialization of strings
ignoreIfNullOrWhitespace: true, // for serialization of strings
)]
public ?array $bars;
} Note: not all added parameters make sense with an array of objects... it's just to illustrate. |
I had a look at the regex which is used to retrieve the type from the DocBlock. The regex is currently |
IMO the best thing to do here is to use https://github.com/phpstan/phpdoc-parser to parse the docblock. Is anyone willing ro provide a PR for it? |
Sure, I can give it a shot. Some questions in advance though:
|
Cleaning up my issues and realized this never has been closed even though it has been fixed. 👍 |
Steps required to reproduce the problem
Use the new
$builder->setDocBlockTypeResolver(true)
feature from Resolve collections from DocBlock #1214.Define single-line DocBlocks to save some space:
Expected Result
Parses successfully.
Actual Result
Throws exception(s):
Case
Bar[]
:Case
\Some\Namespace\Bar[]
:Additional Information
The same code with multi-line DocBlocks parses and de-/serializes successfully:
Interestingly enough, using the
array<Class>
syntax also works with single-line DocBlocks:The text was updated successfully, but these errors were encountered: