-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Parameter $column of method orWhere() errors when Illuminate\Database\Query\Expression is given #784
Comments
orWhere()
errors when Illuminate\Database\Query\Expression
is given
Update: please note that when including
|
Update: please note I'm on Laravel Framework 7.30.4. |
Hello @ttomdewit! We use stubs for special purposes. |
Yeah I'd be happy to take a look |
Hi, I think our stubs needs updating. Here you can see the accepted types. Just need to add Query\Expression to it. If you can make a PR with changes and some tests, I can merge it 👍 Edit: Of course @szepeviktor was faster 😄 |
I'll try and PR this addition and add the tests. It's a new codebase for me so might take a second. |
@szepeviktor @canvural What about the array type that's included in the stub but not in the original DocBlock? Is that expected? |
Just make the parameter type equal to Laravel 8. |
It is in the original docbloc: https://github.com/laravel/framework/blob/7.x/src/Illuminate/Database/Eloquent/Builder.php#L264 |
I must misread it. I thought it accepts either a Closure, a string, an array or a Query expression. Perhaps you're describing what the array should look like. I'll leave it for now and try to PR what @szepeviktor mentioned about copying over the original DocBlock. |
@ttomdewit Are you talking about the |
I wasn't, no, but that's a good comment. I'll make sure to keep it! I'm referring to the next part:
And explicitly the |
|
That makes perfect sense. Thank you! For now I've changed it to this and am currently manually testing it: /**
* Add an "or where" clause to the query.
*
* @param \Closure|model-property<TModelClass>|array<model-property<TModelClass>|int, mixed>|\Illuminate\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @return $this
*/
public function orWhere($column, $operator = null, $value = null); |
@szepeviktor @canvural I'm happy to report that the error is gone when applying the changes mentioned in #784 (comment). On to the tests now. |
Thank you. And I believe Laravel can take Query\Expression in different methods also. Please update them too. I think laravel/framework#34828 added them all to Laravel. |
Allow me to add the test for this particular method, all tests are currently green as expected so I'll need to figure out how to add this particular example. |
@szepeviktor @canvural I have absolutely no idea how to test these changes with the way tests are setup in this project. I'll publish the PR and, if you have time, maybe you can point me in the right direction. |
--level
used: 5Description
When on level 5, the
orWhere()
method onIlluminate\Database\Eloquent\Builder<Illuminate\Database\Eloquent\Model>::orWhere()
fails when aIlluminate\Database\Query\Expression
is given, even though it's in the DocBlock of aforementioned method.Laravel code where the issue was found
Full error:
Note: it says it expects an array that looks like
int|string
ormixed
, that's another error I think?The text was updated successfully, but these errors were encountered: