1

I have phpstan in my proyect to analyze all my code. I´m working with laravel and php 8.2.

My problem it´s that when i execute phpStan return any errors and i have one in my function that i´m calling a scope function. this call it´s:

$empresas_informe_gts = Empresa::filtrarConLiquidacionesOrdenadosPorNombre($argsScope);

and in Empresa i have this function defined:

public function scopeFiltrarConLiquidacionesOrdenadosPorNombre($query, $args)

But the analysis, return

Call to an undefined static method
         App\Models\Empresa::filtrarConLiquidacionesOrdenadosPorNombre().

I try to add in function:

/**
     * @param Query<String> $query
     * @return Object<Object>
     */

but i have same error. This function scope, have a return $query with any joins and method get().

Thanks for readme and sorry for my bad english

1 Answer 1

3

The PhpDoc notation is not @param but @method

use Illuminate\Database\Eloquent\Builder;

/** @method static Builder filtrarConLiquidacionesOrdenadosPorNombre (array $args)

One of the points of PHPStan is to check type matching, so the more you typehint the more it can help.

public function scopeFiltrarConLiquidacionesOrdenadosPorNombre(Builder $query, array $args): Builder

A smaller point, as the query builder Builder, is an object you do not have to return it in scopes. As objects is always passed by reference.

Sign up to request clarification or add additional context in comments.

1 Comment

i had wrote FiltrarConLiquidacionesOrdenadosPorNombre instead of filtrarConLiquidacionesOrdenadosPorNombre try with that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.