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

Missing Class-level PHPDoc when using Laravel IDE Helper for models #1666

Closed
dlongheu opened this issue Jan 27, 2025 · 4 comments
Closed

Missing Class-level PHPDoc when using Laravel IDE Helper for models #1666

dlongheu opened this issue Jan 27, 2025 · 4 comments
Labels

Comments

@dlongheu
Copy link

dlongheu commented Jan 27, 2025

###Versions:

  • ide-helper Version: 3.5.4
  • Laravel Version: 11.39.1
  • PHP Version: 8.3

Question:

Hi, I'm having an issue with the Laravel IDE Helper package when generating PHPDoc for my models. The generated docblock does not include the class-level declaration (e.g., App\Models\Doctor) at the top of the docblock.

Here's an example of my Doctor model after running the command:

php artisan ide-helper:models App\Models\Doctor --write

And this is the result:

/**
 * 
 *
 * @property int $id
 * @property int $user_id
 * @property int $organization_id
 * @property string|null $fiscal_code
 * @property string|null $phone
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property Carbon|null $deleted_at
 * @property-read string $full_name
 * @property-read User $user
 * @property-read Organization $organization
 * @method static Builder<static>|Doctor query()
 * @mixin \Eloquent
 */

As you can see, the ### App\Models\Doctor line is missing at the top of the docblock.

I confirmed that the config/ide-helper.php file has the following settings enabled:
'write_model_external_builder_methods' => true, 'write_model_magic_where' => true, 'use_generics_annotations' => true,

Expected Output:

I expected the docblock to include the following at the top:

/**
 * App\Models\Doctor
 *
 * @property int $id
 * @property int $user_id
 * @property int $organization_id
 * @property string|null $fiscal_code
 * @property string|null $phone
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property Carbon|null $deleted_at
 * @property-read string $full_name
 * @property-read User $user
 * @property-read Organization $organization
 * @method static Builder<static>|Doctor query()
 * @mixin \Eloquent
 */

Question:

Is this expected behavior, or am I missing a step or configuration?
Is there a specific command or flag I need to use to include the class-level PHPDoc?

Thanks in advance for your help! Any guidance would be greatly appreciated.

@mfn
Copy link
Collaborator

mfn commented Jan 27, 2025

Is this expected behavior

Yes, was removed a year ago in #1523

@mfn
Copy link
Collaborator

mfn commented Jan 28, 2025

Maybe to add: if you had it from before, after that change, it was treated like any additional text and was preserved. So for those who upgraded all along, they might never noticed that it was removed until they e.g. manually remove the whole phpdoc or start a new project.

@w3roman
Copy link

w3roman commented Feb 25, 2025

@mfn

Image

Depending on the IDE settings, spaces at the end of lines may be removed when saving, so if we open a class and edit it, then cancel the changes and save, the space will be removed and the class will be changed. We will commit unnecessary changes. Then we will run IDE Helper and the space will be added again, and again unnecessary changes.

@mfn
Copy link
Collaborator

mfn commented Feb 25, 2025

Seems like a separate issue, PRs welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants