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