Open mabar opened 3 years ago
The question is what is the proper fix. I'd rather refrain from depending on some phodoc parser able to handle this 🤔
I would say phpstan/phpdoc-parser is reasonable dependency. But not supporting it and just informing by throwing exception might be good enough too.
Entity implementation using real properties and attributes may come with an alternative anyway so the opcache.save_comments
could be enabled.
I would say there are three tasks:
array*
and just validating it as an arrayThe validation is rather too complicated and I would refrain from doing so 🤔 Supporting just the parsing could be nicely and easily done without an dependency. I do not expect any other more complex types like functional types and so.
With the increased amount of what types can be (newly union types in PHP 8.1), we should use PHPStans phpdoc parser.
The question is how the validation should work. Probably full validation should be implemented.
"Full" validation actually means just:
array
)int
, bool
, float
, string
)What will be the behavior for not supported types? Throw exception or note in documentation type may not be true? Exception is safer but it will likely lead to requests for types users actually do use.
Either:
{typeNotCheckedAtRuntime}
)/shrug
Describe the bug
Properties using generic array syntax and defining key type are ignored.
To Reproduce
Nextras\Orm\Entity\Entity
)@property array<string, string> $example
$example
property,EntityMetadata
should throw exceptionExpected behavior
@property array<string, string> $example
is a valid property, same as (currently valid)@property array<string> $example
or at least throw an exception describing syntax is not supported.Versions::