Model's --write duplicates array properties that have summary and array key-value types added
olexoliinyk0 opened this issue · 3 comments
Versions:
- ide-helper Version: dev-master 6336db0
- Laravel Version: 10.22.0
- PHP Version: 8.2.4
Description:
After specifying the key and value type for an Eloquent Model's array @property
and adding a comment after that - it duplicates the property.
Steps To Reproduce:
- have the Models that has an array or json column (eg Client model has
address_values
property that is json typed in DB); - run
php artisan ide-helper:models App\\Models\\Client --write
; - check that your Client model's phpDoc now has
@property array|null $address_values
; - specify array key-value types and add a summary for the property -
@property array<string, string>|null $address_values some description
; - run
php artisan ide-helper:models App\\Models\\Client --write
; - check that it now added / duplicated the
$address_values
property.
It works as expected for these variants:
@property array|null $address_values some description
-- no array key-value types;@property array<string, string>|null $address_values
-- no description / summary / text after the property name.
Expected behavior is to be able to add both array's key-value types and description (I write some examples there).
Can you add a (failing) test? Or even provide a fix?
@mfn This turns out to be a problem with the barryvdh/reflection-docblock
dependency. There's a preg_split
with a limit of 3 that combines $param_name with the description if generic type with TKey-TValue (and space between) provided, losing the description in such cases.
Created a PR to showcase this bug here and one in that dependency lib to fix this issue, but can't hope that'll be a priority for maintainers. Do you know any other way to fix this locally for the time being?
Do you know any other way to fix this locally for the time being?
Sorry, no.