laravel-shift/blueprint

Enhance Blueprint Stubs with PHPDoc to Eliminate PHPStan Warnings

Open

#738 aberto em 11 de fev. de 2025

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)PHP (295 forks)user submission
communityenhancementgood first issue

Métricas do repositório

Stars
 (3.107 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Synopsis:

Blueprint generates stubs for models, controllers, and more, but without proper PHPDoc annotations, my IDE won’t stop nagging about missing or unclear types. Adding detailed annotations would improve type inference, reduce warnings, and make development smoother.

Proposed Syntax:

As an Example we can modify the stub: stubs/model.class.stub

<?php

namespace {{ namespace }};

{{ imports }}

class {{ class }} extends Model
{
    use HasFactory;
}

To:

<?php

namespace {{ namespace }};

{{ imports }}

class {{ class }} extends Model
{
    /** @use HasFactory<\Database\Factories\{{ class }}Factory> */
    use HasFactory;
}

Expected Behavior:

PHPStan would stop complaining about missing PHPDoc comments in generated files.
P.S. The above change did introduce another issue - SoftDeletes ended up in PHPDoc instead of being added as a trait.

Guia do colaborador