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

ArraySpreadInsteadOfArrayMergeRector bug #2854

Closed
bendavies opened this issue Feb 14, 2020 · 4 comments · Fixed by #2872
Closed

ArraySpreadInsteadOfArrayMergeRector bug #2854

bendavies opened this issue Feb 14, 2020 · 4 comments · Fixed by #2872
Labels

Comments

@bendavies
Copy link
Contributor

bendavies commented Feb 14, 2020

Subject Details
Rector version Rector 0.6.x-dev@b2c0c3e
PHP version 7.4.2
Full Command
Demo link https://getrector.org/demo/c85519dc-4feb-469e-b30d-fffc4d7f279c
rector.yaml

Current Behaviour

ArraySpreadInsteadOfArrayMergeRector is buggy because

array_merge(...$values)) !== [...$values]
<?php

$values = [
  [new stdClass],
  [new stdClass]
];

var_dump(array_merge(...$values) === [...$values]);

Minimal PHP Code Causing Issue

https://getrector.org/demo/c85519dc-4feb-469e-b30d-fffc4d7f279c

Expected Behaviour

ArraySpreadInsteadOfArrayMergeRector is not applied

@TomasVotruba
Copy link
Member

3v4l.org would help too
What's the difference?

@bendavies
Copy link
Contributor Author

bendavies commented Feb 14, 2020

array_merge flattens the arrays
https://3v4l.org/8E3E4

@bendavies
Copy link
Contributor Author

Here is the issue:

https://3v4l.org/m2adm

You can't apply ArraySpreadInsteadOfArrayMergeRector if the array_merge has argument unpacking with ...

@TomasVotruba
Copy link
Member

Thanks, much better! Could you send failing test case to ArraySpreadInsteadOfArrayMergeRectorTest?

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

Successfully merging a pull request may close this issue.

2 participants