Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dominiquevienne's avatar

PHPStan / LaraStan - Model event - Static call to instance method error

Hi everyone,

I'm planning to implement PHPStan / LaraStan into our projects. However, I face a Static call to instance method error for every Model boot event and I don't find how to solve this.

Here is the code triggering the issue

class Node extends AbstractModel
{
    use SoftDeletes;
    use TimeStampsBy;
    use SoftDeletesBy;

    protected $fillable = [
        'name',
// ...
    ];

    protected $hidden = [
        'created_at',
        'updated_at',
        'deleted_at',
        'created_by',
        'updated_by',
        'deleted_by',
    ];

    public static function boot()
    {
        parent::boot();

        /**
         * Ensure active property is set to 1 when creating a Node
         */
        static::creating(function (Node $model) {
            $model->active = 1;
        });

// ...
}

Thx to everyone in the willing to answer that question... ;)

0 likes
3 replies
tomasnorre's avatar

It’s not solving your problem but you could include it and start by adding it to the baseline, allow errors pr lower the level. This Will, get you started and you Can improve it when you get more experince with it.

That would at least help improve other potential improvements.

dominiquevienne's avatar

For the moment, the only way I found to work with it, even on level 1, is to somehow disable / ignore those errors.

Final goal would be to implement PHPStan in the Puil Request workflow so we ensure our code is reliable and avoid merging bad code.

tomasnorre's avatar

That you Can still do by ignoring this one error in baseline. Then all new code Will be inspected.

Please or to participate in this conversation.