diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 2d834d7d40..acd8cc0fcd 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -49,12 +49,8 @@ class DbalLogger implements SQLLogger $this->stopwatch->start('doctrine', 'doctrine'); } - if (is_array($params)) { - $params = $this->normalizeParams($params); - } - if (null !== $this->logger) { - $this->log($sql, null === $params ? array() : $params); + $this->log($sql, null === $params ? array() : $this->normalizeParams($params)); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml index 2b6307a9ef..5922d14664 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml @@ -9,11 +9,7 @@ - - - - %kernel.cache_dir%/secure_random.seed - - + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 21406feb49..ca9e7f994c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -60,6 +60,11 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface $files = $this->extractFiles($resource); foreach ($files as $file) { $this->parseTokens(token_get_all(file_get_contents($file)), $catalog); + + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } } } @@ -80,7 +85,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface */ protected function normalizeToken($token) { - if (is_array($token)) { + if (isset($token[1]) && 'b"' !== $token) { return $token[1]; } @@ -94,7 +99,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface { for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (!is_array($t) || ($t[0] !== T_WHITESPACE)) { + if (T_WHITESPACE !== $t[0]) { break; } } @@ -111,7 +116,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (!is_array($t)) { + if (!isset($t[1])) { break; } diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index f00e09ca3c..e702a90990 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.9", - "symfony/security": "~2.7", + "symfony/security": "~2.7.9|~2.8", "symfony/security-acl": "~2.7", "symfony/http-kernel": "~2.2" }, diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index cffc1ab294..8046579685 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -149,8 +149,9 @@ class ClassCollectionLoader $inNamespace = false; $tokens = token_get_all($source); - for (reset($tokens); false !== $token = current($tokens); next($tokens)) { - if (is_string($token)) { + for ($i = 0; isset($tokens[$i]); ++$i) { + $token = $tokens[$i]; + if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { // strip comments @@ -162,12 +163,12 @@ class ClassCollectionLoader $rawChunk .= $token[1]; // namespace name and whitespaces - while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { - $rawChunk .= $t[1]; + while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { + $rawChunk .= $tokens[$i][1]; } - if ('{' === $t) { + if ('{' === $tokens[$i]) { $inNamespace = false; - prev($tokens); + --$i; } else { $rawChunk = rtrim($rawChunk)."\n{"; $inNamespace = true; @@ -175,8 +176,8 @@ class ClassCollectionLoader } elseif (T_START_HEREDOC === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; do { - $token = next($tokens); - $output .= is_string($token) ? $token : $token[1]; + $token = $tokens[++$i]; + $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; } while ($token[0] !== T_END_HEREDOC); $output .= "\n"; $rawChunk = ''; @@ -192,7 +193,15 @@ class ClassCollectionLoader $rawChunk .= "}\n"; } - return $output.self::compressCode($rawChunk); + $output .= self::compressCode($rawChunk); + + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + unset($tokens, $rawChunk); + gc_mem_caches(); + } + + return $output; } /** diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index a4ddce5115..07c974f428 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -72,6 +72,11 @@ class ClassMapGenerator $classes = self::findClasses($path); + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } + foreach ($classes as $class) { $map[$class] = $path; } @@ -95,10 +100,10 @@ class ClassMapGenerator $classes = array(); $namespace = ''; - for ($i = 0, $max = count($tokens); $i < $max; ++$i) { + for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; - if (is_string($token)) { + if (!isset($token[1])) { continue; } @@ -108,9 +113,9 @@ class ClassMapGenerator case T_NAMESPACE: $namespace = ''; // If there is a namespace, extract it - while (($t = $tokens[++$i]) && is_array($t)) { - if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { - $namespace .= $t[1]; + while (isset($tokens[++$i][1])) { + if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) { + $namespace .= $tokens[$i][1]; } } $namespace .= '\\'; @@ -121,7 +126,7 @@ class ClassMapGenerator // Skip usage of ::class constant $isClassConstant = false; for ($j = $i - 1; $j > 0; --$j) { - if (is_string($tokens[$j])) { + if (!isset($tokens[$j][1])) { break; } @@ -138,10 +143,11 @@ class ClassMapGenerator } // Find the classname - while (($t = $tokens[++$i]) && is_array($t)) { + while (isset($tokens[++$i][1])) { + $t = $tokens[$i]; if (T_STRING === $t[0]) { $class .= $t[1]; - } elseif ($class !== '' && T_WHITESPACE == $t[0]) { + } elseif ('' !== $class && T_WHITESPACE === $t[0]) { break; } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 989517dcbb..a85c8a8f52 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -711,14 +711,15 @@ abstract class Kernel implements KernelInterface, TerminableInterface $output = ''; $tokens = token_get_all($source); $ignoreSpace = false; - for (reset($tokens); false !== $token = current($tokens); next($tokens)) { - if (is_string($token)) { + for ($i = 0; isset($tokens[$i]); ++$i) { + $token = $tokens[$i]; + if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; } elseif (T_START_HEREDOC === $token[0]) { $output .= $rawChunk.$token[1]; do { - $token = next($tokens); - $output .= $token[1]; + $token = $tokens[++$i]; + $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; } while ($token[0] !== T_END_HEREDOC); $rawChunk = ''; } elseif (T_WHITESPACE === $token[0]) { @@ -744,6 +745,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface $output .= $rawChunk; + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + unset($tokens, $rawChunk); + gc_mem_caches(); + } + return $output; } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index edb3142356..bd1b428d09 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -246,7 +246,7 @@ modified'; $heredoc = <<isAbstract()) { - throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class)); + throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName())); } $globals = $this->getGlobals($class); diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index 8ce57ac18c..a3a7e0e5ae 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -64,6 +64,10 @@ class AnnotationFileLoader extends FileLoader $collection->addResource(new FileResource($path)); $collection->addCollection($this->loader->load($class, $type)); } + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } return $collection; } @@ -88,10 +92,10 @@ class AnnotationFileLoader extends FileLoader $class = false; $namespace = false; $tokens = token_get_all(file_get_contents($file)); - for ($i = 0, $count = count($tokens); $i < $count; ++$i) { + for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; - if (!is_array($token)) { + if (!isset($token[1])) { continue; } @@ -100,11 +104,11 @@ class AnnotationFileLoader extends FileLoader } if (true === $namespace && T_STRING === $token[0]) { - $namespace = ''; - do { - $namespace .= $token[1]; - $token = $tokens[++$i]; - } while ($i < $count && is_array($token) && in_array($token[0], array(T_NS_SEPARATOR, T_STRING))); + $namespace = $token[1]; + while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) { + $namespace .= $tokens[$i][1]; + } + $token = $tokens[$i]; } if (T_CLASS === $token[0]) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index 2d623c9784..162563e095 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -99,7 +99,6 @@ class CardSchemeValidatorTest extends AbstractConstraintValidatorTest array('MAESTRO', '5020507657408074712'), array('MAESTRO', '5612559223580173965'), array('MAESTRO', '6759744069209'), - array('MAESTRO', '6759744069209'), array('MAESTRO', '6594371785970435599'), array('MASTERCARD', '5555555555554444'), array('MASTERCARD', '5105105105105100'),