Browse Source

bug #4830 TernaryToNullCoalescingFixer - handle yield from (SpacePossum)

This PR was merged into the 2.15 branch.

Discussion
----------

TernaryToNullCoalescingFixer - handle yield from

Commits
-------

c07a1e1f TernaryToNullCoalescingFixer - handle yield from
SpacePossum 5 years ago
parent
commit
d51dd1e8ea

+ 1 - 0
src/Fixer/Operator/TernaryToNullCoalescingFixer.php

@@ -201,6 +201,7 @@ final class TernaryToNullCoalescingFixer extends AbstractFixer
             T_INC,
             T_INC,
             T_STRING,
             T_STRING,
             T_YIELD,
             T_YIELD,
+            T_YIELD_FROM,
         ];
         ];
 
 
         foreach ($tokens as $token) {
         foreach ($tokens as $token) {

+ 1 - 0
tests/Fixer/Operator/TernaryToNullCoalescingFixerTest.php

@@ -62,6 +62,7 @@ final class TernaryToNullCoalescingFixerTest extends AbstractFixerTestCase
             ['<?php $x = isset($a[foo()]) ? $a[foo()] : null;'],
             ['<?php $x = isset($a[foo()]) ? $a[foo()] : null;'],
             ['<?php $x = isset($a[$callback()]) ? $a[$callback()] : null;'],
             ['<?php $x = isset($a[$callback()]) ? $a[$callback()] : null;'],
             ['<?php $y = isset($a) ? 2**3 : 3**2;'],
             ['<?php $y = isset($a) ? 2**3 : 3**2;'],
+            ['<?php $x = function(){isset($a[yield from $a]) ? $a[yield from $a] : null;};'],
             // Fix cases.
             // Fix cases.
             'Common fix case (I).' => [
             'Common fix case (I).' => [
                 '<?php $x = $a ?? null;',
                 '<?php $x = $a ?? null;',