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

[5.4][PHP-7.2] Make addNestedWhereQuery PHP 7.2 compatible #20635

Merged
merged 1 commit into from
Aug 19, 2017

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Aug 19, 2017

In PHP 7.2, count() can only be called on arrays and Countable

The old code did do this in addNestedWhereQuery:

        if (count($query->wheres)) {

Which could translate to if (count(NULL)) { which will produce:
ErrorException: count(): Parameter must be an array or an object that implements Countable

Because the phpdoc says it's supposed to be an array and I saw another place having an explicit (array)-cast, my approach was to simply ensure it's an array by default and don't have special cases for NULL case anymore

In PHP 7.2, `count()` can only be called on arrays and `Countable`

The old code did do this in `addNestedWhereQuery`:
```PHP
        if (count($query->wheres)) {
```
Which could translate to `if (count(NULL)) {` which will produce:
` ErrorException: count(): Parameter must be an array or an object that implements Countable`

Because the phpdoc says it's supposed to be an array and I saw another place having an explicit `(array)`-cast, my approach was to simply ensure it's an array by default and don't have special cases for `NULL` case anymore
@taylorotwell taylorotwell merged commit ef6177f into laravel:5.4 Aug 19, 2017
vrza added a commit to vrza/framework that referenced this pull request Mar 26, 2021
In PHP 7.2, `count()` can only be called on arrays and `Countable`

The old code did do this in `addNestedWhereQuery`:

    if (count($query->wheres)) {

Which could translate to `if (count(NULL)) {` which will produce:

`ErrorException: count(): Parameter must be an array or an object
that implements Countable`

See 5.4 pull request laravel#20635
arjanwestdorp added a commit to arjanwestdorp/framework that referenced this pull request Jul 20, 2021
arjanwestdorp added a commit to arjanwestdorp/framework that referenced this pull request Jul 21, 2021
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.

2 participants