[TASK] Installation process hangs with PHP 7.1 98/50998/3
authorOliver Hader <oliver@typo3.org>
Mon, 19 Dec 2016 17:56:03 +0000 (18:56 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 19 Dec 2016 19:34:12 +0000 (20:34 +0100)
The lengthy switch/case part of the Lexer class seems to be
too much for PHP 7.1.0. Albeit this seems to be a PHP bug,
this patch is provided to help others and to clean up the
mentioned switch/case code.

Change-Id: I0e8e4ca55f2e15d0445874b44a04742645670570
Resolves: #79039
Releases: master
Reviewed-on: https://review.typo3.org/50998
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/Database/Schema/Parser/Lexer.php

index 9e858a8..6720a8b 100644 (file)
@@ -197,73 +197,76 @@ class Lexer extends \Doctrine\Common\Lexer
     {
         $type = self::T_NONE;
 
-        switch (true) {
-            // Recognize numeric values
-            case is_numeric($value):
-                if (strpos($value, '.') !== false || stripos($value, 'e') !== false) {
-                    return self::T_FLOAT;
-                }
+        // Recognize numeric values
+        if (is_numeric($value)) {
+            if (strpos($value, '.') !== false || stripos($value, 'e') !== false) {
+                return self::T_FLOAT;
+            }
 
-                return self::T_INTEGER;
+            return self::T_INTEGER;
+        }
 
-            // Recognize quoted strings
-            case $value[0] === "'":
-                $value = str_replace("''", "'", substr($value, 1, -1));
+        // Recognize quoted strings
+        if ($value[0] === "'") {
+            $value = str_replace("''", "'", substr($value, 1, -1));
 
-                return self::T_STRING;
+            return self::T_STRING;
+        }
 
-            // Recognize quoted strings
-            case $value[0] === '`':
-                $value = str_replace('``', '`', substr($value, 1, -1));
+        // Recognize quoted strings
+        if ($value[0] === '`') {
+            $value = str_replace('``', '`', substr($value, 1, -1));
 
-                return self::T_IDENTIFIER;
+            return self::T_IDENTIFIER;
+        }
 
-            // Recognize identifiers, aliased or qualified names
-            case ctype_alpha($value[0]):
-                $name = 'TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Lexer::T_' . strtoupper($value);
+        // Recognize identifiers, aliased or qualified names
+        if (ctype_alpha($value[0])) {
+            $name = 'TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Lexer::T_' . strtoupper($value);
 
-                if (defined($name)) {
-                    $type = constant($name);
+            if (defined($name)) {
+                $type = constant($name);
 
-                    if ($type > 100) {
-                        return $type;
-                    }
+                if ($type > 100) {
+                    return $type;
                 }
+            }
 
-                return self::T_STRING;
+            return self::T_STRING;
+        }
 
+        switch ($value) {
             // Recognize symbols
-            case $value === '.':
+            case '.':
                 return self::T_DOT;
-            case $value === ';':
+            case ';':
                 return self::T_SEMICOLON;
-            case $value === ',':
+            case ',':
                 return self::T_COMMA;
-            case $value === '(':
+            case '(':
                 return self::T_OPEN_PARENTHESIS;
-            case $value === ')':
+            case ')':
                 return self::T_CLOSE_PARENTHESIS;
-            case $value === '=':
+            case '=':
                 return self::T_EQUALS;
-            case $value === '>':
+            case '>':
                 return self::T_GREATER_THAN;
-            case $value === '<':
+            case '<':
                 return self::T_LOWER_THAN;
-            case $value === '+':
+            case '+':
                 return self::T_PLUS;
-            case $value === '-':
+            case '-':
                 return self::T_MINUS;
-            case $value === '*':
+            case '*':
                 return self::T_MULTIPLY;
-            case $value === '/':
+            case '/':
                 return self::T_DIVIDE;
-            case $value === '!':
+            case '!':
                 return self::T_NEGATE;
-            case $value === '{':
+            case '{':
                 return self::T_OPEN_CURLY_BRACE;
-            case $value === '}':
+            case '}':
                 return self::T_CLOSE_CURLY_BRACE;
-
             // Default
             default:
                 // Do nothing