|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-04-02 13:32 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 07:00:01 2025 UTC |
This is probably the same issue. I have this code: ------------- <?php echo '<p>[PHP VERSION: '.phpversion().']</p>'; $state = 'foo'; toggle($state); echo $state; // in php 7.0.5 : still foo! function toggle(&$state) { switch ($state) { case 'foo': $state = 'bar'; break; case 'bar': $state = 'foo'; break; } } -------------