From 35e0845f237df0ab065c43a7621ce2e5946a08c6 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 30 Nov 2014 21:18:40 +0000 Subject: [PATCH] [3.0] Removed some old hacks --- README.md | 21 +--- autoload.php.dist | 6 +- ...egacyUniqueEntityValidator2Dot4ApiTest.php | 26 ----- ...gacyUniqueEntityValidatorLegacyApiTest.php | 26 ----- .../Bridge/Twig/Command/LintCommand.php | 4 - .../Bridge/Twig/Extension/CodeExtension.php | 6 +- .../Bridge/Twig/Tests/Node/DumpNodeTest.php | 4 +- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 6 +- .../Node/SearchAndRenderBlockNodeTest.php | 6 +- .../Bridge/Twig/Tests/Node/TransNodeTest.php | 12 +- .../FrameworkBundle/Command/ServerCommand.php | 2 +- .../Command/ServerRunCommand.php | 2 +- .../Command/YamlLintCommand.php | 4 - .../Console/Descriptor/JsonDescriptor.php | 4 - .../DependencyInjection/Configuration.php | 9 +- .../Templating/Helper/CodeHelper.php | 6 +- .../Console/Descriptor/JsonDescriptorTest.php | 7 -- .../DependencyInjection/ConfigurationTest.php | 2 +- .../FrameworkExtensionTest.php | 18 +-- .../SecurityRoutingIntegrationTest.php | 8 -- .../ClassLoader/ClassCollectionLoader.php | 5 +- .../ClassLoader/ClassMapGenerator.php | 10 +- .../ClassLoader/DebugClassLoader.php | 2 +- .../ClassLoader/DebugUniversalClassLoader.php | 2 +- .../Tests/ClassCollectionLoaderTest.php | 18 --- .../Tests/ClassMapGeneratorTest.php | 9 +- .../Console/Descriptor/TextDescriptor.php | 4 - .../Component/Debug/DebugClassLoader.php | 2 +- src/Symfony/Component/Debug/ErrorHandler.php | 43 +------ .../Component/Debug/ExceptionHandler.php | 2 +- .../ClassNotFoundFatalErrorHandler.php | 2 +- src/Symfony/Component/DomCrawler/Crawler.php | 10 +- .../Component/ExpressionLanguage/Parser.php | 4 - .../DateTimeToStringTransformer.php | 9 +- .../Csrf/CsrfProvider/DefaultCsrfProvider.php | 6 +- .../DateTimeToStringTransformerTest.php | 10 +- .../CsrfProvider/DefaultCsrfProviderTest.php | 4 - .../Component/HttpFoundation/JsonResponse.php | 29 +---- .../Storage/Handler/NativeSessionHandler.php | 11 +- .../Session/Storage/NativeSessionStorage.php | 38 +----- .../Storage/PhpBridgeSessionStorage.php | 4 - .../Session/Storage/Proxy/AbstractProxy.php | 32 +---- .../Handler/NativeFileSessionHandlerTest.php | 9 +- .../Handler/NativeSessionHandlerTest.php | 11 +- .../Storage/NativeSessionStorageTest.php | 36 +----- .../Storage/PhpBridgeSessionStorageTest.php | 30 +---- .../Storage/Proxy/AbstractProxyTest.php | 78 +------------ .../Storage/Proxy/SessionHandlerProxyTest.php | 8 +- .../DataCollector/DumpDataCollector.php | 7 +- .../Fragment/HIncludeFragmentRenderer.php | 6 +- .../Controller/ControllerResolverTest.php | 14 +-- .../Data/Bundle/Reader/JsonBundleReader.php | 29 +---- .../Data/Bundle/Writer/JsonBundleWriter.php | 12 +- .../Intl/DateFormatter/IntlDateFormatter.php | 31 ++--- .../Intl/NumberFormatter/NumberFormatter.php | 28 +---- .../Bundle/Writer/JsonBundleWriterTest.php | 8 -- .../AbstractIntlDateFormatterTest.php | 110 ++++-------------- .../DateFormatter/IntlDateFormatterTest.php | 7 +- .../AbstractNumberFormatterTest.php | 24 +--- .../Core/Encoder/BCryptPasswordEncoder.php | 4 - .../Core/Encoder/Pbkdf2PasswordEncoder.php | 26 +---- .../Encoder/BCryptPasswordEncoderTest.php | 11 -- .../Security/Core/Util/SecureRandom.php | 4 +- .../NativeSessionTokenStorageTest.php | 4 - .../NativeSessionTokenStorage.php | 6 +- .../Serializer/Encoder/JsonDecode.php | 6 +- .../Serializer/Encoder/JsonEncoder.php | 19 +-- .../Component/Templating/PhpEngine.php | 16 +-- .../Translation/Dumper/JsonFileDumper.php | 4 - .../Tests/Dumper/JsonFileDumperTest.php | 4 - .../AbstractComparisonValidatorTestCase.php | 4 - .../Constraints/IdenticalToValidatorTest.php | 6 +- .../NotIdenticalToValidatorTest.php | 6 +- .../Tests/Constraints/RangeValidatorTest.php | 20 ++-- .../Validator/LegacyValidator2Dot5ApiTest.php | 9 -- .../LegacyValidatorLegacyApiTest.php | 9 -- .../Validator/Tests/ValidatorBuilderTest.php | 12 +- .../Component/Validator/ValidatorBuilder.php | 13 +-- .../Component/VarDumper/Cloner/VarCloner.php | 2 +- .../VarDumper/Tests/CliDumperTest.php | 2 +- .../VarDumper/Tests/HtmlDumperTest.php | 2 +- .../Yaml/Exception/ParseException.php | 7 +- .../Yaml/Tests/ParseExceptionTest.php | 12 +- 83 files changed, 131 insertions(+), 960 deletions(-) delete mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php delete mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php diff --git a/README.md b/README.md index 42607fbbfa..ebcbd8664a 100644 --- a/README.md +++ b/README.md @@ -4,32 +4,13 @@ README What is Symfony? ----------------- -Symfony is a PHP 5.3 full-stack web framework. It is written with speed and +Symfony is a PHP full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP. Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers. -Requirements ------------- - -Symfony is only supported on PHP 5.3.3 and up. - -Be warned that PHP versions before 5.3.8 are known to be buggy and might not -work for you: - - * before PHP 5.3.4, if you get "Notice: Trying to get property of - non-object", you've hit a known PHP bug (see - https://bugs.php.net/bug.php?id=52083 and - https://bugs.php.net/bug.php?id=50027); - - * before PHP 5.3.8, if you get an error involving annotations, you've hit a - known PHP bug (see https://bugs.php.net/bug.php?id=55156). - - * PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to - run Symfony (https://bugs.php.net/bug.php?id=62715) - Installation ------------ diff --git a/autoload.php.dist b/autoload.php.dist index c179857248..e2d7299b5c 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -1,8 +1,8 @@ = 50400 && gc_enabled()) { - // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+ - // https://bugs.php.net/bug.php?id=53976 +// Disabling Zend Garbage Collection to prevent segfaults +// https://bugs.php.net/bug.php?id=53976 +if (gc_enabled()) { gc_disable(); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php deleted file mode 100644 index 3e1151d520..0000000000 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.4 - * @author Bernhard Schussek - */ -class LegacyUniqueEntityValidator2Dot4ApiTest extends UniqueEntityValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_4; - } -} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php deleted file mode 100644 index 07382d90e9..0000000000 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidatorLegacyApiTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.4 - * @author Bernhard Schussek - */ -class LegacyUniqueEntityValidatorLegacyApiTest extends UniqueEntityValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 276b6b9672..8f45251260 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -11,10 +11,6 @@ namespace Symfony\Bridge\Twig\Command; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index d7b7898a72..3349b4b0c0 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -174,11 +174,7 @@ class CodeExtension extends \Twig_Extension $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 1efe52d126..e080044c8e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -56,7 +56,7 @@ if ($this->env->isDebug()) { } EOTXT; - $expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); $this->assertSame($expected, $compiler->compile($node)->getSource()); } @@ -82,7 +82,7 @@ if ($this->env->isDebug()) { } EOTXT; - $expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $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 5f8ae11211..34b6de2a52 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -66,10 +66,6 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $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 60ef9edfb9..e08572e60c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -263,10 +263,6 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetter($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $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 df5eb559d8..476fc5fef1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -38,19 +38,11 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase } protected function getVariableGetterWithoutStrictCheck($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); - } - - return sprintf('$this->getContext($context, "%s", true)', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } protected function getVariableGetterWithStrictCheck($name) { - if (PHP_VERSION_ID >= 50400) { - return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); - } - - return sprintf('$this->getContext($context, "%s")', $name); + return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php index 4a94f99fe0..cbd5ec892f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php @@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand */ public function isEnabled() { - if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 01a1e4da7f..79d4aec6b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -30,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand */ public function isEnabled() { - if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php index 967c3b18a3..83d63f802f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php @@ -11,10 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Command; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 5dd2d405ee..2f2f8020dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -11,10 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 9354a54980..d635aae822 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -498,14 +498,7 @@ class Configuration implements ConfigurationInterface ->validate() ->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; }) ->then(function ($v) { - // This condition is duplicated in ValidatorBuilder. This - // duplication is necessary in order to know the desired - // API version already during container configuration - // (to adjust service classes etc.) - // See https://github.com/symfony/symfony/issues/11580 - $v['validation']['api'] = PHP_VERSION_ID < 50309 - ? '2.4' - : '2.5-bc'; + $v['validation']['api'] = '2.5-bc'; return $v; }) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 5ee9fb324d..65a4a1a2b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -166,11 +166,7 @@ class CodeHelper extends Helper } if (false !== $link = $this->getFileLink($file, $line)) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php index 7f7a0ae15c..ee03f65391 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php @@ -15,13 +15,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor; class JsonDescriptorTest extends AbstractDescriptorTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.'); - } - } - protected function getDescriptor() { return new JsonDescriptor(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 9a4ad2770a..0fdb592ca6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -131,7 +131,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase 'static_method' => array('loadValidatorMetadata'), 'translation_domain' => 'validators', 'strict_email' => false, - 'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc', + 'api' => '2.5-bc', ), 'annotations' => array( 'cache' => 'file', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index acc3cff6ba..4c4f14a4fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -295,11 +295,7 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); $this->assertSame('setApiVersion', $calls[6][0]); - if (PHP_VERSION_ID < 50309) { - $this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]); - } else { - $this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); - } + $this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); } public function testFullyConfiguredValidationService() @@ -448,11 +444,7 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertSame('setApiVersion', $calls[5][0]); // no cache, no annotations - if (PHP_VERSION_ID < 50309) { - $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]); - } else { - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } + $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); } /** @@ -472,11 +464,7 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertSame('setApiVersion', $calls[5][0]); // no cache, no annotations - if (PHP_VERSION_ID < 50309) { - $this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]); - } else { - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } + $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); } public function testFormsCanBeEnabledWithoutCsrfProtection() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index f86ec326af..3593b50743 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -30,10 +30,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); - } - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->insulate(); $client->request('GET', '/unprotected_resource'); @@ -46,10 +42,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); - } - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); $client->insulate(); diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 6bf4ebd545..8627516526 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -43,10 +43,7 @@ class ClassCollectionLoader self::$loaded[$name] = true; - $declared = array_merge(get_declared_classes(), get_declared_interfaces()); - if (function_exists('get_declared_traits')) { - $declared = array_merge($declared, get_declared_traits()); - } + $declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); if ($adaptive) { // don't include already declared classes diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 4c2aeab3ac..0151751be0 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,14 +11,6 @@ namespace Symfony\Component\ClassLoader; -if (!defined('SYMFONY_TRAIT')) { - if (PHP_VERSION_ID >= 50400) { - define('SYMFONY_TRAIT', T_TRAIT); - } else { - define('SYMFONY_TRAIT', 0); - } -} - /** * ClassMapGenerator. * @@ -117,7 +109,7 @@ class ClassMapGenerator break; case T_CLASS: case T_INTERFACE: - case SYMFONY_TRAIT: + case T_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { diff --git a/src/Symfony/Component/ClassLoader/DebugClassLoader.php b/src/Symfony/Component/ClassLoader/DebugClassLoader.php index 897919b20a..47bba2d45f 100644 --- a/src/Symfony/Component/ClassLoader/DebugClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugClassLoader.php @@ -107,7 +107,7 @@ class DebugClassLoader if ($file = $this->classFinder->findFile($class)) { require $file; - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (!class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)) { if (false !== strpos($class, '/')) { throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); } diff --git a/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php b/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php index 678f4e8b2a..19bb79fc01 100644 --- a/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php +++ b/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php @@ -55,7 +55,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader if ($file = $this->findFile($class)) { require $file; - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (!class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)) { throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); } } diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index e821e45063..5e5ee06fa7 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -22,12 +22,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase { public function testTraitDependencies() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/deps/traits.php'; $r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader'); @@ -100,12 +94,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase */ public function testClassWithTraitsReordering(array $classes) { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/ClassesWithParents/ATrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; @@ -148,12 +136,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase public function testFixClassWithTraitsOrdering() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Requires PHP > 5.4'); - - return; - } - require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/F.php'; require_once __DIR__.'/Fixtures/ClassesWithParents/G.php'; diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 88099258ec..77c861d9eb 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -102,18 +102,15 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase 'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php', 'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php', )), - ); - - if (PHP_VERSION_ID >= 50400) { - $data[] = array(__DIR__.'/Fixtures/php5.4', array( + array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php', 'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php', - )); - } + )), + ); return $data; } diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index fcefcd83f6..1ed60e1073 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -229,10 +229,6 @@ class TextDescriptor extends Descriptor */ private function formatDefaultValue($default) { - if (PHP_VERSION_ID < 50400) { - return str_replace('\/', '/', json_encode($default)); - } - return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index b70a4c4ac3..369e65818c 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -162,7 +162,7 @@ class DebugClassLoader ErrorHandler::unstackErrors(); - $exists = class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); if ('\\' === $class[0]) { $class = substr($class, 1); diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 48e4a2d69e..65b88a2b3e 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -357,12 +357,6 @@ class ErrorHandler $type &= $level | $this->screamedErrors; if ($type && ($log || $throw)) { - if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) { - $e = $context; // Whatever the signature of the method, - unset($e['GLOBALS'], $context); // $context is always a reference in 5.3 - $context = $e; - } - if ($throw) { if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { // Checking for class existence is a work around for https://bugs.php.net/42098 @@ -371,14 +365,6 @@ class ErrorHandler $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line); } - if (PHP_VERSION_ID <= 50407 && (PHP_VERSION_ID >= 50400 || PHP_VERSION_ID <= 50317)) { - // Exceptions thrown from error handlers are sometimes not caught by the exception - // handler and shutdown handlers are bypassed before 5.4.8/5.3.18. - // We temporarily re-enable display_errors to prevent any blank page related to this bug. - - $throw->errorHandlerCanary = new ErrorHandlerCanary(); - } - throw $throw; } @@ -401,7 +387,7 @@ class ErrorHandler $e['stack'] = debug_backtrace(true); // Provide object } } elseif ($trace) { - $e['stack'] = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false); + $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } } @@ -658,30 +644,3 @@ class ErrorHandler static::handleFatalError(); } } - -/** - * Private class used to work around https://bugs.php.net/54275 - * - * @author Nicolas Grekas - * - * @internal - */ -class ErrorHandlerCanary -{ - private static $displayErrors = null; - - public function __construct() - { - if (null === self::$displayErrors) { - self::$displayErrors = ini_set('display_errors', 1); - } - } - - public function __destruct() - { - if (null !== self::$displayErrors) { - ini_set('display_errors', self::$displayErrors); - self::$displayErrors = null; - } - } -} diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index cbe582eb24..56198af0f3 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -441,6 +441,6 @@ EOF; $str = iconv($charset, 'UTF-8', $str); } - return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8'); + return htmlspecialchars($str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } } diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index 0ba0bd4483..bc5275f3ae 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -191,6 +191,6 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface */ private function classExists($class) { - return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); } } diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 9471d54a9a..4f52f218b6 100755 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -581,15 +581,7 @@ class Crawler extends \SplObjectStorage $html = ''; foreach ($this->getNode(0)->childNodes as $child) { - if (PHP_VERSION_ID >= 50306) { - // node parameter was added to the saveHTML() method in PHP 5.3.6 - // @see http://php.net/manual/en/domdocument.savehtml.php - $html .= $child->ownerDocument->saveHTML($child); - } else { - $document = new \DOMDocument('1.0', 'UTF-8'); - $document->appendChild($document->importNode($child, true)); - $html .= rtrim($document->saveHTML()); - } + $html .= $child->ownerDocument->saveHTML($child); } return $html; diff --git a/src/Symfony/Component/ExpressionLanguage/Parser.php b/src/Symfony/Component/ExpressionLanguage/Parser.php index 3e769c6d4f..be884414a2 100644 --- a/src/Symfony/Component/ExpressionLanguage/Parser.php +++ b/src/Symfony/Component/ExpressionLanguage/Parser.php @@ -336,10 +336,6 @@ class Parser $node = new Node\GetAttrNode($node, $arg, $arguments, $type); } elseif ('[' === $token->value) { - if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && PHP_VERSION_ID < 50400) { - throw new SyntaxError('Array calls on a method call is only supported on PHP 5.4+', $token->cursor); - } - $this->stream->next(); $arg = $this->parseExpression(); $this->stream->expect(Token::PUNCTUATION_TYPE, ']'); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index f5ba9948d0..45936d51fd 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -61,17 +61,12 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * * @throws UnexpectedTypeException if a timezone is not a string */ - public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = null) + public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = true) { parent::__construct($inputTimezone, $outputTimezone); $this->generateFormat = $this->parseFormat = $format; - - // The pipe in the parser pattern only works as of PHP 5.3.7 - // See http://bugs.php.net/54316 - $this->parseUsingPipe = null === $parseUsingPipe - ? PHP_VERSION_ID >= 50307 - : $parseUsingPipe; + $this->parseUsingPipe = $parseUsingPipe || null === $parseUsingPipe; // See http://php.net/manual/en/datetime.createfromformat.php // The character "|" in the format makes sure that the parts of a date diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php index fd9110d3b1..aefc406d7b 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php @@ -73,11 +73,7 @@ class DefaultCsrfProvider implements CsrfProviderInterface */ protected function getSessionId() { - if (PHP_VERSION_ID >= 50400) { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - } elseif (!session_id()) { + if (PHP_SESSION_NONE === session_status()) { session_start(); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index dbcdad0f96..be0f451a90 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -30,6 +30,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase array('H:i:00', '16:05:00', '1970-01-01 16:05:00 UTC'), array('H:i', '16:05', '1970-01-01 16:05:00 UTC'), array('H', '16', '1970-01-01 16:00:00 UTC'), + array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'), // different day representations array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'), @@ -59,11 +60,6 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase array('U', '1265213106', '2010-02-03 16:05:06 UTC'), ); - // This test will fail < 5.3.9 - see https://bugs.php.net/51994 - if (PHP_VERSION_ID >= 50309) { - $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); - } - return $data; } @@ -111,10 +107,6 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); - } - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); $output = new \DateTime($output); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php index f201f99862..113fc5c6dc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php @@ -51,10 +51,6 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase { session_id('touti'); - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires PHP >= 5.4'); - } - $this->assertSame(PHP_SESSION_NONE, session_status()); $token = $this->provider->generateCsrfToken('foo'); diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index fa80c68858..a8769db1a5 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -120,7 +120,7 @@ class JsonResponse extends Response } if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException($this->transformJsonError()); + throw new \InvalidArgumentException(json_last_error_msg()); } return $this->update(); @@ -172,31 +172,4 @@ class JsonResponse extends Response return $this->setContent($this->data); } - - private function transformJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded.'; - - case JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch.'; - - case JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found.'; - - case JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON.'; - - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded.'; - - default: - return 'Unknown error.'; - } - } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 80d3ab892d..047c70a2d9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -16,12 +16,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; * * @see http://php.net/sessionhandler */ -if (PHP_VERSION_ID >= 50400) { - class NativeSessionHandler extends \SessionHandler - { - } -} else { - class NativeSessionHandler - { - } + +class NativeSessionHandler extends \SessionHandler +{ } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index a5bdbe91d8..fdb97dcc2c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -101,11 +101,7 @@ class NativeSessionStorage implements SessionStorageInterface session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) ini_set('session.use_cookies', 1); - if (PHP_VERSION_ID >= 50400) { - session_register_shutdown(); - } else { - register_shutdown_function('session_write_close'); - } + session_register_shutdown(); $this->setMetadataBag($metaBag); $this->setOptions($options); @@ -131,15 +127,10 @@ class NativeSessionStorage implements SessionStorageInterface return true; } - if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { + if (\PHP_SESSION_ACTIVE === session_status()) { throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) { - // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3 - throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).'); - } - if (ini_get('session.use_cookies') && headers_sent($file, $line)) { throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); } @@ -150,10 +141,6 @@ class NativeSessionStorage implements SessionStorageInterface } $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(true); - } return true; } @@ -213,11 +200,6 @@ class NativeSessionStorage implements SessionStorageInterface { session_write_close(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(false); - } - $this->closed = true; $this->started = false; } @@ -363,24 +345,12 @@ class NativeSessionStorage implements SessionStorageInterface if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { $saveHandler = new SessionHandlerProxy($saveHandler); } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = PHP_VERSION_ID >= 50400 ? - new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); + $saveHandler = new SessionHandlerProxy(new \SessionHandler()); } $this->saveHandler = $saveHandler; if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (PHP_VERSION_ID >= 50400) { - session_set_save_handler($this->saveHandler, false); - } else { - session_set_save_handler( - array($this->saveHandler, 'open'), - array($this->saveHandler, 'close'), - array($this->saveHandler, 'read'), - array($this->saveHandler, 'write'), - array($this->saveHandler, 'destroy'), - array($this->saveHandler, 'gc') - ); - } + session_set_save_handler($this->saveHandler, false); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php index ced706f72c..6f02a7fd73 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php @@ -43,10 +43,6 @@ class PhpBridgeSessionStorage extends NativeSessionStorage } $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 + internal save handlers - $this->saveHandler->setActive(true); - } return true; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 1036818277..f3f1478114 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -25,11 +25,6 @@ abstract class AbstractProxy */ protected $wrapper = false; - /** - * @var bool - */ - protected $active = false; - /** * @var string */ @@ -72,32 +67,7 @@ abstract class AbstractProxy */ public function isActive() { - if (PHP_VERSION_ID >= 50400) { - return $this->active = \PHP_SESSION_ACTIVE === session_status(); - } - - return $this->active; - } - - /** - * Sets the active flag. - * - * Has no effect under PHP 5.4+ as status is detected - * automatically in isActive() - * - * @internal - * - * @param bool $flag - * - * @throws \LogicException - */ - public function setActive($flag) - { - if (PHP_VERSION_ID >= 50400) { - throw new \LogicException('This method is disabled in PHP 5.4.0+'); - } - - $this->active = (bool) $flag; + return \PHP_SESSION_ACTIVE === session_status(); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index ab848b6b97..c3eeacf7b1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -28,13 +28,8 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - if (PHP_VERSION_ID < 50400) { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('files', ini_get('session.save_handler')); - } else { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } + $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); + $this->assertEquals('user', ini_get('session.save_handler')); $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); $this->assertEquals('TESTING', ini_get('session.name')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php index 3437cf08f1..b2304cbc48 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php @@ -27,14 +27,7 @@ class NativeSessionHandlerTest extends \PHPUnit_Framework_TestCase { $handler = new NativeSessionHandler(); - // note for PHPUnit optimisers - the use of assertTrue/False - // here is deliberate since the tests do not require the classes to exist - drak - if (PHP_VERSION_ID < 50400) { - $this->assertFalse($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } else { - $this->assertTrue($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } + $this->assertTrue($handler instanceof \SessionHandler); + $this->assertTrue($handler instanceof NativeSessionHandler); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 41329e7248..9b836bbe99 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -165,34 +165,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase $storage->setSaveHandler(new \stdClass()); } - public function testSetSaveHandler53() + public function testSetSaveHandler() { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - ini_set('session.save_handler', 'files'); - $storage = $this->getStorage(); - $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeProxy()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - } - - public function testSetSaveHandler54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - ini_set('session.save_handler', 'files'); $storage = $this->getStorage(); $storage->setSaveHandler(); @@ -212,7 +186,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase /** * @expectedException \RuntimeException */ - public function testStartedOutside() + public function testStarted() { $storage = $this->getStorage(); @@ -222,10 +196,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase session_start(); $this->assertTrue(isset($_SESSION)); - if (PHP_VERSION_ID >= 50400) { - // this only works in PHP >= 5.4 where session_status is available - $this->assertTrue($storage->getSaveHandler()->isActive()); - } + $this->assertTrue($storage->getSaveHandler()->isActive()); + // PHP session might have started, but the storage driver has not, so false is correct here $this->assertFalse($storage->isStarted()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index d9f4a30a89..ed989d4078 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -59,36 +59,8 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase return $storage; } - public function testPhpSession53() + public function testPhpSession() { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $storage = $this->getStorage(); - - $this->assertFalse(isset($_SESSION)); - $this->assertFalse($storage->getSaveHandler()->isActive()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - // in PHP 5.3 we cannot reliably tell if a session has started - $this->assertFalse($storage->getSaveHandler()->isActive()); - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); - $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); - } - - public function testPhpSession54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - $storage = $this->getStorage(); $this->assertFalse(isset($_SESSION)); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index ee476a879d..7290e62382 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -85,56 +85,18 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->proxy->isWrapper()); } - public function testIsActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->assertFalse($this->proxy->isActive()); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testIsActivePhp54() + public function testIsActive() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } $this->assertFalse($this->proxy->isActive()); session_start(); $this->assertTrue($this->proxy->isActive()); } - public function testSetActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->assertTrue($this->proxy->isActive()); - $this->proxy->setActive(false); - $this->assertFalse($this->proxy->isActive()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testSetActivePhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $this->proxy->setActive(true); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled @@ -147,30 +109,13 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase $this->assertEquals(session_name(), $this->proxy->getName()); } - /** - * @expectedException \LogicException - */ - public function testNameExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setName('foo'); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled * @expectedException \LogicException */ - public function testNameExceptionPhp54() + public function testNameException() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - session_start(); $this->proxy->setName('foo'); } @@ -187,30 +132,13 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase $this->assertEquals(session_id(), $this->proxy->getId()); } - /** - * @expectedException \LogicException - */ - public function testIdExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setId('foo'); - } - /** * @runInSeparateProcess * @preserveGlobalState disabled * @expectedException \LogicException */ - public function testIdExceptionPhp54() + public function testIdException() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - session_start(); $this->proxy->setId('foo'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index d2775a80a2..bc810a6b20 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -45,7 +45,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase $this->proxy = null; } - public function testOpen() + public function testOpenTrue() { $this->mock->expects($this->once()) ->method('open') @@ -53,11 +53,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); - if (PHP_VERSION_ID < 50400) { - $this->assertTrue($this->proxy->isActive()); - } else { - $this->assertFalse($this->proxy->isActive()); - } + $this->assertFalse($this->proxy->isActive()); } public function testOpenFalse() diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index 6099097f36..8a836da84c 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -60,12 +60,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface $this->isCollected = false; } - $trace = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS : true; - if (PHP_VERSION_ID >= 50400) { - $trace = debug_backtrace($trace, 7); - } else { - $trace = debug_backtrace($trace); - } + $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7); $file = $trace[0]['file']; $line = $trace[0]['line']; diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 56c96b3ced..304b527842 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -107,11 +107,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer } $renderedAttributes = ''; if (count($attributes) > 0) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { $renderedAttributes .= sprintf( ' %s="%s"', diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index fe70ae5d5e..dd1d6242ea 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -181,15 +181,11 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $request->attributes->set('foobar', 'foobar'); $controller = array(new self(), 'controllerMethod3'); - if (PHP_VERSION_ID === 50316) { - $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); - } else { - try { - $resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } + try { + $resolver->getArguments($request, $controller); + $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + } catch (\Exception $e) { + $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); } $request = Request::create('/'); diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php index 1973843481..84b20abf77 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php @@ -53,37 +53,10 @@ class JsonBundleReader implements BundleReaderInterface 'The resource bundle "%s/%s.json" contains invalid JSON: %s', $path, $locale, - self::getLastJsonError() + json_last_error_msg() )); } return $data; } - - /** - * @return string The last error message created by {@link json_decode()} - * - * @link http://de2.php.net/manual/en/function.json-last-error-msg.php#113243 - */ - private static function getLastJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - static $errors = array( - JSON_ERROR_NONE => null, - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', - ); - - $error = json_last_error(); - - return array_key_exists($error, $errors) - ? $errors[$error] - : sprintf('Unknown error (%s)', $error); - } } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php index 6a79340c69..f3df769e13 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php @@ -35,14 +35,8 @@ class JsonBundleWriter implements BundleWriterInterface } }); - if (PHP_VERSION_ID >= 50400) { - // Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs - file_put_contents( - $path.'/'.$locale.'.json', - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n" - ); - } else { - file_put_contents($path.'/'.$locale.'.json', json_encode($data)."\n"); - } + $contents = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n"; + + file_put_contents($path.'/'.$locale.'.json', $contents); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 7636be9a34..37bb9cad49 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -187,8 +187,7 @@ class IntlDateFormatter /** * Format the date/time value (timestamp) as a string. * - * @param int|\DateTime $timestamp The timestamp to format. \DateTime objects - * are supported as of PHP 5.3.4. + * @param int|\DateTime $timestamp The timestamp to format. * * @return string|bool The formatted value or false if formatting failed. * @@ -200,20 +199,16 @@ class IntlDateFormatter { // intl allows timestamps to be passed as arrays - we don't if (is_array($timestamp)) { - $message = PHP_VERSION_ID >= 50304 ? - 'Only integer Unix timestamps and DateTime objects are supported' : - 'Only integer Unix timestamps are supported'; + $message = 'Only integer Unix timestamps and DateTime objects are supported'; throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message); } // behave like the intl extension $argumentError = null; - if (PHP_VERSION_ID < 50304 && !is_int($timestamp)) { - $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (PHP_VERSION_ID >= 50304 && !is_int($timestamp) && !$timestamp instanceof \DateTime) { + if (!is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (PHP_VERSION_ID >= 50500 && !is_int($timestamp)) { + if (!is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -227,7 +222,7 @@ class IntlDateFormatter } // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (PHP_VERSION_ID >= 50304 && $timestamp instanceof \DateTime) { + if ($timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } @@ -375,10 +370,7 @@ class IntlDateFormatter return $this->timeZoneId; } - // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - return date_default_timezone_get(); - } + return date_default_timezone_get(); } /** @@ -540,16 +532,7 @@ class IntlDateFormatter public function setTimeZoneId($timeZoneId) { if (null === $timeZoneId) { - // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - $timeZoneId = date_default_timezone_get(); - } else { - // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will - // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC. - // See the first two items of the commit message for more information: - // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9 - $timeZoneId = getenv('TZ') ?: 'UTC'; - } + $timeZoneId = date_default_timezone_get(); $this->unitializedTimeZoneId = true; } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 6a66e8bb45..c7f518d74c 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -839,9 +839,7 @@ class NumberFormatter * * @param mixed $value The value to be converted * - * @return int|float The converted value - * - * @see https://bugs.php.net/bug.php?id=59597 Bug #59597 + * @return int|false The converted value */ private function getInt64Value($value) { @@ -849,30 +847,6 @@ class NumberFormatter return false; } - if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value <= self::$int32Range['negative'])) { - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // The negative PHP_INT_MAX was being converted to float - if ( - $value == self::$int32Range['negative'] && - ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) - ) { - return (int) $value; - } - - return (float) $value; - } - - if (PHP_INT_SIZE === 8) { - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if ( - ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && - (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) - ) { - $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value)); - } - } - return (int) $value; } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index 69575289cd..f2e7b4fce4 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -34,10 +34,6 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires at least PHP 5.4.0.'); - } - $this->writer = new JsonBundleWriter(); $this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.rand(1000, 9999); $this->filesystem = new Filesystem(); @@ -47,10 +43,6 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function tearDown() { - if (PHP_VERSION_ID < 50400) { - return; - } - $this->filesystem->remove($this->directory); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 40f5fd71c1..cbac7ab9f8 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -37,12 +37,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); - // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (PHP_VERSION_ID >= 50500) { - $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); - } else { - $this->assertNull($formatter->getTimeZoneId()); - } + $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } /** @@ -60,6 +55,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase public function formatProvider() { + $dateTime = new \DateTime('@0'); + $formatData = array( /* general */ array('y-M-d', 0, '1970-1-1'), @@ -236,22 +233,16 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase array('zzz', 0, 'GMT'), array('zzzz', 0, 'GMT'), array('zzzzz', 0, 'GMT'), + + // general, DateTime + array('y-M-d', $dateTime, '1970-1-1'), + array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"), + array('h:mm a', $dateTime, '12:00 AM'), + array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'), + array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT'), + array('K:mm a, z', $dateTime, '0:00 AM, GMT'), ); - // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (PHP_VERSION_ID >= 50304) { - $dateTime = new \DateTime('@0'); - - /* general, DateTime */ - $formatData[] = array('y-M-d', $dateTime, '1970-1-1'); - $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"); - $formatData[] = array('h:mm a', $dateTime, '12:00 AM'); - $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'); - - $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT'); - $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT'); - } - return $formatData; } @@ -269,22 +260,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase public function formatErrorProvider() { - // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if (PHP_VERSION_ID >= 50500) { - return array( - array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'), - ); - } - - $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR'; - - if (PHP_VERSION_ID >= 50304) { - $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR'; - } - return array( - array('y-M-d', '0', $message), - array('y-M-d', 'foobar', $message), + array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'), ); } @@ -324,16 +301,12 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase array(0, 'Europe/Dublin', '1970-01-01 01:00:00'), array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'), array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'), + array(0, 'Foo/Bar', '1970-01-01 00:00:00'), + array(0, 'Foo/Bar', '1970-01-01 00:00:00'), + array(0, 'UTC+04:30', '1970-01-01 00:00:00'), + array(0, 'UTC+04:AA', '1970-01-01 00:00:00'), ); - // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (PHP_VERSION_ID < 50500) { - // When time zone not exists, uses UTC by default - $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); - $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); - $data[] = array(0, 'UTC+04:AA', '1970-01-01 00:00:00'); - } - return $data; } @@ -341,11 +314,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('GMT+03:00'); - } else { - $formatter->setTimeZoneId('GMT+03:00'); - } + $formatter->setTimeZone('GMT+03:00'); $this->assertEquals('GMT+03:00', $formatter->format(0)); } @@ -354,11 +323,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('GMT+00:30'); - } else { - $formatter->setTimeZoneId('GMT+00:30'); - } + $formatter->setTimeZone('GMT+00:30'); $this->assertEquals('GMT+00:30', $formatter->format(0)); } @@ -367,11 +332,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone('Pacific/Fiji'); - } else { - $formatter->setTimeZoneId('Pacific/Fiji'); - } + $formatter->setTimeZone('Pacific/Fiji'); $this->assertEquals('Fiji Standard Time', $formatter->format(0)); } @@ -387,35 +348,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase ); } - public function testFormatWithTimezoneFromEnvironmentVariable() - { - if (PHP_VERSION_ID >= 50500) { - $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); - } - - $tz = getenv('TZ'); - putenv('TZ=Europe/London'); - - $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); - $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); - - $this->assertEquals( - $this->getDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'), - $formatter->format(0) - ); - - $this->assertEquals('Europe/London', getenv('TZ')); - - // Restores TZ. - putenv('TZ='.$tz); - } - public function testFormatWithTimezoneFromPhp() { - if (PHP_VERSION_ID < 50500) { - $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); - } - $tz = date_default_timezone_get(); date_default_timezone_set('Europe/London'); @@ -843,11 +777,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { $formatter = $this->getDefaultDateFormatter(); - if (PHP_VERSION_ID >= 50500) { - $formatter->setTimeZone($timeZoneId); - } else { - $formatter->setTimeZoneId($timeZoneId); - } + $formatter->setTimeZone($timeZoneId); $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId()); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 2e7544b39e..97247d47b5 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -56,12 +56,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest $formatter->format($localtime); } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); - - if (PHP_VERSION_ID >= 50304) { - $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); - } else { - $this->assertStringEndsWith('Only integer Unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); - } + $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); } } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 341cdc90c2..531bb4c62b 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -687,13 +687,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // The negative PHP_INT_MAX was being converted to float - if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) { - $this->assertInternalType('int', $parsedValue); - } else { - $this->assertInternalType('float', $parsedValue); - } + $this->assertInternalType('int', $parsedValue); $this->assertEquals(-2147483648, $parsedValue); } @@ -744,24 +738,12 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); $this->assertInternalType('integer', $parsedValue); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { - $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); - } else { - $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); - } + $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64); $this->assertInternalType('integer', $parsedValue); - // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 - // A 32 bit integer was being generated instead of a 64 bit integer - if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { - $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); - } else { - $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); - } + $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); } /** diff --git a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php index d2b031999c..c0c8fe0993 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php @@ -34,10 +34,6 @@ class BCryptPasswordEncoder extends BasePasswordEncoder */ public function __construct($cost) { - if (!function_exists('password_hash')) { - throw new \RuntimeException('To use the BCrypt encoder, you need to upgrade to PHP 5.5 or install the "ircmaxell/password-compat" via Composer.'); - } - $cost = (int) $cost; if ($cost < 4 || $cost > 31) { throw new \InvalidArgumentException('Cost must be in the range of 4-31.'); diff --git a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php index dac1cad600..8422a4baae 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php @@ -64,11 +64,7 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } - if (function_exists('hash_pbkdf2')) { - $digest = hash_pbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length, true); - } else { - $digest = $this->hashPbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length); - } + $digest = hash_pbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length, true); return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest); } @@ -80,24 +76,4 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder { return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt)); } - - private function hashPbkdf2($algorithm, $password, $salt, $iterations, $length = 0) - { - // Number of blocks needed to create the derived key - $blocks = ceil($length / strlen(hash($algorithm, null, true))); - $digest = ''; - - for ($i = 1; $i <= $blocks; $i++) { - $ib = $block = hash_hmac($algorithm, $salt.pack('N', $i), $password, true); - - // Iterations - for ($j = 1; $j < $iterations; $j++) { - $ib ^= ($block = hash_hmac($algorithm, $block, $password, true)); - } - - $digest .= $ib; - } - - return substr($digest, 0, $this->length); - } } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php index 2f7b845acd..4d9ca6d48e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php @@ -47,8 +47,6 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function testResultLength() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); @@ -56,21 +54,12 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function testValidation() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } - private function skipIfPhpVersionIsNotSupported() - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Requires PHP >= 5.3.7'); - } - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ diff --git a/src/Symfony/Component/Security/Core/Util/SecureRandom.php b/src/Symfony/Component/Security/Core/Util/SecureRandom.php index aefc88854a..f4167e4d2f 100644 --- a/src/Symfony/Component/Security/Core/Util/SecureRandom.php +++ b/src/Symfony/Component/Security/Core/Util/SecureRandom.php @@ -43,9 +43,7 @@ final class SecureRandom implements SecureRandomInterface $this->logger = $logger; // determine whether to use OpenSSL - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) { - $this->useOpenSsl = false; - } elseif (!function_exists('openssl_random_pseudo_bytes')) { + if (!function_exists('openssl_random_pseudo_bytes')) { if (null !== $this->logger) { $this->logger->notice('It is recommended that you enable the "openssl" extension for random number generation.'); } diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index 0039deb1a8..ef49f2f884 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -52,10 +52,6 @@ class NativeSessionTokenStorageTest extends \PHPUnit_Framework_TestCase public function testStoreTokenInClosedSessionWithExistingSessionId() { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires PHP 5.4 or later.'); - } - session_id('foobar'); $this->assertSame(PHP_SESSION_NONE, session_status()); diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php index 60145c65a0..4229bb637b 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php @@ -108,11 +108,7 @@ class NativeSessionTokenStorage implements TokenStorageInterface private function startSession() { - if (PHP_VERSION_ID >= 50400) { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - } elseif (!session_id()) { + if (PHP_SESSION_NONE === session_status()) { session_start(); } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 4bb5b43dd0..a35849a5c6 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -99,11 +99,7 @@ class JsonDecode implements DecoderInterface $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - if (PHP_VERSION_ID >= 50400) { - $decodedData = json_decode($data, $associative, $recursionDepth, $options); - } else { - $decodedData = json_decode($data, $associative, $recursionDepth); - } + $decodedData = json_decode($data, $associative, $recursionDepth, $options); if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) { throw new UnexpectedValueException(JsonEncoder::getLastErrorMessage()); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php index 2231dd624a..28d619f1f2 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -99,23 +99,6 @@ class JsonEncoder implements EncoderInterface, DecoderInterface */ public static function getLastErrorMessage() { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded'; - case JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch'; - case JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found'; - case JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON'; - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - default: - return 'Unknown error'; - } + return json_last_error_msg(); } } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index fd236d2cff..491d17c2e0 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -457,11 +457,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess */ protected function initializeEscapers() { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } + $flags = ENT_QUOTES | ENT_SUBSTITUTE; $this->escapers = array( 'html' => @@ -488,11 +484,11 @@ class PhpEngine implements EngineInterface, \ArrayAccess * @return string the escaped value */ function ($value) { - if ('UTF-8' != $that->getCharset()) { - $value = $that->convertEncoding($value, 'UTF-8', $that->getCharset()); + if ('UTF-8' != $this->getCharset()) { + $value = $this->convertEncoding($value, 'UTF-8', $this->getCharset()); } - $callback = function ($matches) use ($that) { + $callback = function ($matches) { $char = $matches[0]; // \xHH @@ -501,7 +497,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess } // \uHHHH - $char = $that->convertEncoding($char, 'UTF-16BE', 'UTF-8'); + $char = $this->convertEncoding($char, 'UTF-16BE', 'UTF-8'); return '\\u'.substr('0000'.bin2hex($char), -4); }; @@ -511,7 +507,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess } if ('UTF-8' != $this->getCharset()) { - $value = $this->convertEncoding($value, $that->getCharset(), 'UTF-8'); + $value = $this->convertEncoding($value, $this->getCharset(), 'UTF-8'); } return $value; diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index fea7827498..f54321f00e 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -13,10 +13,6 @@ namespace Symfony\Component\Translation\Dumper; use Symfony\Component\Translation\MessageCatalogue; -if (!defined('JSON_PRETTY_PRINT')) { - define('JSON_PRETTY_PRINT', 128); -} - /** * JsonFileDumper generates an json formatted string representation of a message catalogue. * diff --git a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php index 697cd939f6..86594ef8bb 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php @@ -18,10 +18,6 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase { public function testDump() { - if (PHP_VERSION_ID < 50400) { - $this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing'); - } - $catalogue = new MessageCatalogue('en'); $catalogue->add(array('foo' => 'bar')); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 4013fd48fe..37ce4805f4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -36,10 +36,6 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal { protected static function addPhp5Dot5Comparisons(array $comparisons) { - if (version_compare(PHP_VERSION, '5.5.0-dev', '<')) { - return $comparisons; - } - $result = $comparisons; // Duplicate all tests involving DateTime objects to be tested with diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index 4b71062f05..8550e1159f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -64,10 +64,8 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase array(null, 1), ); - if (version_compare(PHP_VERSION, '>=', '5.5')) { - $immutableDate = new \DateTimeImmutable('2000-01-01'); - $comparisons[] = array($immutableDate, $immutableDate); - } + $immutableDate = new \DateTimeImmutable('2000-01-01'); + $comparisons[] = array($immutableDate, $immutableDate); return $comparisons; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 1fbd80663f..e59c0945c4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -82,10 +82,8 @@ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'), ); - if (version_compare(PHP_VERSION, '>=', '5.5')) { - $immutableDate = new \DateTimeImmutable('2000-01-01'); - $comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime'); - } + $immutableDate = new \DateTimeImmutable('2000-01-01'); + $comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime'); return $comparisons; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 9b7056b548..6e6990c39f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -194,11 +194,9 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest array(new \DateTime('March 20, 2014')), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 10, 2014')); - $tests[] = array(new \DateTimeImmutable('March 15, 2014')); - $tests[] = array(new \DateTimeImmutable('March 20, 2014')); - } + $tests[] = array(new \DateTimeImmutable('March 10, 2014')); + $tests[] = array(new \DateTimeImmutable('March 15, 2014')); + $tests[] = array(new \DateTimeImmutable('March 20, 2014')); $this->restoreDefaultTimezone(); @@ -216,10 +214,8 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'); - $tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'); - } + $tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM'); + $tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'); $this->restoreDefaultTimezone(); @@ -237,10 +233,8 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'), ); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { - $tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'); - $tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'); - } + $tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM'); + $tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'); $this->restoreDefaultTimezone(); diff --git a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php index 3e1e442f75..4509e22ee1 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php @@ -19,15 +19,6 @@ use Symfony\Component\Validator\Validator\LegacyValidator; class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - - parent::setUp(); - } - protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { $contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator()); diff --git a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php index 3f02a5af71..3f7bf1e5bb 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php @@ -19,15 +19,6 @@ use Symfony\Component\Validator\Validator\LegacyValidator; class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest { - protected function setUp() - { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - - parent::setUp(); - } - protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { $contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator()); diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index ba184f7c78..69689d6390 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -112,13 +112,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase public function testDefaultApiVersion() { - if (PHP_VERSION_ID < 50309) { - // Old implementation on PHP < 5.3.9 - $this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator()); - } else { - // Legacy compatible implementation on PHP >= 5.3.9 - $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); - } + $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); } public function testSetApiVersion24() @@ -135,10 +129,6 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase public function testSetApiVersion24And25() { - if (PHP_VERSION_ID < 50309) { - $this->markTestSkipped('Not supported prior to PHP 5.3.9'); - } - $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC)); $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); } diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index f5cab110cd..8151a444f7 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -329,15 +329,6 @@ class ValidatorBuilder implements ValidatorBuilderInterface )); } - if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) { - throw new InvalidArgumentException(sprintf( - 'The Validator API that is compatible with both Symfony 2.4 '. - 'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '. - 'Your current PHP version is %s.', - PHP_VERSION - )); - } - $this->apiVersion = $apiVersion; return $this; @@ -389,9 +380,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface $apiVersion = $this->apiVersion; if (null === $apiVersion) { - $apiVersion = PHP_VERSION_ID < 50309 - ? Validation::API_VERSION_2_4 - : Validation::API_VERSION_2_5_BC; + $apiVersion = Validation::API_VERSION_2_5_BC; } if (Validation::API_VERSION_2_4 === $apiVersion) { diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 605977be80..0827bba547 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -266,7 +266,7 @@ class VarCloner extends AbstractCloner } else { // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below $obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush'); - foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { + foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) { if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) { $frame['line'] = 0; break; diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index 49710aaa88..ed77ccb597 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -38,7 +38,7 @@ class CliDumperTest extends \PHPUnit_Framework_TestCase ob_start(); $dumper->dump($data); $out = ob_get_clean(); - $closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function'; + $closureLabel = 'public method'; $out = preg_replace('/[ \t]+$/m', '', $out); $intMax = PHP_INT_MAX; $res1 = (int) $var['res']; diff --git a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php index fc8a15f09f..87198d6d26 100644 --- a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php @@ -40,7 +40,7 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase ob_start(); $dumper->dump($data); $out = ob_get_clean(); - $closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function'; + $closureLabel = 'public method'; $out = preg_replace('/[ \t]+$/m', '', $out); $var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8'); $intMax = PHP_INT_MAX; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index 0447dff137..180e712e90 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -125,12 +125,7 @@ class ParseException extends RuntimeException } if (null !== $this->parsedFile) { - if (PHP_VERSION_ID >= 50400) { - $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; - } else { - $jsonOptions = 0; - } - $this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions)); + $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } if ($this->parsedLine >= 0) { diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php index e4eb9c98a1..7286d45a09 100644 --- a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -18,11 +18,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessage() { $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); - if (PHP_VERSION_ID >= 50400) { - $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; - } else { - $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; - } + $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; $this->assertEquals($message, $exception->getMessage()); } @@ -30,11 +26,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessageWithUnicodeInFilename() { $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml'); - if (PHP_VERSION_ID >= 50400) { - $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; - } else { - $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")'; - } + $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; $this->assertEquals($message, $exception->getMessage()); }