Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:5.4from
mfn:patch-2
Aug 19, 2017
Merged

[5.4][PHP-7.2] Make addNestedWhereQuery PHP 7.2 compatible#20635
taylorotwell merged 1 commit into
laravel:5.4from
mfn:patch-2

Conversation

@mfn

@mfn mfn commented Aug 19, 2017

Copy link
Copy Markdown
Contributor

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