diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php index f075709654c95..30d0aff1bb102 100644 --- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php +++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php @@ -93,11 +93,7 @@ public function getHtmlCallGraph() public function getProfile() { if (null === $this->profile) { - if (PHP_VERSION_ID >= 70000) { - $this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile'))); - } else { - $this->profile = unserialize($this->data['profile']); - } + $this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile'))); } return $this->profile; diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 5e589c2db11db..bc4c6a5ae1637 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -82,11 +82,7 @@ public function testOneVar() EOTXT; - if (PHP_VERSION_ID >= 70000) { - $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); - } else { - $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); - } + $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); $this->assertSame($expected, $compiler->compile($node)->getSource()); } @@ -113,11 +109,7 @@ public function testMultiVars() EOTXT; - if (PHP_VERSION_ID >= 70000) { - $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); - } else { - $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); - } + $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); $this->assertSame($expected, $compiler->compile($node)->getSource()); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 9d3576e0b4430..33acc0cff5aa2 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -67,10 +67,6 @@ public function testCompile() protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 70000) { - return sprintf('($context["%s"] ?? null)', $name, $name); - } - - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); + return sprintf('($context["%s"] ?? null)', $name, $name); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index b292ef63f8555..322e78f1fd188 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -264,10 +264,6 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 70000) { - return sprintf('($context["%s"] ?? null)', $name, $name); - } - - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); + return sprintf('($context["%s"] ?? null)', $name, $name); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 5862006f3826a..5108db26cf788 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -40,11 +40,7 @@ public function testCompileStrict() protected function getVariableGetterWithoutStrictCheck($name) { - if (PHP_VERSION_ID >= 70000) { - return sprintf('($context["%s"] ?? null)', $name, $name); - } - - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); + return sprintf('($context["%s"] ?? null)', $name, $name); } protected function getVariableGetterWithStrictCheck($name) @@ -53,10 +49,6 @@ protected function getVariableGetterWithStrictCheck($name) return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name); } - if (PHP_VERSION_ID >= 70000) { - return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name); - } - - return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); + return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 97c94fdd14bf9..7af04086622a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -85,10 +85,8 @@ public function extract($resource, MessageCatalogue $catalog) 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(); - } + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); } } diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 8ddfa27f3868f..08cd4731ba93c 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -53,19 +53,17 @@ function ($key, $value, $isHit) { } /** - * This adapter should only be used on PHP 7.0+ to take advantage of how PHP - * stores arrays in its latest versions. This factory method decorates the given - * fallback pool with this adapter only if the current PHP version is supported. + * This adapter to take advantage of how PHP stores arrays in its latest versions. * * @param string $file The PHP file were values are cached - * @param CacheItemPoolInterface $fallbackPool Fallback for old PHP versions or opcache disabled + * @param CacheItemPoolInterface $fallbackPool Fallback when opcache is disabled * * @return CacheItemPoolInterface */ public static function create($file, CacheItemPoolInterface $fallbackPool) { // Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM - if ((PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) { + if (ini_get('opcache.enable') || defined('HHVM_VERSION')) { if (!$fallbackPool instanceof AdapterInterface) { $fallbackPool = new ProxyAdapter($fallbackPool); } diff --git a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php index 3c61f5e8f645e..40d37051820f1 100644 --- a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php @@ -37,9 +37,7 @@ public function __construct($file, CacheInterface $fallbackPool) } /** - * This adapter should only be used on PHP 7.0+ to take advantage of how PHP - * stores arrays in its latest versions. This factory method decorates the given - * fallback pool with this adapter only if the current PHP version is supported. + * This adapter to take advantage of how PHP stores arrays in its latest versions. * * @param string $file The PHP file were values are cached * @@ -48,7 +46,7 @@ public function __construct($file, CacheInterface $fallbackPool) public static function create($file, CacheInterface $fallbackPool) { // Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM - if ((PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || defined('HHVM_VERSION')) { + if (ini_get('opcache.enable') || defined('HHVM_VERSION')) { return new static($file, $fallbackPool); } diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 8fd0adc592abd..299b593d71dff 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -124,12 +124,8 @@ public function provideHashedSignature() yield array(0, 8, '/** priv docblock */'); yield array(0, 9, 'private $priv = 123;'); yield array(1, 10, '/** pub docblock */'); - if (PHP_VERSION_ID >= 50600) { - yield array(1, 11, 'public function pub(...$arg) {}'); - } - if (PHP_VERSION_ID >= 70000) { - yield array(1, 11, 'public function pub($arg = null): Foo {}'); - } + yield array(1, 11, 'public function pub(...$arg) {}'); + yield array(1, 11, 'public function pub($arg = null): Foo {}'); yield array(0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"); yield array(1, 12, '/** prot docblock */'); yield array(1, 13, 'protected function prot($a = array(123)) {}'); diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 2359677515659..14430308d1151 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -286,15 +286,7 @@ public function setCode(callable $code) if ($code instanceof \Closure) { $r = new \ReflectionFunction($code); if (null === $r->getClosureThis()) { - if (PHP_VERSION_ID < 70000) { - // Bug in PHP5: https://bugs.php.net/bug.php?id=64761 - // This means that we cannot bind static closures and therefore we must - // ignore any errors here. There is no way to test if the closure is - // bindable. - $code = @\Closure::bind($code, $this); - } else { - $code = \Closure::bind($code, $this); - } + $code = \Closure::bind($code, $this); } } diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 85cd779849b73..6195c0535afa8 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -148,11 +148,6 @@ private function parseLongOption($token) if (false !== $pos = strpos($name, '=')) { if (0 === strlen($value = substr($name, $pos + 1))) { - // if no value after "=" then substr() returns "" since php7 only, false before - // see http://php.net/manual/fr/migration70.incompatible.php#119151 - if (PHP_VERSION_ID < 70000 && false === $value) { - $value = ''; - } array_unshift($this->parsed, $value); } $this->addLongOption(substr($name, 0, $pos), $value); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index ea74f28a4d031..b970ea43aa79d 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -1106,9 +1106,6 @@ public function testConsoleErrorEventIsTriggeredOnCommandNotFound() $this->assertEquals(1, $tester->getStatusCode()); } - /** - * @requires PHP 7 - */ public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent() { $application = new Application(); @@ -1342,9 +1339,6 @@ protected function getDispatcher($skipCommand = false) return $dispatcher; } - /** - * @requires PHP 7 - */ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled() { $application = new Application(); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index a8048aeaf813b..b1963918324a6 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -392,13 +392,7 @@ public function testSetCodeWithStaticClosure() $tester = new CommandTester($command); $tester->execute(array()); - if (PHP_VERSION_ID < 70000) { - // Cannot bind static closures in PHP 5 - $this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay()); - } else { - // Can bind static closures in PHP 7 - $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); - } + $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); } private static function createClosure() diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index 2e1d71808e132..c943f7b4e0cb2 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -30,7 +30,6 @@ class DebugClassLoader private static $final = array(); private static $finalMethods = array(); private static $deprecated = array(); - private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null'); private static $darwinCache = array('/' => array('/', array())); /** @@ -201,9 +200,7 @@ public function loadClass($class) } } - if (in_array(strtolower($refl->getShortName()), self::$php7Reserved)) { - @trigger_error(sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED); - } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) { + if (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) { self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]); } else { // Don't trigger deprecations for classes in the same vendor diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index 765e8d9b86bfd..3f21b2a0adb24 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -59,29 +59,6 @@ public function testIdempotence() $this->fail('DebugClassLoader did not register'); } - public function testUnsilencing() - { - if (PHP_VERSION_ID >= 70000) { - $this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.'); - } - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is not handled in this test case.'); - } - - ob_start(); - - $this->iniSet('log_errors', 0); - $this->iniSet('display_errors', 1); - - // See below: this will fail with parse error - // but this should not be @-silenced. - @class_exists(__NAMESPACE__.'\TestingUnsilencing', true); - - $output = ob_get_clean(); - - $this->assertStringMatchesFormat('%aParse error%a', $output); - } - public function testStacking() { // the ContextErrorException must not be loaded to test the workaround @@ -109,13 +86,8 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} } } catch (\ErrorException $exception) { // if an exception is thrown, the test passed $this->assertStringStartsWith(__FILE__, $exception->getFile()); - if (PHP_VERSION_ID < 70000) { - $this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage()); - $this->assertEquals(E_STRICT, $exception->getSeverity()); - } else { - $this->assertRegExp('/^Warning: Declaration/', $exception->getMessage()); - $this->assertEquals(E_WARNING, $exception->getSeverity()); - } + $this->assertRegExp('/^Warning: Declaration/', $exception->getMessage()); + $this->assertEquals(E_WARNING, $exception->getSeverity()); } finally { restore_error_handler(); restore_exception_handler(); @@ -243,32 +215,6 @@ class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true $this->assertSame($xError, $lastError); } - public function testReservedForPhp7() - { - if (PHP_VERSION_ID >= 70000) { - $this->markTestSkipped('PHP7 already prevents using reserved names.'); - } - - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Test\\'.__NAMESPACE__.'\\Float', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Test\Symfony\Component\Debug\Tests\Float" class uses the reserved name "Float", it will break on PHP 7 and higher', - ); - - $this->assertSame($xError, $lastError); - } - public function testExtendedFinalClass() { set_error_handler(function () { return false; }); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 2fccf2dbe7a9b..eada140ccab7e 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -475,9 +475,6 @@ public function testHandleFatalError() } } - /** - * @requires PHP 7 - */ public function testHandleErrorException() { $exception = new \Error("Class 'Foo' not found"); diff --git a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php index e7762bdec8edd..4a0e6cbe4f234 100644 --- a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php +++ b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php @@ -138,9 +138,6 @@ public function testPrevious(\Exception $exception, $statusCode) $this->assertSame(array($flattened2), $flattened->getAllPrevious()); } - /** - * @requires PHP 7.0 - */ public function testPreviousError() { $exception = new \Exception('test', 123, new \ParseError('Oh noes!', 42)); diff --git a/src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php b/src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php index f49a1eb78e16c..8b507efe82eec 100644 --- a/src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php +++ b/src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php @@ -65,11 +65,7 @@ public function serialize() public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, array('allowed_classes' => false)); - } else { - list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized); - } + list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, array('allowed_classes' => false)); } /** diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 09f695ee810b9..12e43ab635c5e 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1409,13 +1409,14 @@ private function dumpValue($value, $interpolate = true) $value = $value->getValues()[0]; $code = $this->dumpValue($value, $interpolate); + $returnedType = ''; if ($value instanceof TypedReference) { - $code = sprintf('$f = function (\\%s $v%s) { return $v; }; return $f(%s);', $value->getType(), ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $value->getInvalidBehavior() ? ' = null' : '', $code); - } else { - $code = sprintf('return %s;', $code); + $returnedType = sprintf(': %s\%s', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior() ? '' : '?', $value->getType()); } - return sprintf("function () {\n %s\n }", $code); + $code = sprintf('return %s;', $code); + + return sprintf("function ()%s {\n %s\n }", $returnedType, $code); } if ($value instanceof IteratorArgument) { @@ -1628,9 +1629,7 @@ private function getServiceCall($id, Reference $reference = null) } if ($this->container->hasDefinition($id) && (!$this->container->getDefinition($id)->isPublic() || $this->container->getDefinition($id)->isShared())) { - // The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0 - - $code = "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}"; + $code = "(\$this->services['$id'] ?? $code)"; } return $code; diff --git a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php index b6115ea7dc84c..9a82937252904 100644 --- a/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php +++ b/src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php @@ -49,10 +49,6 @@ public static function getSignature(\ReflectionFunctionAbstract $r, &$call = nul $k = substr($k, 1); } } catch (\ReflectionException $e) { - if ($type && $p->allowsNull() && !class_exists('ReflectionNamedType', false)) { - $k .= ' = null'; - $k = substr($k, 1); - } } $signature[] = $k; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index e2ba9ec4e4b97..0b4f80b3629e1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -40,9 +40,6 @@ public function testProcess() $this->assertEquals(Foo::class, (string) $container->getDefinition('bar')->getArgument(0)); } - /** - * @requires PHP 5.6 - */ public function testProcessVariadic() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 744384b136f3a..aea09d916ac6b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -482,9 +482,6 @@ public function testClosureProxy() $this->assertSame('reflection.Symfony\Component\DependencyInjection\Tests\Fixtures\Container31\Foo', (string) array_pop($res)); } - /** - * @requires PHP 7.1 - */ public function testClosureProxyWithVoidReturnType() { $container = include self::$fixturesPath.'/containers/container_dump_proxy_with_void_return_type.php'; @@ -497,9 +494,6 @@ public function testClosureProxyWithVoidReturnType() $this->assertSame('reflection.Symfony\Component\DependencyInjection\Tests\Fixtures\ContainerVoid\Foo', (string) array_pop($res)); } - /** - * @requires PHP 7.1 - */ public function testClosureProxyPhp71() { $container = include self::$fixturesPath.'/containers/container32.php'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php index 045b3c8e61347..8f05da5df6b67 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php @@ -64,11 +64,11 @@ protected function getBarService() $this->services['bar'] = $instance = new \stdClass(); $instance->foo = array(0 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container31\Foo::withNoArgs */ function () { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withNoArgs(); + return ($this->services['foo'] ?? $this->get('foo'))->withNoArgs(); }, 1 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container31\Foo::withArgs */ function ($a, \Symfony\Component\DependencyInjection\Tests\Fixtures\Container31\Foo $b = NULL, $c = array(0 => 123)) { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withArgs($a, $b, $c); + return ($this->services['foo'] ?? $this->get('foo'))->withArgs($a, $b, $c); }, 2 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container31\Foo::withRefs */ function &(&$a = NULL, &$b) { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withRefs($a, $b); + return ($this->services['foo'] ?? $this->get('foo'))->withRefs($a, $b); }); return $instance; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php index c18b3f5d4421d..96ec4c73f6a66 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php @@ -64,11 +64,11 @@ protected function getBarService() $this->services['bar'] = $instance = new \stdClass(); $instance->foo = array(0 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container32\Foo::withVariadic */ function ($a, &...$c) { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withVariadic($a, ...$c); + return ($this->services['foo'] ?? $this->get('foo'))->withVariadic($a, ...$c); }, 1 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container32\Foo::withNullable */ function (?int $a) { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withNullable($a); + return ($this->services['foo'] ?? $this->get('foo'))->withNullable($a); }, 2 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\Container32\Foo::withReturnType */ function (): \Bar { - return ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withReturnType(); + return ($this->services['foo'] ?? $this->get('foo'))->withReturnType(); }); return $instance; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index b8d5aeafacf24..9e3013dcafb3b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -83,7 +83,7 @@ public function __construct() */ protected function getBarService() { - $a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + $a = ($this->services['foo.baz'] ?? $this->get('foo.baz')); $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar')); @@ -104,7 +104,7 @@ protected function getBazService() { $this->services['baz'] = $instance = new \Baz(); - $instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->get('foo_with_inline')) && false ?: '_'}); + $instance->setFoo(($this->services['foo_with_inline'] ?? $this->get('foo_with_inline'))); return $instance; } @@ -120,7 +120,7 @@ protected function getBazService() protected function getClosureProxyService() { return $this->services['closure_proxy'] = new \BarClass(/** @closure-proxy BarClass::getBaz */ function () { - return ${($_ = isset($this->services['closure_proxy']) ? $this->services['closure_proxy'] : $this->get('closure_proxy')) && false ?: '_'}->getBaz(); + return ($this->services['closure_proxy'] ?? $this->get('closure_proxy'))->getBaz(); }); } @@ -136,7 +136,7 @@ protected function getConfiguredServiceService() { $this->services['configured_service'] = $instance = new \stdClass(); - ${($_ = isset($this->services['configurator_service']) ? $this->services['configurator_service'] : $this->getConfiguratorServiceService()) && false ?: '_'}->configureStdClass($instance); + ($this->services['configurator_service'] ?? $this->getConfiguratorServiceService())->configureStdClass($instance); return $instance; } @@ -153,7 +153,7 @@ protected function getConfiguredServiceSimpleService() { $this->services['configured_service_simple'] = $instance = new \stdClass(); - ${($_ = isset($this->services['configurator_service_simple']) ? $this->services['configurator_service_simple'] : $this->getConfiguratorServiceSimpleService()) && false ?: '_'}->configureStdClass($instance); + ($this->services['configurator_service_simple'] ?? $this->getConfiguratorServiceSimpleService())->configureStdClass($instance); return $instance; } @@ -224,7 +224,7 @@ protected function getDeprecatedServiceService() */ protected function getFactoryServiceService() { - return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}->getInstance(); + return $this->services['factory_service'] = ($this->services['foo.baz'] ?? $this->get('foo.baz'))->getInstance(); } /** @@ -237,7 +237,7 @@ protected function getFactoryServiceService() */ protected function getFactoryServiceSimpleService() { - return $this->services['factory_service_simple'] = ${($_ = isset($this->services['factory_simple']) ? $this->services['factory_simple'] : $this->getFactorySimpleService()) && false ?: '_'}->getInstance(); + return $this->services['factory_service_simple'] = ($this->services['factory_simple'] ?? $this->getFactorySimpleService())->getInstance(); } /** @@ -250,14 +250,14 @@ protected function getFactoryServiceSimpleService() */ protected function getFooService() { - $a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + $a = ($this->services['foo.baz'] ?? $this->get('foo.baz')); $this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')), true, $this); $instance->foo = 'bar'; $instance->moo = $a; $instance->qux = array($this->getParameter('foo') => 'foo is '.$this->getParameter('foo').'', 'foobar' => $this->getParameter('foo')); - $instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'}); + $instance->setBar(($this->services['bar'] ?? $this->get('bar'))); $instance->initialize(); sc_configure($instance); @@ -305,7 +305,7 @@ protected function getFooWithInlineService() { $this->services['foo_with_inline'] = $instance = new \Foo(); - $instance->setBar(${($_ = isset($this->services['inlined']) ? $this->services['inlined'] : $this->getInlinedService()) && false ?: '_'}); + $instance->setBar(($this->services['inlined'] ?? $this->getInlinedService())); return $instance; } @@ -321,7 +321,7 @@ protected function getFooWithInlineService() protected function getLazyContextService() { return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () { - yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + yield 'k1' => ($this->services['foo.baz'] ?? $this->get('foo.baz')); yield 'k2' => $this; }, 2), new RewindableGenerator(function () { return new \EmptyIterator(); @@ -339,7 +339,7 @@ protected function getLazyContextService() protected function getLazyContextIgnoreInvalidRefService() { return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () { - yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + yield 0 => ($this->services['foo.baz'] ?? $this->get('foo.baz')); if ($this->has('invalid')) { yield 1 => $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE); } @@ -364,7 +364,7 @@ protected function getMethodCall1Service() $this->services['method_call1'] = $instance = new \Bar\FooClass(); - $instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}); + $instance->setBar(($this->services['foo'] ?? $this->get('foo'))); $instance->setBar($this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)); if ($this->has('foo3')) { $instance->setBar($this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE)); @@ -387,7 +387,7 @@ protected function getMethodCall1Service() */ protected function getNewFactoryServiceService() { - $this->services['new_factory_service'] = $instance = ${($_ = isset($this->services['new_factory']) ? $this->services['new_factory'] : $this->getNewFactoryService()) && false ?: '_'}->getInstance(); + $this->services['new_factory_service'] = $instance = ($this->services['new_factory'] ?? $this->getNewFactoryService())->getInstance(); $instance->foo = 'bar'; @@ -423,7 +423,7 @@ protected function getConfiguratorServiceService() { $this->services['configurator_service'] = $instance = new \ConfClass(); - $instance->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'}); + $instance->setFoo(($this->services['baz'] ?? $this->get('baz'))); return $instance; } @@ -479,7 +479,7 @@ protected function getInlinedService() $this->services['inlined'] = $instance = new \Bar(); $instance->pub = 'pub'; - $instance->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'}); + $instance->setBaz(($this->services['baz'] ?? $this->get('baz'))); return $instance; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 78d1e15edbf5a..58e61f712f52b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -83,7 +83,7 @@ public function isCompiled() */ protected function getBarService() { - $a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + $a = ($this->services['foo.baz'] ?? $this->get('foo.baz')); $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar')); @@ -104,7 +104,7 @@ protected function getBazService() { $this->services['baz'] = $instance = new \Baz(); - $instance->setFoo(${($_ = isset($this->services['foo_with_inline']) ? $this->services['foo_with_inline'] : $this->get('foo_with_inline')) && false ?: '_'}); + $instance->setFoo(($this->services['foo_with_inline'] ?? $this->get('foo_with_inline'))); return $instance; } @@ -120,7 +120,7 @@ protected function getBazService() protected function getClosureProxyService() { return $this->services['closure_proxy'] = new \BarClass(/** @closure-proxy BarClass::getBaz */ function () { - return ${($_ = isset($this->services['closure_proxy']) ? $this->services['closure_proxy'] : $this->get('closure_proxy')) && false ?: '_'}->getBaz(); + return ($this->services['closure_proxy'] ?? $this->get('closure_proxy'))->getBaz(); }); } @@ -135,7 +135,7 @@ protected function getClosureProxyService() protected function getConfiguredServiceService() { $a = new \ConfClass(); - $a->setFoo(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'}); + $a->setFoo(($this->services['baz'] ?? $this->get('baz'))); $this->services['configured_service'] = $instance = new \stdClass(); @@ -214,7 +214,7 @@ protected function getDeprecatedServiceService() */ protected function getFactoryServiceService() { - return $this->services['factory_service'] = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}->getInstance(); + return $this->services['factory_service'] = ($this->services['foo.baz'] ?? $this->get('foo.baz'))->getInstance(); } /** @@ -240,14 +240,14 @@ protected function getFactoryServiceSimpleService() */ protected function getFooService() { - $a = ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + $a = ($this->services['foo.baz'] ?? $this->get('foo.baz')); $this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this); $instance->foo = 'bar'; $instance->moo = $a; $instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar'); - $instance->setBar(${($_ = isset($this->services['bar']) ? $this->services['bar'] : $this->get('bar')) && false ?: '_'}); + $instance->setBar(($this->services['bar'] ?? $this->get('bar'))); $instance->initialize(); sc_configure($instance); @@ -296,7 +296,7 @@ protected function getFooWithInlineService() $this->services['foo_with_inline'] = $instance = new \Foo(); $a->pub = 'pub'; - $a->setBaz(${($_ = isset($this->services['baz']) ? $this->services['baz'] : $this->get('baz')) && false ?: '_'}); + $a->setBaz(($this->services['baz'] ?? $this->get('baz'))); $instance->setBar($a); @@ -314,7 +314,7 @@ protected function getFooWithInlineService() protected function getLazyContextService() { return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () { - yield 'k1' => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + yield 'k1' => ($this->services['foo.baz'] ?? $this->get('foo.baz')); yield 'k2' => $this; }, 2), new RewindableGenerator(function () { return new \EmptyIterator(); @@ -332,7 +332,7 @@ protected function getLazyContextService() protected function getLazyContextIgnoreInvalidRefService() { return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () { - yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'}; + yield 0 => ($this->services['foo.baz'] ?? $this->get('foo.baz')); }, 1), new RewindableGenerator(function () { return new \EmptyIterator(); }, 0)); @@ -352,7 +352,7 @@ protected function getMethodCall1Service() $this->services['method_call1'] = $instance = new \Bar\FooClass(); - $instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}); + $instance->setBar(($this->services['foo'] ?? $this->get('foo'))); $instance->setBar(NULL); $instance->setBar(($this->get("foo")->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default")))); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php index f09561d8f4e1f..4d282d1a6ddd1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php @@ -64,7 +64,7 @@ protected function getBarService() $this->services['bar'] = $instance = new \stdClass(); $instance->foo = array(0 => /** @closure-proxy Symfony\Component\DependencyInjection\Tests\Fixtures\ContainerVoid\Foo::withVoid */ function (): void { - ${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->withVoid(); + ($this->services['foo'] ?? $this->get('foo'))->withVoid(); }); return $instance; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index 651547430bcf7..98305c1a1df6d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -71,7 +71,7 @@ public function isCompiled() */ protected function getBarServiceService() { - return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'}); + return $this->services['bar_service'] = new \stdClass(($this->services['baz_service'] ?? $this->getBazServiceService())); } /** @@ -85,9 +85,9 @@ protected function getBarServiceService() protected function getFooServiceService() { return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\ServiceLocator(array('bar' => function () { - return ${($_ = isset($this->services['bar_service']) ? $this->services['bar_service'] : $this->get('bar_service')) && false ?: '_'}; - }, 'baz' => function () { - $f = function (\stdClass $v) { return $v; }; return $f(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'}); + return ($this->services['bar_service'] ?? $this->get('bar_service')); + }, 'baz' => function (): \stdClass { + return ($this->services['baz_service'] ?? $this->getBazServiceService()); }, 'nil' => function () { return NULL; })); @@ -143,7 +143,7 @@ protected function getTranslator_Loader3Service() protected function getTranslator1Service() { return $this->services['translator_1'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_1' => function () { - return ${($_ = isset($this->services['translator.loader_1']) ? $this->services['translator.loader_1'] : $this->get('translator.loader_1')) && false ?: '_'}; + return ($this->services['translator.loader_1'] ?? $this->get('translator.loader_1')); }))); } @@ -158,10 +158,10 @@ protected function getTranslator1Service() protected function getTranslator2Service() { $this->services['translator_2'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_2' => function () { - return ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->get('translator.loader_2')) && false ?: '_'}; + return ($this->services['translator.loader_2'] ?? $this->get('translator.loader_2')); }))); - $instance->addResource('db', ${($_ = isset($this->services['translator.loader_2']) ? $this->services['translator.loader_2'] : $this->get('translator.loader_2')) && false ?: '_'}, 'nl'); + $instance->addResource('db', ($this->services['translator.loader_2'] ?? $this->get('translator.loader_2')), 'nl'); return $instance; } @@ -176,10 +176,10 @@ protected function getTranslator2Service() */ protected function getTranslator3Service() { - $a = ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->get('translator.loader_3')) && false ?: '_'}; + $a = ($this->services['translator.loader_3'] ?? $this->get('translator.loader_3')); $this->services['translator_3'] = $instance = new \Symfony\Component\DependencyInjection\Tests\Fixtures\StubbedTranslator(new \Symfony\Component\DependencyInjection\ServiceLocator(array('translator.loader_3' => function () { - return ${($_ = isset($this->services['translator.loader_3']) ? $this->services['translator.loader_3'] : $this->get('translator.loader_3')) && false ?: '_'}; + return ($this->services['translator.loader_3'] ?? $this->get('translator.loader_3')); }))); $instance->addResource('db', $a, 'nl'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index d6e0e57205f47..1df28c328a58a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -65,7 +65,7 @@ public function isCompiled() */ protected function getBarServiceService() { - return $this->services['bar_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'}); + return $this->services['bar_service'] = new \stdClass(($this->services['baz_service'] ?? $this->getBazServiceService())); } /** @@ -78,7 +78,7 @@ protected function getBarServiceService() */ protected function getFooServiceService() { - return $this->services['foo_service'] = new \stdClass(${($_ = isset($this->services['baz_service']) ? $this->services['baz_service'] : $this->getBazServiceService()) && false ?: '_'}); + return $this->services['foo_service'] = new \stdClass(($this->services['baz_service'] ?? $this->getBazServiceService())); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index 9179b270b1419..81506dae44a0d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -84,14 +84,14 @@ protected function getSymfony_Component_DependencyInjection_Tests_Fixtures_TestS */ protected function getFooServiceService() { - return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber(new \Symfony\Component\DependencyInjection\ServiceLocator(array('Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => function () { - $f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->getAutowired_Symfony_Component_DependencyInjection_Tests_Fixtures_CustomDefinitionService()) && false ?: '_'}); - }, 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => function () { - $f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')) && false ?: '_'}); - }, 'bar' => function () { - $f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')) && false ?: '_'}); - }, 'baz' => function () { - $f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition']) ? $this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] : $this->getAutowired_Symfony_Component_DependencyInjection_Tests_Fixtures_CustomDefinitionService()) && false ?: '_'}); + return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber(new \Symfony\Component\DependencyInjection\ServiceLocator(array('Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => function (): \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition { + return ($this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] ?? $this->getAutowired_Symfony_Component_DependencyInjection_Tests_Fixtures_CustomDefinitionService()); + }, 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => function (): \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber { + return ($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] ?? $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')); + }, 'bar' => function (): \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition { + return ($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] ?? $this->get('Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber')); + }, 'baz' => function (): \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition { + return ($this->services['autowired.Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition'] ?? $this->getAutowired_Symfony_Component_DependencyInjection_Tests_Fixtures_CustomDefinitionService()); }))); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 003cd714b1fa9..66fe419b9d806 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -45,7 +45,6 @@ public function testTypeConversions($key, $value, $supported) /** * @dataProvider getTypeConversions - * @requires PHP 5.6.1 * This test illustrates where our conversions differs from INI_SCANNER_TYPED introduced in PHP 5.6.1 */ public function testTypeConversionsWithNativePhp($key, $value, $supported) diff --git a/src/Symfony/Component/Finder/CHANGELOG.md b/src/Symfony/Component/Finder/CHANGELOG.md index 9b88b452ffc04..7361fb1940798 100644 --- a/src/Symfony/Component/Finder/CHANGELOG.md +++ b/src/Symfony/Component/Finder/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * removed `ExceptionInterface` + * removed `Symfony\Component\Finder\Iterator\FilterIterator` 3.4.0 ----- diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index b43b88d98df79..db6d4f2db07e1 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -19,7 +19,7 @@ * * @author Fabien Potencier */ -class CustomFilterIterator extends FilterIterator +class CustomFilterIterator extends \FilterIterator { private $filters = array(); diff --git a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php index 0f2d48f39ef99..2ccaf93f319e1 100644 --- a/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php @@ -18,7 +18,7 @@ * * @author Fabien Potencier */ -class DateRangeFilterIterator extends FilterIterator +class DateRangeFilterIterator extends \FilterIterator { private $comparators = array(); diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index f78c71ed415cc..1c956e97b5e65 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -16,7 +16,7 @@ * * @author Fabien Potencier */ -class DepthRangeFilterIterator extends FilterIterator +class DepthRangeFilterIterator extends \FilterIterator { private $minDepth = 0; diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index 3f5a5dfeb133c..8e240f9fe6ae3 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -16,7 +16,7 @@ * * @author Fabien Potencier */ -class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator +class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator { private $iterator; private $isRecursive; diff --git a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php index f50fd82c345f4..d1c0ebaca6f64 100644 --- a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php @@ -16,7 +16,7 @@ * * @author Fabien Potencier */ -class FileTypeFilterIterator extends FilterIterator +class FileTypeFilterIterator extends \FilterIterator { const ONLY_FILES = 1; const ONLY_DIRECTORIES = 2; diff --git a/src/Symfony/Component/Finder/Iterator/FilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilterIterator.php deleted file mode 100644 index a182f10eb8ded..0000000000000 --- a/src/Symfony/Component/Finder/Iterator/FilterIterator.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Iterator; - -/** - * This iterator just overrides the rewind method in order to correct a PHP bug, - * which existed before version 5.5.23/5.6.7. - * - * @see https://bugs.php.net/68557 - * - * @author Alex Bogomazov - * - * @deprecated since 3.4, to be removed in 4.0. - */ -abstract class FilterIterator extends \FilterIterator -{ - /** - * This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after - * rewind in some cases. - * - * @see FilterIterator::rewind() - */ - public function rewind() - { - if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) { - parent::rewind(); - - return; - } - - $iterator = $this; - while ($iterator instanceof \OuterIterator) { - $innerIterator = $iterator->getInnerIterator(); - - if ($innerIterator instanceof RecursiveDirectoryIterator) { - // this condition is necessary for iterators to work properly with non-local filesystems like ftp - if ($innerIterator->isRewindable()) { - $innerIterator->next(); - $innerIterator->rewind(); - } - } elseif ($innerIterator instanceof \FilesystemIterator) { - $innerIterator->next(); - $innerIterator->rewind(); - } - - $iterator = $innerIterator; - } - - parent::rewind(); - } -} diff --git a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php b/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php index 162dc1410b979..44f4fb35cb98b 100644 --- a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php @@ -16,7 +16,7 @@ * * @author Fabien Potencier */ -abstract class MultiplePcreFilterIterator extends FilterIterator +abstract class MultiplePcreFilterIterator extends \FilterIterator { protected $matchRegexps = array(); protected $noMatchRegexps = array(); diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index 5bea38e69a772..f56990aa70d31 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -118,11 +118,6 @@ public function rewind() return; } - // @see https://bugs.php.net/68557 - if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) { - parent::next(); - } - parent::rewind(); } diff --git a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php index 3d3140a6ae45a..9262a38e663b7 100644 --- a/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php @@ -18,7 +18,7 @@ * * @author Fabien Potencier */ -class SizeRangeFilterIterator extends FilterIterator +class SizeRangeFilterIterator extends \FilterIterator { private $comparators = array(); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php deleted file mode 100644 index 8b1a4482bae2e..0000000000000 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Tests\Iterator; - -/** - * @author Alex Bogomazov - * - * @group legacy - */ -class FilterIteratorTest extends RealIteratorTestCase -{ - public function testFilterFilesystemIterators() - { - $i = new \FilesystemIterator($this->toAbsolute()); - - // it is expected that there are test.py test.php in the tmpDir - $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i)); - $i->expects($this->any()) - ->method('accept') - ->will($this->returnCallback(function () use ($i) { - return (bool) preg_match('/\.php/', (string) $i->current()); - }) - ); - - $c = 0; - foreach ($i as $item) { - ++$c; - } - - $this->assertEquals(1, $c); - - $i->rewind(); - - $c = 0; - foreach ($i as $item) { - ++$c; - } - - // This would fail in php older than 5.5.23/5.6.7 with \FilterIterator - // but works with Symfony\Component\Finder\Iterator\FilterIterator - // see https://bugs.php.net/68557 - $this->assertEquals(1, $c); - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 7d29b6b88c1af..c9c1854e3aef9 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -43,8 +43,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer /** * Whether to parse by appending a pipe "|" to the parse format. * - * This only works as of PHP 5.3.7. - * * @var bool */ private $parseUsingPipe; diff --git a/src/Symfony/Component/Form/FormError.php b/src/Symfony/Component/Form/FormError.php index e4e50a873c942..88a4ad6ceec55 100644 --- a/src/Symfony/Component/Form/FormError.php +++ b/src/Symfony/Component/Form/FormError.php @@ -185,10 +185,6 @@ public function serialize() */ public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized, array('allowed_classes' => false)); - } else { - list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized); - } + list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized, array('allowed_classes' => false)); } } diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 4962256376d71..536e110788946 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1576,9 +1576,6 @@ public function isMethodCacheable() public function getContent($asResource = false) { $currentContentIsResource = is_resource($this->content); - if (PHP_VERSION_ID < 50600 && false === $this->content) { - throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.'); - } if (true === $asResource) { if ($currentContentIsResource) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index edaed2533b1bd..29fac6adaf989 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -104,9 +104,6 @@ public function testConstructorWithDateTime() $this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); } - /** - * @requires PHP 5.5 - */ public function testConstructorWithDateTimeImmutable() { $expire = new \DateTimeImmutable(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index dfc37459ab971..7cb59dc1cd819 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1051,21 +1051,6 @@ public function testContentAsResource() $this->assertEquals('My other content', $req->getContent()); } - /** - * @expectedException \LogicException - * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider - */ - public function testGetContentCantBeCalledTwiceWithResources($first, $second) - { - if (PHP_VERSION_ID >= 50600) { - $this->markTestSkipped('PHP >= 5.6 allows to open php://input several times.'); - } - - $req = new Request(); - $req->getContent($first); - $req->getContent($second); - } - public function getContentCantBeCalledTwiceWithResourcesProvider() { return array( @@ -1076,7 +1061,6 @@ public function getContentCantBeCalledTwiceWithResourcesProvider() /** * @dataProvider getContentCanBeCalledTwiceWithResourcesProvider - * @requires PHP 5.6 */ public function testGetContentCanBeCalledTwiceWithResources($first, $second) { diff --git a/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php b/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php index fd53f0bcef3b3..3bb574b5ffa58 100644 --- a/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php +++ b/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php @@ -72,11 +72,7 @@ public function serialize() public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - $unserialized = unserialize($serialized, array('allowed_classes' => false)); - } else { - $unserialized = unserialize($serialized); - } + $unserialized = unserialize($serialized, array('allowed_classes' => false)); $this->prefix = $unserialized['prefix']; $this->variables = $unserialized['variables']; diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php index d1e7af206804b..a86a5675e3321 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php @@ -18,30 +18,6 @@ */ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface { - /** - * If the ...$arg functionality is available. - * - * Requires at least PHP 5.6.0 or HHVM 3.9.1 - * - * @var bool - */ - private $supportsVariadic; - - /** - * If the reflection supports the getType() method to resolve types. - * - * Requires at least PHP 7.0.0 or HHVM 3.11.0 - * - * @var bool - */ - private $supportsParameterType; - - public function __construct() - { - $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic'); - $this->supportsParameterType = method_exists('ReflectionParameter', 'getType'); - } - /** * {@inheritdoc} */ @@ -73,7 +49,7 @@ public function createArgumentMetadata($controller) */ private function isVariadic(\ReflectionParameter $parameter) { - return $this->supportsVariadic && $parameter->isVariadic(); + return $parameter->isVariadic(); } /** @@ -109,21 +85,15 @@ private function getDefaultValue(\ReflectionParameter $parameter) */ private function getType(\ReflectionParameter $parameter) { - if ($this->supportsParameterType) { - if (!$type = $parameter->getType()) { - return; - } - $typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); - if ('array' === $typeName && !$type->isBuiltin()) { - // Special case for HHVM with variadics - return; - } - - return $typeName; + if (!$type = $parameter->getType()) { + return; } - - if (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $info)) { - return $info[1]; + $typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); + if ('array' === $typeName && !$type->isBuiltin()) { + // Special case for HHVM with variadics + return; } + + return $typeName; } } diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 9eefba210a41b..6f70f0d5072b0 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -63,11 +63,7 @@ public function serialize() public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); - } else { - $this->fileLinkFormat = unserialize($serialized); - } + $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); } private function getFileLinkFormat() diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 69b27194ddb48..2c6e3250f7935 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -766,11 +766,9 @@ public static function stripComments($source) $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(); - } + // 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/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php index 0804139030128..6a5926f85c7e3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php @@ -152,9 +152,6 @@ public function testGetArgumentsInjectsExtendingRequest() $this->assertEquals(array($request), self::$resolver->getArguments($request, $controller), '->getArguments() injects the request when extended'); } - /** - * @requires PHP 5.6 - */ public function testGetVariadicArguments() { $request = Request::create('/'); @@ -166,7 +163,6 @@ public function testGetVariadicArguments() } /** - * @requires PHP 5.6 * @expectedException \InvalidArgumentException */ public function testGetVariadicArgumentsWithoutArrayInRequest() @@ -180,7 +176,6 @@ public function testGetVariadicArgumentsWithoutArrayInRequest() } /** - * @requires PHP 5.6 * @expectedException \InvalidArgumentException */ public function testGetArgumentWithoutArray() @@ -210,9 +205,6 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() self::$resolver->getArguments($request, $controller); } - /** - * @requires PHP 7.1 - */ public function testGetNullableArguments() { $request = Request::create('/'); @@ -224,9 +216,6 @@ public function testGetNullableArguments() $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); } - /** - * @requires PHP 7.1 - */ public function testGetNullableArgumentsWithDefaults() { $request = Request::create('/'); diff --git a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index b4b449f358611..2ddc6e7a5ee10 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -84,9 +84,6 @@ public function testSignature5() ), $arguments); } - /** - * @requires PHP 5.6 - */ public function testVariadicSignature() { $arguments = $this->factory->createArgumentMetadata(array(new VariadicController(), 'action')); @@ -97,9 +94,6 @@ public function testVariadicSignature() ), $arguments); } - /** - * @requires PHP 7.0 - */ public function testBasicTypesSignature() { $arguments = $this->factory->createArgumentMetadata(array(new BasicTypesController(), 'action')); @@ -111,9 +105,6 @@ public function testBasicTypesSignature() ), $arguments); } - /** - * @requires PHP 7.1 - */ public function testNullableTypesSignature() { $arguments = $this->factory->createArgumentMetadata(array(new NullableController(), 'action')); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 35a377da2e899..9c5cd9fdd11c0 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -243,9 +243,6 @@ public function formatProvider() return $formatData; } - /** - * @requires PHP 5.5.10 - */ public function testFormatUtcAndGmtAreSplit() { $pattern = "yyyy.MM.dd 'at' HH:mm:ss zzz"; @@ -318,7 +315,6 @@ public function formatWithTimezoneProvider() /** * @dataProvider formatTimezoneProvider - * @requires PHP 5.5 */ public function testFormatTimezone($pattern, $timezone, $expected) { @@ -432,8 +428,8 @@ public function testFormatWithDateTimeZoneGmt() public function testFormatWithDateTimeZoneGmtOffset() { - if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) { - $this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.'); + if (defined('HHVM_VERSION_ID')) { + $this->markTestSkipped('See https://github.com/facebook/hhvm/issues/5875'); } $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT+03:00'), IntlDateFormatter::GREGORIAN, 'zzzz'); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 6019544a19e8c..975824b5057e0 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -195,10 +195,6 @@ public function setValue(&$objectOrArray, $propertyPath, $value) $overwrite = true; try { - if (PHP_VERSION_ID < 70000 && false === self::$previousErrorHandler) { - self::$previousErrorHandler = set_error_handler(self::$errorHandler); - } - for ($i = count($propertyValues) - 1; 0 <= $i; --$i) { $zval = $propertyValues[$i]; unset($propertyValues[$i]); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index 573528c012f55..4a2cf3fc836e2 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -85,7 +85,6 @@ public function typesProvider() /** * @dataProvider php7TypesProvider - * @requires PHP 7.0 */ public function testExtractPhp7Type($property, array $type = null) { @@ -104,7 +103,6 @@ public function php7TypesProvider() /** * @dataProvider php71TypesProvider - * @requires PHP 7.1 */ public function testExtractPhp71Type($property, array $type = null) { diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index a3cbdd056f37c..4805bdaee1c1b 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -73,11 +73,7 @@ public function serialize() */ public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - $data = unserialize($serialized, array('allowed_classes' => false)); - } else { - $data = unserialize($serialized); - } + $data = unserialize($serialized, array('allowed_classes' => false)); $this->variables = $data['vars']; $this->staticPrefix = $data['path_prefix']; diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index 4dc41e16cd392..b5e02e23b329c 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -64,10 +64,9 @@ public function load($file, $type = null) $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(); - } + + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); return $collection; } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 137d97548d20d..6d1b1fbec9f8f 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -116,11 +116,7 @@ public function serialize() */ public function unserialize($serialized) { - if (PHP_VERSION_ID >= 70000) { - $data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class))); - } else { - $data = unserialize($serialized); - } + $data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class))); $this->path = $data['path']; $this->host = $data['host']; $this->defaults = $data['defaults']; diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index 5d54f9f99f665..2ec3cc6fc9956 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -35,9 +35,6 @@ public function testLoad() $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); } - /** - * @requires PHP 5.4 - */ public function testLoadTraitWithClassConstant() { $this->reader->expects($this->never())->method('getClassAnnotation'); @@ -54,9 +51,6 @@ public function testLoadFileWithoutStartTag() $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/NoStartTagClass.php'); } - /** - * @requires PHP 5.6 - */ public function testLoadVariadic() { $route = new Route(array('path' => '/path/to/{id}')); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index e9ca7ce570e59..46a1e006fbd4c 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -69,7 +69,7 @@ public function __construct($associative = false, $depth = 512) * If not specified, this method will use the default set in JsonDecode::__construct * * json_decode_options: integer - * Specifies additional options as per documentation for json_decode. Only supported with PHP 5.4.0 and higher + * Specifies additional options as per documentation for json_decode. * * @return mixed * diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index ee0a159f06f8a..8961e9fc99021 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -146,9 +146,6 @@ public function testConstructorDenormalizeWithOptionalDefaultArgument() $this->assertEquals('test', $obj->getBar()); } - /** - * @requires PHP 5.6 - */ public function testConstructorDenormalizeWithVariadicArgument() { $obj = $this->normalizer->denormalize( @@ -157,9 +154,6 @@ public function testConstructorDenormalizeWithVariadicArgument() $this->assertEquals(array(1, 2, 3), $obj->getFoo()); } - /** - * @requires PHP 5.6 - */ public function testConstructorDenormalizeWithMissingVariadicArgument() { $obj = $this->normalizer->denormalize( diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index 08b538e1fec83..32bdaf5181199 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -28,7 +28,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti if (isset($options['json_encoding'])) { $flags = $options['json_encoding']; } else { - $flags = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; + $flags = JSON_PRETTY_PRINT; } return json_encode($messages->all($domain), $flags); diff --git a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php index 6675caa0478b9..270e18961f746 100644 --- a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php @@ -68,7 +68,7 @@ private static function getParameters($function, $class) if ($v->isPassedByReference()) { $k = '&'.$k; } - if (method_exists($v, 'isVariadic') && $v->isVariadic()) { + if ($v->isVariadic()) { $variadic .= $k; } else { $params[] = $k; diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 9811eab5e7e48..a436f3b1842fc 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -186,7 +186,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra foreach ($c->getParameters() as $v) { $k = '$'.$v->name; - if (method_exists($v, 'isVariadic') && $v->isVariadic()) { + if ($v->isVariadic()) { $k = '...'.$k; } if ($v->isPassedByReference()) { @@ -241,12 +241,8 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st 'allowsNull' => 'allowsNull', )); - if (method_exists($c, 'getType')) { - if ($v = $c->getType()) { - $a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString(); - } - } elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $c, $v)) { - $a[$prefix.'typeHint'] = $v[1]; + if ($v = $c->getType()) { + $a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString(); } if (isset($a[$prefix.'typeHint'])) { @@ -258,17 +254,13 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st try { $a[$prefix.'default'] = $v = $c->getDefaultValue(); - if (method_exists($c, 'isDefaultValueConstant') && $c->isDefaultValueConstant()) { + if ($c->isDefaultValueConstant()) { $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); } if (null === $v) { unset($a[$prefix.'allowsNull']); } } catch (\ReflectionException $e) { - if (isset($a[$prefix.'typeHint']) && $c->allowsNull() && !class_exists('ReflectionNamedType', false)) { - $a[$prefix.'default'] = null; - unset($a[$prefix.'allowsNull']); - } } return $a; diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php index 105d5638ee1bc..1dacce59bc180 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php @@ -151,9 +151,6 @@ public function provideFilter() ); } - /** - * @requires PHP 7.0 - */ public function testAnonymousClass() { $c = eval('return new class extends stdClass { private $foo = "foo"; };'); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index 5495a78e40f34..4eada28c01da4 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -101,9 +101,6 @@ public function testReflectionParameter() ); } - /** - * @requires PHP 7.0 - */ public function testReflectionParameterScalar() { $f = eval('return function (int $a) {};'); @@ -121,9 +118,6 @@ public function testReflectionParameterScalar() ); } - /** - * @requires PHP 7.0 - */ public function testReturnType() { $f = eval('return function ():int {};'); @@ -143,9 +137,6 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest" ); } - /** - * @requires PHP 7.0 - */ public function testGenerator() { if (extension_loaded('xdebug')) { diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index 41785d4b563c6..c2291c6949668 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -401,7 +401,6 @@ public function testRefsInProperties() /** * @runInSeparateProcess * @preserveGlobalState disabled - * @requires PHP 5.6 */ public function testSpecialVars56() { @@ -460,47 +459,6 @@ public function testGlobals() 2 => &1 array:1 [&1] ] -EOTXT - , - $out - ); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testBuggyRefs() - { - if (PHP_VERSION_ID >= 50600) { - $this->markTestSkipped('PHP 5.6 fixed refs counting'); - } - - $var = $this->getSpecialVars(); - $var = $var[0]; - - $dumper = new CliDumper(); - $dumper->setColors(false); - $cloner = new VarCloner(); - - $data = $cloner->cloneVar($var)->withMaxDepth(3); - $out = ''; - $dumper->dump($data, function ($line, $depth) use (&$out) { - if ($depth >= 0) { - $out .= str_repeat(' ', $depth).$line."\n"; - } - }); - - $this->assertSame( - <<<'EOTXT' -array:1 [ - 0 => array:1 [ - 0 => array:1 [ - 0 => array:1 [ …1] - ] - ] -] - EOTXT , $out diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index a26ffbf9e44c6..5e46fb99bdae0 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -570,12 +570,7 @@ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $ $expected = new \DateTime($yaml); $expected->setTimeZone(new \DateTimeZone('UTC')); $expected->setDate($year, $month, $day); - - if (PHP_VERSION_ID >= 70100) { - $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); - } else { - $expected->setTime($hour, $minute, $second); - } + $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); $date = Inline::parse($yaml, Yaml::PARSE_DATETIME); $this->assertEquals($expected, $date);