Bug #71948 [Opn]: Variables by reference with goto and switch broken as of 7.0.5
Edit report at https://bugs.php.net/bug.php?id=71948&edit=1
ID: 71948
User updated by: dane dot tschi at gmail dot com
Reported by: dane dot tschi at gmail dot com
-Summary: Variables by reference broken as of 7.0.5
+Summary: Variables by reference with goto and switch broken
as of 7.0.5
Status: Open
Type: Bug
Package: Variables related
Operating System: Unix/OSX
PHP Version: 7.0.5
Block user comment: N
Private report: N
New Comment:
Updated title
Previous Comments:
------------------------------------------------------------------------
[2016-04-02 13:32:02] dane dot tschi at gmail dot com
Description:
------------
We tried upgrading from php 7.0.4 to 7.0.5. Unfortunately zendframework stopped working. After
debugging I came up with a reduced testcase that reproduces the issue.
On php 7.0.4 it outputs the expected result, on 7.0.5 the wrong result.
This only happens if the switch-case is in there, if i replace it with if/else it works.
Test script:
---------------
<?php
$tokenIndex = 0;
$tokens = [T_WHITESPACE, T_CLASS];
$tokenType = null;
$MACRO_TOKEN_ADVANCE = function () use (&$tokenType, &$tokenIndex, $tokens) {
if (!isset($tokens[$tokenIndex])) return false;
$tokenType = $tokens[$tokenIndex++];
return $tokenType;
};
$MACRO_TOKEN_ADVANCE();
SCANNER_TOP:
switch($tokenType) {
case T_WHITESPACE: echo "whitespace"; break;
case T_CLASS: echo "class"; break;
}
if ($MACRO_TOKEN_ADVANCE() !== false) goto SCANNER_TOP;
Expected result:
----------------
whitespaceclass
Actual result:
--------------
whitespacewhitespace
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71948&edit=1
Thread (5 messages)