laravel-elasticsearch
laravel-elasticsearch copied to clipboard
Static analysis fails on some methods
Package version
v4.0.3
Describe the bug
When running static analysis over the code using larastan
which uses phpstan
under the hood this error is generated:
Static call to instance method PDPhilip\Elasticsearch\Eloquent\Model::firstOrCreateWithoutRefresh().
from code like this:
Model::firstOrCreateWithoutRefresh([
'attribute' => 'value',
], [
'data' => [],
]);
To Reproduce
Steps to reproduce the behavior:
create standard project with larastan
as a dev dependency and try using phpstan analysis on level 1
Expected behavior
I expect the documentation to have the static calls listed as at least static in the doc block in line with the online documentation.
additionally
there are a few methods that follow this pattern, so it isn't just this single case, this just happens to be the case I was made aware of.
Workaround
Looks like one can add this to their phpstan.neon
file to avoid the phpstan
error:
parameters:
ignoreErrors:
- '#Static call to instance method PDPhilip\\.*#'
intelephense
will also complain, adding the following above the code should mute the error:
/** @disregard P1036 */
Model::firstOrCreateWithoutRefresh([
...