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

Hotfix: correct array indicies when using ternary or coalesce ops #2695

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

michalbundyra
Copy link
Contributor

Fixes #2694

I have find out that the issue is also when using coalesce operator.
Example, which is valid code, but has no sens would be:

$array = [
    'foo' => 'foo',
    'bar' => $baz ? ['abc'] : ['def'],
    'hey' => $baz ?? ['one'] ?? ['two'],
];

Without fix we have 5 elements in $indices but we should have 3.

Added tests to cover changes.

Fixes squizlabs#2694

I have find out that the issue is also when using coalesce operator.
Example, which is valid code, but has no sens would be:

```php
$array = [
    'foo' => 'foo',
    'bar' => $baz ? ['abc'] : ['def'],
    'hey' => $baz ?? ['one'] ?? ['two'],
];
```

Without fix we have 5 elements in `$indices` but we should have 3.

Added tests to cover changes.
@gsherwood gsherwood merged commit e6b37df into squizlabs:master Nov 14, 2019
@gsherwood gsherwood added this to the 3.5.3 milestone Nov 14, 2019
@gsherwood
Copy link
Member

Thanks for fixing this.

@michalbundyra michalbundyra deleted the hotfix/array-indices branch November 14, 2019 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AbstractArraySniff produces invalid indices when using ternary operator
2 participants