Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no need to generate comments for query, newquery, newmodelqu… #1071

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

a443939412
Copy link

There is no need to generate static method comments for query, newQuery and newModelQuery

Summary

Model::newQuery() and Model::newModelQuery() works incorrectly in laravel 6.8.

@mfn
Copy link
Collaborator

mfn commented Dec 2, 2020

I'm sorry, I don't understand the purpose of this PR.

It's certainly possible to invoke <YourModel>::… with any of these methods; they're caught by \Illuminate\Database\Eloquent\Model::__callStatic and forwarded.

Can you explain in more detail what it fixes for your? Also just commenting out code and not adapting tests won't be acceptable.

I'm inclined to reject this PR in the current state without more information, I hope you can understand.

@a443939412
Copy link
Author

a443939412 commented Dec 3, 2020

Because it works wrong in laravel 6. X and PHP 7.3
dd(Spu::newQuery());

image

The same is true for the newModelQuery method.
dd(Spu::newModelQuery()); (laravel 6. X and PHP 7.3)

ErrorException
Non-static method Illuminate\Database\Eloquent\Model::newModelQuery() should not be called statically

dd(StockLogs::newQuery()); (laravel v5.5 and PHP 7.3)

image

    public static function __callStatic($method, $parameters)
    {
        return (new static)->$method(...$parameters);
    }

For the time being, I don't know why __callStatic didn't work

@rimace
Copy link

rimace commented Apr 9, 2021

@mfn

It's certainly possible to invoke <YourModel>::… with any of these methods; they're caught by \Illuminate\Database\Eloquent\Model::__callStatic and forwarded.

I see what you mean, but PHP does not call __callStatic if the a method with that name exists.
So No, static call to newQuery() or newModelQuery() will not get forwarded.
When I try to call <A Model>::newQuery() PHP 7.4 and 8.0 throws the error Non-static method Illuminate\Database\Eloquent\Model::newQuery() cannot be called statically .

It only works with query(), because it is a static method.

@mfn
Copy link
Collaborator

mfn commented Sep 15, 2022

Please add tests covering this, right now I don't even need to trigger the workflow runs because there are none. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants