Skip to content
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

Model's --write duplicates array properties that have summary and array key-value types added #1505

Open
olexoliinyk0 opened this issue Feb 1, 2024 · 3 comments · May be fixed by barryvdh/ReflectionDocBlock#16
Labels

Comments

@olexoliinyk0
Copy link
Contributor

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).

@mfn
Copy link
Collaborator

mfn commented Feb 2, 2024

Can you add a (failing) test? Or even provide a fix?

olexoliinyk0 added a commit to olexoliinyk0/laravel-ide-helper that referenced this issue Feb 2, 2024
duplication of properties that have generic types specified and descriptions;
olexoliinyk0 added a commit to olexoliinyk0/laravel-ide-helper that referenced this issue Feb 2, 2024
duplication of properties that have generic types specified and descriptions;
@olexoliinyk0
Copy link
Contributor Author

@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?

mfn added a commit that referenced this issue Feb 3, 2024
@mfn
Copy link
Collaborator

mfn commented Feb 3, 2024

Do you know any other way to fix this locally for the time being?

Sorry, no.

d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this issue Feb 16, 2024
duplication of properties that have generic types specified and descriptions;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants