@@ -721,17 +721,62 @@ protected function tokenize($string)
721
721
continue ;
722
722
}//end if
723
723
724
+ /*
725
+ Before PHP 7.0, the "yield from" was tokenized as
726
+ T_YIELD, T_WHITESPACE and T_STRING. So look for
727
+ and change this token in earlier versions.
728
+ */
729
+
730
+ if (PHP_VERSION_ID < 70000
731
+ && PHP_VERSION_ID >= 50500
732
+ && $ tokenIsArray === true
733
+ && $ token [0 ] === T_YIELD
734
+ && isset ($ tokens [($ stackPtr + 1 )]) === true
735
+ && isset ($ tokens [($ stackPtr + 2 )]) === true
736
+ && $ tokens [($ stackPtr + 1 )][0 ] === T_WHITESPACE
737
+ && $ tokens [($ stackPtr + 2 )][0 ] === T_STRING
738
+ && strtolower ($ tokens [($ stackPtr + 2 )][1 ]) === 'from '
739
+ ) {
740
+ $ newToken = array ();
741
+ $ newToken ['code ' ] = T_YIELD_FROM ;
742
+ $ newToken ['type ' ] = 'T_YIELD_FROM ' ;
743
+ $ newToken ['content ' ] = $ token [1 ].$ tokens [($ stackPtr + 1 )][1 ].$ tokens [($ stackPtr + 2 )][1 ];
744
+ $ finalTokens [$ newStackPtr ] = $ newToken ;
745
+
746
+ $ newStackPtr ++;
747
+ $ stackPtr += 2 ;
748
+ continue ;
749
+ }
750
+
724
751
/*
725
752
Before PHP 5.5, the yield keyword was tokenized as
726
753
T_STRING. So look for and change this token in
727
754
earlier versions.
755
+ Checks also if it is just "yield" or "yield from".
728
756
*/
729
757
730
758
if (PHP_VERSION_ID < 50500
731
759
&& $ tokenIsArray === true
732
760
&& $ token [0 ] === T_STRING
733
761
&& strtolower ($ token [1 ]) === 'yield '
734
762
) {
763
+ if (isset ($ tokens [($ stackPtr + 1 )]) === true
764
+ && isset ($ tokens [($ stackPtr + 2 )]) === true
765
+ && $ tokens [($ stackPtr + 1 )][0 ] === T_WHITESPACE
766
+ && $ tokens [($ stackPtr + 2 )][0 ] === T_STRING
767
+ && strtolower ($ tokens [($ stackPtr + 2 )][1 ]) === 'from '
768
+ ) {
769
+ $ newToken = array ();
770
+ $ newToken ['code ' ] = T_YIELD_FROM ;
771
+ $ newToken ['type ' ] = 'T_YIELD_FROM ' ;
772
+ $ newToken ['content ' ] = $ token [1 ].$ tokens [($ stackPtr + 1 )][1 ].$ tokens [($ stackPtr + 2 )][1 ];
773
+ $ finalTokens [$ newStackPtr ] = $ newToken ;
774
+
775
+ $ newStackPtr ++;
776
+ $ stackPtr += 2 ;
777
+ continue ;
778
+ }
779
+
735
780
$ newToken = array ();
736
781
$ newToken ['code ' ] = T_YIELD ;
737
782
$ newToken ['type ' ] = 'T_YIELD ' ;
0 commit comments