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

Fix PHPStan parser for different PHP version parsing #1791

Merged
merged 5 commits into from Feb 9, 2022

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Feb 9, 2022

@TomasVotruba TomasVotruba changed the title tv downgrade json Fix infinite mixed loop in DowngradeJsonDecodeNullAssociativeArgRector Feb 9, 2022
@TomasVotruba TomasVotruba force-pushed the tv-downgrade-json branch 3 times, most recently from 60b933f to 2be2313 Compare February 9, 2022 10:42
@samsonasik
Copy link
Member

@TomasVotruba It seems if it called multiple time, the changes keep happen:

bin/rector p vendor/clue/ndjson-react/src/Decoder.php -c build/config/config-downgrade-parallel.php -n --clear-cache --debug

try call multiple times, and it keep adding diff, which should not.

@samsonasik
Copy link
Member

It called multiple time, make multipel changes:

bin/rector process vendor/clue/ndjson-react/src/Decoder.php -c build/config/config-downgrade-parallel.php --clear-cache --debug

             if ($this->options === 0) {
-                $data = \json_decode($data, ($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc), $this->depth);
+                $data = \json_decode($data, (($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc)) === null ?: (($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc)), $this->depth);
             } else {
-                $data = \json_decode($data, ($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc), $this->depth, $this->options);
+                $data = \json_decode($data, (($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc)) === null ?: (($this->assoc === null ?: $this->assoc) === null ?: ($this->assoc === null ?: $this->assoc)), $this->depth, $this->options);

@TomasVotruba
Copy link
Member Author

Indeed, the scope is not refreshed so the type is the same. I'll check it 👍

@samsonasik
Copy link
Member

@TomasVotruba the vendor/clue/ndjson-react/src/Decoder.php should not be changed since the $this->assoc is always filled at constructor, and always be bool.

@samsonasik
Copy link
Member

This change is invalid:

1) vendor/clue/ndjson-react/src/Decoder.php:108

    ---------- begin diff ----------
@@ @@

             // decode data with options given in ctor
             if ($this->options === 0) {
-                $data = \json_decode($data, $this->assoc, $this->depth);
+                $data = \json_decode($data, $this->assoc === null ?: $this->assoc, $this->depth);
             } else {
-                $data = \json_decode($data, $this->assoc, $this->depth, $this->options);
+                $data = \json_decode($data, $this->assoc === null ?: $this->assoc, $this->depth, $this->options);
             }

             // abort stream if decoding failed
    ----------- end diff -----------

Applied rules:
 * DowngradeJsonDecodeNullAssociativeArgRector (https://3v4l.org/b1mA6)

since $this->assoc always filled by construct, and always be bool for @param bool, while it technically possible to provide non bool, but this change cause innnecessary change.

@TomasVotruba TomasVotruba changed the title Fix infinite mixed loop in DowngradeJsonDecodeNullAssociativeArgRector Fix PHPStan parser for different PHP version parsing Feb 9, 2022
@TomasVotruba TomasVotruba force-pushed the tv-downgrade-json branch 3 times, most recently from 6b8e649 to 7858df3 Compare February 9, 2022 11:42
@TomasVotruba TomasVotruba force-pushed the tv-downgrade-json branch 2 times, most recently from 963b961 to 20379f4 Compare February 9, 2022 12:01
@TomasVotruba
Copy link
Member Author

@samsonasik I've tried few parser.neon modifications, but no useful result that would not break something else.
Let's revert for now to last working modification. Thanks for feedbacks 👍

@TomasVotruba TomasVotruba enabled auto-merge (squash) February 9, 2022 12:07
@TomasVotruba TomasVotruba merged commit bc0eac3 into main Feb 9, 2022
@TomasVotruba TomasVotruba deleted the tv-downgrade-json branch February 9, 2022 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants