[3.0] Removed some old hacks
This commit is contained in:
parent
fddcb86c31
commit
35e0845f23
21
README.md
21
README.md
|
@ -4,32 +4,13 @@ README
|
||||||
What is Symfony?
|
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
|
flexibility in mind. It allows developers to build better and easy to maintain
|
||||||
websites with PHP.
|
websites with PHP.
|
||||||
|
|
||||||
Symfony can be used to develop all kind of websites, from your personal blog
|
Symfony can be used to develop all kind of websites, from your personal blog
|
||||||
to high traffic ones like Dailymotion or Yahoo! Answers.
|
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
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
|
// Disabling Zend Garbage Collection to prevent segfaults
|
||||||
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
|
|
||||||
// https://bugs.php.net/bug.php?id=53976
|
// https://bugs.php.net/bug.php?id=53976
|
||||||
|
if (gc_enabled()) {
|
||||||
gc_disable();
|
gc_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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 <bschussek@gmail.com>
|
|
||||||
*/
|
|
||||||
class LegacyUniqueEntityValidator2Dot4ApiTest extends UniqueEntityValidatorTest
|
|
||||||
{
|
|
||||||
protected function getApiVersion()
|
|
||||||
{
|
|
||||||
return Validation::API_VERSION_2_4;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* 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 <bschussek@gmail.com>
|
|
||||||
*/
|
|
||||||
class LegacyUniqueEntityValidatorLegacyApiTest extends UniqueEntityValidatorTest
|
|
||||||
{
|
|
||||||
protected function getApiVersion()
|
|
||||||
{
|
|
||||||
return Validation::API_VERSION_2_5_BC;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Bridge\Twig\Command;
|
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\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
|
@ -174,11 +174,7 @@ class CodeExtension extends \Twig_Extension
|
||||||
$text = "$text at line $line";
|
$text = "$text at line $line";
|
||||||
|
|
||||||
if (false !== $link = $this->getFileLink($file, $line)) {
|
if (false !== $link = $this->getFileLink($file, $line)) {
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||||
} else {
|
|
||||||
$flags = ENT_QUOTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
|
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ if ($this->env->isDebug()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EOTXT;
|
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());
|
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ if ($this->env->isDebug()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EOTXT;
|
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());
|
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,6 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
protected function getVariableGetter($name)
|
protected function getVariableGetter($name)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('$this->getContext($context, "%s")', $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,10 +263,6 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
protected function getVariableGetter($name)
|
protected function getVariableGetter($name)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('$this->getContext($context, "%s")', $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,19 +38,11 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
protected function getVariableGetterWithoutStrictCheck($name)
|
protected function getVariableGetterWithoutStrictCheck($name)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('$this->getContext($context, "%s", true)', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getVariableGetterWithStrictCheck($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('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('$this->getContext($context, "%s")', $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
|
if (defined('HHVM_VERSION')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
|
if (defined('HHVM_VERSION')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
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\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
|
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\Alias;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
|
|
@ -498,14 +498,7 @@ class Configuration implements ConfigurationInterface
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; })
|
->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; })
|
||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
// This condition is duplicated in ValidatorBuilder. This
|
$v['validation']['api'] = '2.5-bc';
|
||||||
// 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';
|
|
||||||
|
|
||||||
return $v;
|
return $v;
|
||||||
})
|
})
|
||||||
|
|
|
@ -166,11 +166,7 @@ class CodeHelper extends Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== $link = $this->getFileLink($file, $line)) {
|
if (false !== $link = $this->getFileLink($file, $line)) {
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||||
} else {
|
|
||||||
$flags = ENT_QUOTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
|
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Descriptor\JsonDescriptor;
|
||||||
|
|
||||||
class JsonDescriptorTest extends AbstractDescriptorTest
|
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()
|
protected function getDescriptor()
|
||||||
{
|
{
|
||||||
return new JsonDescriptor();
|
return new JsonDescriptor();
|
||||||
|
|
|
@ -131,7 +131,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||||
'static_method' => array('loadValidatorMetadata'),
|
'static_method' => array('loadValidatorMetadata'),
|
||||||
'translation_domain' => 'validators',
|
'translation_domain' => 'validators',
|
||||||
'strict_email' => false,
|
'strict_email' => false,
|
||||||
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
|
'api' => '2.5-bc',
|
||||||
),
|
),
|
||||||
'annotations' => array(
|
'annotations' => array(
|
||||||
'cache' => 'file',
|
'cache' => 'file',
|
||||||
|
|
|
@ -295,12 +295,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||||
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
|
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
|
||||||
$this->assertSame('setApiVersion', $calls[6][0]);
|
$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()
|
public function testFullyConfiguredValidationService()
|
||||||
{
|
{
|
||||||
|
@ -448,12 +444,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||||
$this->assertSame('setApiVersion', $calls[5][0]);
|
$this->assertSame('setApiVersion', $calls[5][0]);
|
||||||
// no cache, no annotations
|
// 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]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This feature is equivalent to the implicit api, only that the "api"
|
* This feature is equivalent to the implicit api, only that the "api"
|
||||||
|
@ -472,12 +464,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||||
$this->assertSame('setApiVersion', $calls[5][0]);
|
$this->assertSame('setApiVersion', $calls[5][0]);
|
||||||
// no cache, no annotations
|
// 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()
|
public function testFormsCanBeEnabledWithoutCsrfProtection()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,10 +30,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
|
||||||
*/
|
*/
|
||||||
public function testRoutingErrorIsExposedWhenNotProtected($config)
|
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 = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
|
||||||
$client->insulate();
|
$client->insulate();
|
||||||
$client->request('GET', '/unprotected_resource');
|
$client->request('GET', '/unprotected_resource');
|
||||||
|
@ -46,10 +42,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
|
||||||
*/
|
*/
|
||||||
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
|
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 = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
|
||||||
$client->insulate();
|
$client->insulate();
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ class ClassCollectionLoader
|
||||||
|
|
||||||
self::$loaded[$name] = true;
|
self::$loaded[$name] = true;
|
||||||
|
|
||||||
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
|
$declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
|
||||||
if (function_exists('get_declared_traits')) {
|
|
||||||
$declared = array_merge($declared, get_declared_traits());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($adaptive) {
|
if ($adaptive) {
|
||||||
// don't include already declared classes
|
// don't include already declared classes
|
||||||
|
|
|
@ -11,14 +11,6 @@
|
||||||
|
|
||||||
namespace Symfony\Component\ClassLoader;
|
namespace Symfony\Component\ClassLoader;
|
||||||
|
|
||||||
if (!defined('SYMFONY_TRAIT')) {
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
define('SYMFONY_TRAIT', T_TRAIT);
|
|
||||||
} else {
|
|
||||||
define('SYMFONY_TRAIT', 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClassMapGenerator.
|
* ClassMapGenerator.
|
||||||
*
|
*
|
||||||
|
@ -117,7 +109,7 @@ class ClassMapGenerator
|
||||||
break;
|
break;
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
case T_INTERFACE:
|
case T_INTERFACE:
|
||||||
case SYMFONY_TRAIT:
|
case T_TRAIT:
|
||||||
// Find the classname
|
// Find the classname
|
||||||
while (($t = $tokens[++$i]) && is_array($t)) {
|
while (($t = $tokens[++$i]) && is_array($t)) {
|
||||||
if (T_STRING === $t[0]) {
|
if (T_STRING === $t[0]) {
|
||||||
|
|
|
@ -107,7 +107,7 @@ class DebugClassLoader
|
||||||
if ($file = $this->classFinder->findFile($class)) {
|
if ($file = $this->classFinder->findFile($class)) {
|
||||||
require $file;
|
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, '/')) {
|
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));
|
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
require $file;
|
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));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testTraitDependencies()
|
public function testTraitDependencies()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('Requires PHP > 5.4');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once __DIR__.'/Fixtures/deps/traits.php';
|
require_once __DIR__.'/Fixtures/deps/traits.php';
|
||||||
|
|
||||||
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
|
||||||
|
@ -100,12 +94,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testClassWithTraitsReordering(array $classes)
|
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/ATrait.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/BTrait.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
|
||||||
|
@ -148,12 +136,6 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testFixClassWithTraitsOrdering()
|
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/CTrait.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
|
||||||
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
|
||||||
|
|
|
@ -102,18 +102,15 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||||
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
|
'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php',
|
||||||
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
|
'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php',
|
||||||
)),
|
)),
|
||||||
);
|
array(__DIR__.'/Fixtures/php5.4', array(
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
|
|
||||||
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'Foo\\TBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'Foo\\IBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'Foo\\TFooBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
'Foo\\CBar' => __DIR__.'/Fixtures/php5.4/traits.php',
|
||||||
));
|
)),
|
||||||
}
|
);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,10 +229,6 @@ class TextDescriptor extends Descriptor
|
||||||
*/
|
*/
|
||||||
private function formatDefaultValue($default)
|
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);
|
return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ class DebugClassLoader
|
||||||
|
|
||||||
ErrorHandler::unstackErrors();
|
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]) {
|
if ('\\' === $class[0]) {
|
||||||
$class = substr($class, 1);
|
$class = substr($class, 1);
|
||||||
|
|
|
@ -357,12 +357,6 @@ class ErrorHandler
|
||||||
$type &= $level | $this->screamedErrors;
|
$type &= $level | $this->screamedErrors;
|
||||||
|
|
||||||
if ($type && ($log || $throw)) {
|
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 ($throw) {
|
||||||
if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
|
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
|
// 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);
|
$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;
|
throw $throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +387,7 @@ class ErrorHandler
|
||||||
$e['stack'] = debug_backtrace(true); // Provide object
|
$e['stack'] = debug_backtrace(true); // Provide object
|
||||||
}
|
}
|
||||||
} elseif ($trace) {
|
} 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();
|
static::handleFatalError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Private class used to work around https://bugs.php.net/54275
|
|
||||||
*
|
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -441,6 +441,6 @@ EOF;
|
||||||
$str = iconv($charset, 'UTF-8', $str);
|
$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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,6 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||||
*/
|
*/
|
||||||
private function classExists($class)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -581,15 +581,7 @@ class Crawler extends \SplObjectStorage
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach ($this->getNode(0)->childNodes as $child) {
|
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);
|
$html .= $child->ownerDocument->saveHTML($child);
|
||||||
} else {
|
|
||||||
$document = new \DOMDocument('1.0', 'UTF-8');
|
|
||||||
$document->appendChild($document->importNode($child, true));
|
|
||||||
$html .= rtrim($document->saveHTML());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
|
|
@ -336,10 +336,6 @@ class Parser
|
||||||
|
|
||||||
$node = new Node\GetAttrNode($node, $arg, $arguments, $type);
|
$node = new Node\GetAttrNode($node, $arg, $arguments, $type);
|
||||||
} elseif ('[' === $token->value) {
|
} 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();
|
$this->stream->next();
|
||||||
$arg = $this->parseExpression();
|
$arg = $this->parseExpression();
|
||||||
$this->stream->expect(Token::PUNCTUATION_TYPE, ']');
|
$this->stream->expect(Token::PUNCTUATION_TYPE, ']');
|
||||||
|
|
|
@ -61,17 +61,12 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
||||||
*
|
*
|
||||||
* @throws UnexpectedTypeException if a timezone is not a string
|
* @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);
|
parent::__construct($inputTimezone, $outputTimezone);
|
||||||
|
|
||||||
$this->generateFormat = $this->parseFormat = $format;
|
$this->generateFormat = $this->parseFormat = $format;
|
||||||
|
$this->parseUsingPipe = $parseUsingPipe || null === $parseUsingPipe;
|
||||||
// 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;
|
|
||||||
|
|
||||||
// See http://php.net/manual/en/datetime.createfromformat.php
|
// See http://php.net/manual/en/datetime.createfromformat.php
|
||||||
// The character "|" in the format makes sure that the parts of a date
|
// The character "|" in the format makes sure that the parts of a date
|
||||||
|
|
|
@ -73,13 +73,9 @@ class DefaultCsrfProvider implements CsrfProviderInterface
|
||||||
*/
|
*/
|
||||||
protected function getSessionId()
|
protected function getSessionId()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
if (PHP_SESSION_NONE === session_status()) {
|
if (PHP_SESSION_NONE === session_status()) {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
} elseif (!session_id()) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
return session_id();
|
return session_id();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: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:i', '16:05', '1970-01-01 16:05:00 UTC'),
|
||||||
array('H', '16', '1970-01-01 16:00: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
|
// different day representations
|
||||||
array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'),
|
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'),
|
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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +107,6 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||||
*/
|
*/
|
||||||
public function testReverseTransformUsingPipe($format, $input, $output)
|
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);
|
$reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true);
|
||||||
|
|
||||||
$output = new \DateTime($output);
|
$output = new \DateTime($output);
|
||||||
|
|
|
@ -51,10 +51,6 @@ class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
session_id('touti');
|
session_id('touti');
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('This test requires PHP >= 5.4');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(PHP_SESSION_NONE, session_status());
|
$this->assertSame(PHP_SESSION_NONE, session_status());
|
||||||
|
|
||||||
$token = $this->provider->generateCsrfToken('foo');
|
$token = $this->provider->generateCsrfToken('foo');
|
||||||
|
|
|
@ -120,7 +120,7 @@ class JsonResponse extends Response
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||||
throw new \InvalidArgumentException($this->transformJsonError());
|
throw new \InvalidArgumentException(json_last_error_msg());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->update();
|
return $this->update();
|
||||||
|
@ -172,31 +172,4 @@ class JsonResponse extends Response
|
||||||
|
|
||||||
return $this->setContent($this->data);
|
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.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
||||||
*
|
*
|
||||||
* @see http://php.net/sessionhandler
|
* @see http://php.net/sessionhandler
|
||||||
*/
|
*/
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
class NativeSessionHandler extends \SessionHandler
|
class NativeSessionHandler extends \SessionHandler
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
class NativeSessionHandler
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -101,11 +101,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
||||||
ini_set('session.use_cookies', 1);
|
ini_set('session.use_cookies', 1);
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
session_register_shutdown();
|
session_register_shutdown();
|
||||||
} else {
|
|
||||||
register_shutdown_function('session_write_close');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setMetadataBag($metaBag);
|
$this->setMetadataBag($metaBag);
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
|
@ -131,15 +127,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
return true;
|
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.');
|
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)) {
|
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));
|
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();
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -213,11 +200,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
{
|
{
|
||||||
session_write_close();
|
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->closed = true;
|
||||||
$this->started = false;
|
$this->started = false;
|
||||||
}
|
}
|
||||||
|
@ -363,24 +345,12 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
||||||
$saveHandler = new SessionHandlerProxy($saveHandler);
|
$saveHandler = new SessionHandlerProxy($saveHandler);
|
||||||
} elseif (!$saveHandler instanceof AbstractProxy) {
|
} elseif (!$saveHandler instanceof AbstractProxy) {
|
||||||
$saveHandler = PHP_VERSION_ID >= 50400 ?
|
$saveHandler = new SessionHandlerProxy(new \SessionHandler());
|
||||||
new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy();
|
|
||||||
}
|
}
|
||||||
$this->saveHandler = $saveHandler;
|
$this->saveHandler = $saveHandler;
|
||||||
|
|
||||||
if ($this->saveHandler instanceof \SessionHandlerInterface) {
|
if ($this->saveHandler instanceof \SessionHandlerInterface) {
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
session_set_save_handler($this->saveHandler, false);
|
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')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,6 @@ class PhpBridgeSessionStorage extends NativeSessionStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadSession();
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,6 @@ abstract class AbstractProxy
|
||||||
*/
|
*/
|
||||||
protected $wrapper = false;
|
protected $wrapper = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $active = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -72,32 +67,7 @@ abstract class AbstractProxy
|
||||||
*/
|
*/
|
||||||
public function isActive()
|
public function isActive()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
return \PHP_SESSION_ACTIVE === session_status();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,13 +28,8 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
|
$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('files', $storage->getSaveHandler()->getSaveHandlerName());
|
||||||
$this->assertEquals('user', ini_get('session.save_handler'));
|
$this->assertEquals('user', ini_get('session.save_handler'));
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path'));
|
$this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path'));
|
||||||
$this->assertEquals('TESTING', ini_get('session.name'));
|
$this->assertEquals('TESTING', ini_get('session.name'));
|
||||||
|
|
|
@ -27,14 +27,7 @@ class NativeSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$handler = new NativeSessionHandler();
|
$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 \SessionHandler);
|
||||||
$this->assertTrue($handler instanceof NativeSessionHandler);
|
$this->assertTrue($handler instanceof NativeSessionHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -165,34 +165,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
$storage->setSaveHandler(new \stdClass());
|
$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');
|
ini_set('session.save_handler', 'files');
|
||||||
$storage = $this->getStorage();
|
$storage = $this->getStorage();
|
||||||
$storage->setSaveHandler();
|
$storage->setSaveHandler();
|
||||||
|
@ -212,7 +186,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @expectedException \RuntimeException
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testStartedOutside()
|
public function testStarted()
|
||||||
{
|
{
|
||||||
$storage = $this->getStorage();
|
$storage = $this->getStorage();
|
||||||
|
|
||||||
|
@ -222,10 +196,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$this->assertTrue(isset($_SESSION));
|
$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
|
// PHP session might have started, but the storage driver has not, so false is correct here
|
||||||
$this->assertFalse($storage->isStarted());
|
$this->assertFalse($storage->isStarted());
|
||||||
|
|
||||||
|
|
|
@ -59,36 +59,8 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
return $storage;
|
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();
|
$storage = $this->getStorage();
|
||||||
|
|
||||||
$this->assertFalse(isset($_SESSION));
|
$this->assertFalse(isset($_SESSION));
|
||||||
|
|
|
@ -85,56 +85,18 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($this->proxy->isWrapper());
|
$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
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @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());
|
$this->assertFalse($this->proxy->isActive());
|
||||||
session_start();
|
session_start();
|
||||||
$this->assertTrue($this->proxy->isActive());
|
$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
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
|
@ -147,30 +109,13 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(session_name(), $this->proxy->getName());
|
$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
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @expectedException \LogicException
|
* @expectedException \LogicException
|
||||||
*/
|
*/
|
||||||
public function testNameExceptionPhp54()
|
public function testNameException()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
|
||||||
}
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$this->proxy->setName('foo');
|
$this->proxy->setName('foo');
|
||||||
}
|
}
|
||||||
|
@ -187,30 +132,13 @@ class AbstractProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(session_id(), $this->proxy->getId());
|
$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
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @expectedException \LogicException
|
* @expectedException \LogicException
|
||||||
*/
|
*/
|
||||||
public function testIdExceptionPhp54()
|
public function testIdException()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
|
|
||||||
}
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$this->proxy->setId('foo');
|
$this->proxy->setId('foo');
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->proxy = null;
|
$this->proxy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOpen()
|
public function testOpenTrue()
|
||||||
{
|
{
|
||||||
$this->mock->expects($this->once())
|
$this->mock->expects($this->once())
|
||||||
->method('open')
|
->method('open')
|
||||||
|
@ -53,12 +53,8 @@ class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertFalse($this->proxy->isActive());
|
$this->assertFalse($this->proxy->isActive());
|
||||||
$this->proxy->open('name', 'id');
|
$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()
|
public function testOpenFalse()
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,12 +60,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||||
$this->isCollected = false;
|
$this->isCollected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS : true;
|
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7);
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$trace = debug_backtrace($trace, 7);
|
|
||||||
} else {
|
|
||||||
$trace = debug_backtrace($trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = $trace[0]['file'];
|
$file = $trace[0]['file'];
|
||||||
$line = $trace[0]['line'];
|
$line = $trace[0]['line'];
|
||||||
|
|
|
@ -107,11 +107,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||||
}
|
}
|
||||||
$renderedAttributes = '';
|
$renderedAttributes = '';
|
||||||
if (count($attributes) > 0) {
|
if (count($attributes) > 0) {
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||||
} else {
|
|
||||||
$flags = ENT_QUOTES;
|
|
||||||
}
|
|
||||||
foreach ($attributes as $attribute => $value) {
|
foreach ($attributes as $attribute => $value) {
|
||||||
$renderedAttributes .= sprintf(
|
$renderedAttributes .= sprintf(
|
||||||
' %s="%s"',
|
' %s="%s"',
|
||||||
|
|
|
@ -181,16 +181,12 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
||||||
$request->attributes->set('foobar', 'foobar');
|
$request->attributes->set('foobar', 'foobar');
|
||||||
$controller = array(new self(), 'controllerMethod3');
|
$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 {
|
try {
|
||||||
$resolver->getArguments($request, $controller);
|
$resolver->getArguments($request, $controller);
|
||||||
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
$this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$controller = array(new self(), 'controllerMethod5');
|
$controller = array(new self(), 'controllerMethod5');
|
||||||
|
|
|
@ -53,37 +53,10 @@ class JsonBundleReader implements BundleReaderInterface
|
||||||
'The resource bundle "%s/%s.json" contains invalid JSON: %s',
|
'The resource bundle "%s/%s.json" contains invalid JSON: %s',
|
||||||
$path,
|
$path,
|
||||||
$locale,
|
$locale,
|
||||||
self::getLastJsonError()
|
json_last_error_msg()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,8 @@ class JsonBundleWriter implements BundleWriterInterface
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
$contents = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n";
|
||||||
// Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs
|
|
||||||
file_put_contents(
|
file_put_contents($path.'/'.$locale.'.json', $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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,8 +187,7 @@ class IntlDateFormatter
|
||||||
/**
|
/**
|
||||||
* Format the date/time value (timestamp) as a string.
|
* Format the date/time value (timestamp) as a string.
|
||||||
*
|
*
|
||||||
* @param int|\DateTime $timestamp The timestamp to format. \DateTime objects
|
* @param int|\DateTime $timestamp The timestamp to format.
|
||||||
* are supported as of PHP 5.3.4.
|
|
||||||
*
|
*
|
||||||
* @return string|bool The formatted value or false if formatting failed.
|
* @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
|
// intl allows timestamps to be passed as arrays - we don't
|
||||||
if (is_array($timestamp)) {
|
if (is_array($timestamp)) {
|
||||||
$message = PHP_VERSION_ID >= 50304 ?
|
$message = 'Only integer Unix timestamps and DateTime objects are supported';
|
||||||
'Only integer Unix timestamps and DateTime objects are supported' :
|
|
||||||
'Only integer Unix timestamps are supported';
|
|
||||||
|
|
||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message);
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// behave like the intl extension
|
// behave like the intl extension
|
||||||
$argumentError = null;
|
$argumentError = null;
|
||||||
if (PHP_VERSION_ID < 50304 && !is_int($timestamp)) {
|
if (!is_int($timestamp) && !$timestamp instanceof \DateTime) {
|
||||||
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value ';
|
|
||||||
} elseif (PHP_VERSION_ID >= 50304 && !is_int($timestamp) && !$timestamp instanceof \DateTime) {
|
|
||||||
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
|
$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);
|
$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
|
// 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();
|
$timestamp = $timestamp->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,11 +370,8 @@ class IntlDateFormatter
|
||||||
return $this->timeZoneId;
|
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();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not supported. Returns the formatter's timezone.
|
* Not supported. Returns the formatter's timezone.
|
||||||
|
@ -540,16 +532,7 @@ class IntlDateFormatter
|
||||||
public function setTimeZoneId($timeZoneId)
|
public function setTimeZoneId($timeZoneId)
|
||||||
{
|
{
|
||||||
if (null === $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();
|
$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';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->unitializedTimeZoneId = true;
|
$this->unitializedTimeZoneId = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,9 +839,7 @@ class NumberFormatter
|
||||||
*
|
*
|
||||||
* @param mixed $value The value to be converted
|
* @param mixed $value The value to be converted
|
||||||
*
|
*
|
||||||
* @return int|float The converted value
|
* @return int|false The converted value
|
||||||
*
|
|
||||||
* @see https://bugs.php.net/bug.php?id=59597 Bug #59597
|
|
||||||
*/
|
*/
|
||||||
private function getInt64Value($value)
|
private function getInt64Value($value)
|
||||||
{
|
{
|
||||||
|
@ -849,30 +847,6 @@ class NumberFormatter
|
||||||
return false;
|
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;
|
return (int) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,6 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('This test requires at least PHP 5.4.0.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->writer = new JsonBundleWriter();
|
$this->writer = new JsonBundleWriter();
|
||||||
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.rand(1000, 9999);
|
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.rand(1000, 9999);
|
||||||
$this->filesystem = new Filesystem();
|
$this->filesystem = new Filesystem();
|
||||||
|
@ -47,10 +43,6 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->filesystem->remove($this->directory);
|
$this->filesystem->remove($this->directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
$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());
|
$this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
|
||||||
} else {
|
|
||||||
$this->assertNull($formatter->getTimeZoneId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +55,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function formatProvider()
|
public function formatProvider()
|
||||||
{
|
{
|
||||||
|
$dateTime = new \DateTime('@0');
|
||||||
|
|
||||||
$formatData = array(
|
$formatData = array(
|
||||||
/* general */
|
/* general */
|
||||||
array('y-M-d', 0, '1970-1-1'),
|
array('y-M-d', 0, '1970-1-1'),
|
||||||
|
@ -236,22 +233,16 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
array('zzz', 0, 'GMT'),
|
array('zzz', 0, 'GMT'),
|
||||||
array('zzzz', 0, 'GMT'),
|
array('zzzz', 0, 'GMT'),
|
||||||
array('zzzzz', 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;
|
return $formatData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,25 +260,11 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function formatErrorProvider()
|
public function formatErrorProvider()
|
||||||
{
|
{
|
||||||
// With PHP 5.5 IntlDateFormatter accepts empty values ('0')
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
return array(
|
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'),
|
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),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider formatWithTimezoneProvider
|
* @dataProvider formatWithTimezoneProvider
|
||||||
*/
|
*/
|
||||||
|
@ -324,16 +301,12 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
|
array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
|
||||||
array(0, 'Europe/Warsaw', '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, '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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,11 +314,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter('zzzz');
|
$formatter = $this->getDefaultDateFormatter('zzzz');
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
$formatter->setTimeZone('GMT+03:00');
|
$formatter->setTimeZone('GMT+03:00');
|
||||||
} else {
|
|
||||||
$formatter->setTimeZoneId('GMT+03:00');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals('GMT+03:00', $formatter->format(0));
|
$this->assertEquals('GMT+03:00', $formatter->format(0));
|
||||||
}
|
}
|
||||||
|
@ -354,11 +323,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter('zzzz');
|
$formatter = $this->getDefaultDateFormatter('zzzz');
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
$formatter->setTimeZone('GMT+00:30');
|
$formatter->setTimeZone('GMT+00:30');
|
||||||
} else {
|
|
||||||
$formatter->setTimeZoneId('GMT+00:30');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals('GMT+00:30', $formatter->format(0));
|
$this->assertEquals('GMT+00:30', $formatter->format(0));
|
||||||
}
|
}
|
||||||
|
@ -367,11 +332,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter('zzzz');
|
$formatter = $this->getDefaultDateFormatter('zzzz');
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
$formatter->setTimeZone('Pacific/Fiji');
|
$formatter->setTimeZone('Pacific/Fiji');
|
||||||
} else {
|
|
||||||
$formatter->setTimeZoneId('Pacific/Fiji');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals('Fiji Standard Time', $formatter->format(0));
|
$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()
|
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();
|
$tz = date_default_timezone_get();
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
@ -843,11 +777,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$formatter = $this->getDefaultDateFormatter();
|
$formatter = $this->getDefaultDateFormatter();
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50500) {
|
|
||||||
$formatter->setTimeZone($timeZoneId);
|
$formatter->setTimeZone($timeZoneId);
|
||||||
} else {
|
|
||||||
$formatter->setTimeZoneId($timeZoneId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId());
|
$this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||||
$formatter->format($localtime);
|
$formatter->format($localtime);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $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());
|
$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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -687,13 +687,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
|
$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);
|
$this->assertInternalType('int', $parsedValue);
|
||||||
} else {
|
|
||||||
$this->assertInternalType('float', $parsedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(-2147483648, $parsedValue);
|
$this->assertEquals(-2147483648, $parsedValue);
|
||||||
}
|
}
|
||||||
|
@ -744,25 +738,13 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
||||||
$parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
|
$parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
|
||||||
$this->assertInternalType('integer', $parsedValue);
|
$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);
|
$parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
|
||||||
$this->assertInternalType('integer', $parsedValue);
|
$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).');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider parseTypeDoubleProvider
|
* @dataProvider parseTypeDoubleProvider
|
||||||
|
|
|
@ -34,10 +34,6 @@ class BCryptPasswordEncoder extends BasePasswordEncoder
|
||||||
*/
|
*/
|
||||||
public function __construct($cost)
|
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;
|
$cost = (int) $cost;
|
||||||
if ($cost < 4 || $cost > 31) {
|
if ($cost < 4 || $cost > 31) {
|
||||||
throw new \InvalidArgumentException('Cost must be in the range of 4-31.');
|
throw new \InvalidArgumentException('Cost must be in the range of 4-31.');
|
||||||
|
|
|
@ -64,11 +64,7 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder
|
||||||
throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm));
|
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);
|
$digest = hash_pbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length, true);
|
||||||
} else {
|
|
||||||
$digest = $this->hashPbkdf2($this->algorithm, $raw, $salt, $this->iterations, $this->length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
|
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));
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testResultLength()
|
public function testResultLength()
|
||||||
{
|
{
|
||||||
$this->skipIfPhpVersionIsNotSupported();
|
|
||||||
|
|
||||||
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
|
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
|
||||||
$result = $encoder->encodePassword(self::PASSWORD, null);
|
$result = $encoder->encodePassword(self::PASSWORD, null);
|
||||||
$this->assertEquals(60, strlen($result));
|
$this->assertEquals(60, strlen($result));
|
||||||
|
@ -56,21 +54,12 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testValidation()
|
public function testValidation()
|
||||||
{
|
{
|
||||||
$this->skipIfPhpVersionIsNotSupported();
|
|
||||||
|
|
||||||
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
|
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
|
||||||
$result = $encoder->encodePassword(self::PASSWORD, null);
|
$result = $encoder->encodePassword(self::PASSWORD, null);
|
||||||
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
|
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
|
||||||
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', 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
|
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,9 +43,7 @@ final class SecureRandom implements SecureRandomInterface
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
||||||
// determine whether to use OpenSSL
|
// determine whether to use OpenSSL
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) {
|
if (!function_exists('openssl_random_pseudo_bytes')) {
|
||||||
$this->useOpenSsl = false;
|
|
||||||
} elseif (!function_exists('openssl_random_pseudo_bytes')) {
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->notice('It is recommended that you enable the "openssl" extension for random number generation.');
|
$this->logger->notice('It is recommended that you enable the "openssl" extension for random number generation.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,6 @@ class NativeSessionTokenStorageTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testStoreTokenInClosedSessionWithExistingSessionId()
|
public function testStoreTokenInClosedSessionWithExistingSessionId()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('This test requires PHP 5.4 or later.');
|
|
||||||
}
|
|
||||||
|
|
||||||
session_id('foobar');
|
session_id('foobar');
|
||||||
|
|
||||||
$this->assertSame(PHP_SESSION_NONE, session_status());
|
$this->assertSame(PHP_SESSION_NONE, session_status());
|
||||||
|
|
|
@ -108,13 +108,9 @@ class NativeSessionTokenStorage implements TokenStorageInterface
|
||||||
|
|
||||||
private function startSession()
|
private function startSession()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
if (PHP_SESSION_NONE === session_status()) {
|
if (PHP_SESSION_NONE === session_status()) {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
} elseif (!session_id()) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sessionStarted = true;
|
$this->sessionStarted = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,7 @@ class JsonDecode implements DecoderInterface
|
||||||
$recursionDepth = $context['json_decode_recursion_depth'];
|
$recursionDepth = $context['json_decode_recursion_depth'];
|
||||||
$options = $context['json_decode_options'];
|
$options = $context['json_decode_options'];
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
||||||
} else {
|
|
||||||
$decodedData = json_decode($data, $associative, $recursionDepth);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
|
if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
|
||||||
throw new UnexpectedValueException(JsonEncoder::getLastErrorMessage());
|
throw new UnexpectedValueException(JsonEncoder::getLastErrorMessage());
|
||||||
|
|
|
@ -99,23 +99,6 @@ class JsonEncoder implements EncoderInterface, DecoderInterface
|
||||||
*/
|
*/
|
||||||
public static function getLastErrorMessage()
|
public static function getLastErrorMessage()
|
||||||
{
|
{
|
||||||
if (function_exists('json_last_error_msg')) {
|
|
||||||
return 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,11 +457,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
||||||
*/
|
*/
|
||||||
protected function initializeEscapers()
|
protected function initializeEscapers()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
|
||||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||||
} else {
|
|
||||||
$flags = ENT_QUOTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->escapers = array(
|
$this->escapers = array(
|
||||||
'html' =>
|
'html' =>
|
||||||
|
@ -488,11 +484,11 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
||||||
* @return string the escaped value
|
* @return string the escaped value
|
||||||
*/
|
*/
|
||||||
function ($value) {
|
function ($value) {
|
||||||
if ('UTF-8' != $that->getCharset()) {
|
if ('UTF-8' != $this->getCharset()) {
|
||||||
$value = $that->convertEncoding($value, 'UTF-8', $that->getCharset());
|
$value = $this->convertEncoding($value, 'UTF-8', $this->getCharset());
|
||||||
}
|
}
|
||||||
|
|
||||||
$callback = function ($matches) use ($that) {
|
$callback = function ($matches) {
|
||||||
$char = $matches[0];
|
$char = $matches[0];
|
||||||
|
|
||||||
// \xHH
|
// \xHH
|
||||||
|
@ -501,7 +497,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
// \uHHHH
|
// \uHHHH
|
||||||
$char = $that->convertEncoding($char, 'UTF-16BE', 'UTF-8');
|
$char = $this->convertEncoding($char, 'UTF-16BE', 'UTF-8');
|
||||||
|
|
||||||
return '\\u'.substr('0000'.bin2hex($char), -4);
|
return '\\u'.substr('0000'.bin2hex($char), -4);
|
||||||
};
|
};
|
||||||
|
@ -511,7 +507,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('UTF-8' != $this->getCharset()) {
|
if ('UTF-8' != $this->getCharset()) {
|
||||||
$value = $this->convertEncoding($value, $that->getCharset(), 'UTF-8');
|
$value = $this->convertEncoding($value, $this->getCharset(), 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
|
|
@ -13,10 +13,6 @@ namespace Symfony\Component\Translation\Dumper;
|
||||||
|
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
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.
|
* JsonFileDumper generates an json formatted string representation of a message catalogue.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,10 +18,6 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testDump()
|
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 = new MessageCatalogue('en');
|
||||||
$catalogue->add(array('foo' => 'bar'));
|
$catalogue->add(array('foo' => 'bar'));
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,6 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
|
||||||
{
|
{
|
||||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '<')) {
|
|
||||||
return $comparisons;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $comparisons;
|
$result = $comparisons;
|
||||||
|
|
||||||
// Duplicate all tests involving DateTime objects to be tested with
|
// Duplicate all tests involving DateTime objects to be tested with
|
||||||
|
|
|
@ -64,10 +64,8 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
array(null, 1),
|
array(null, 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '>=', '5.5')) {
|
|
||||||
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
||||||
$comparisons[] = array($immutableDate, $immutableDate);
|
$comparisons[] = array($immutableDate, $immutableDate);
|
||||||
}
|
|
||||||
|
|
||||||
return $comparisons;
|
return $comparisons;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,8 @@ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'),
|
array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '>=', '5.5')) {
|
|
||||||
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
||||||
$comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime');
|
$comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime');
|
||||||
}
|
|
||||||
|
|
||||||
return $comparisons;
|
return $comparisons;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,11 +194,9 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
array(new \DateTime('March 20, 2014')),
|
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 10, 2014'));
|
||||||
$tests[] = array(new \DateTimeImmutable('March 15, 2014'));
|
$tests[] = array(new \DateTimeImmutable('March 15, 2014'));
|
||||||
$tests[] = array(new \DateTimeImmutable('March 20, 2014'));
|
$tests[] = array(new \DateTimeImmutable('March 20, 2014'));
|
||||||
}
|
|
||||||
|
|
||||||
$this->restoreDefaultTimezone();
|
$this->restoreDefaultTimezone();
|
||||||
|
|
||||||
|
@ -216,10 +214,8 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
|
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 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 9, 2014'), 'Mar 9, 2014, 12:00 AM');
|
||||||
}
|
|
||||||
|
|
||||||
$this->restoreDefaultTimezone();
|
$this->restoreDefaultTimezone();
|
||||||
|
|
||||||
|
@ -237,10 +233,8 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
|
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 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 9, 2015'), 'Mar 9, 2015, 12:00 AM');
|
||||||
}
|
|
||||||
|
|
||||||
$this->restoreDefaultTimezone();
|
$this->restoreDefaultTimezone();
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,6 @@ use Symfony\Component\Validator\Validator\LegacyValidator;
|
||||||
|
|
||||||
class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
|
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())
|
protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array())
|
||||||
{
|
{
|
||||||
$contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator());
|
$contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator());
|
||||||
|
|
|
@ -19,15 +19,6 @@ use Symfony\Component\Validator\Validator\LegacyValidator;
|
||||||
|
|
||||||
class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
|
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())
|
protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array())
|
||||||
{
|
{
|
||||||
$contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator());
|
$contextFactory = new LegacyExecutionContextFactory($metadataFactory, new DefaultTranslator());
|
||||||
|
|
|
@ -112,14 +112,8 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testDefaultApiVersion()
|
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()
|
public function testSetApiVersion24()
|
||||||
{
|
{
|
||||||
|
@ -135,10 +129,6 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testSetApiVersion24And25()
|
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->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC));
|
||||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator());
|
$this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
$this->apiVersion = $apiVersion;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -389,9 +380,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
|
||||||
$apiVersion = $this->apiVersion;
|
$apiVersion = $this->apiVersion;
|
||||||
|
|
||||||
if (null === $apiVersion) {
|
if (null === $apiVersion) {
|
||||||
$apiVersion = PHP_VERSION_ID < 50309
|
$apiVersion = Validation::API_VERSION_2_5_BC;
|
||||||
? Validation::API_VERSION_2_4
|
|
||||||
: Validation::API_VERSION_2_5_BC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Validation::API_VERSION_2_4 === $apiVersion) {
|
if (Validation::API_VERSION_2_4 === $apiVersion) {
|
||||||
|
|
|
@ -266,7 +266,7 @@ class VarCloner extends AbstractCloner
|
||||||
} else {
|
} else {
|
||||||
// check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
|
// 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');
|
$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)) {
|
if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) {
|
||||||
$frame['line'] = 0;
|
$frame['line'] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CliDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
ob_start();
|
ob_start();
|
||||||
$dumper->dump($data);
|
$dumper->dump($data);
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
$closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function';
|
$closureLabel = 'public method';
|
||||||
$out = preg_replace('/[ \t]+$/m', '', $out);
|
$out = preg_replace('/[ \t]+$/m', '', $out);
|
||||||
$intMax = PHP_INT_MAX;
|
$intMax = PHP_INT_MAX;
|
||||||
$res1 = (int) $var['res'];
|
$res1 = (int) $var['res'];
|
||||||
|
|
|
@ -40,7 +40,7 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
ob_start();
|
ob_start();
|
||||||
$dumper->dump($data);
|
$dumper->dump($data);
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
$closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function';
|
$closureLabel = 'public method';
|
||||||
$out = preg_replace('/[ \t]+$/m', '', $out);
|
$out = preg_replace('/[ \t]+$/m', '', $out);
|
||||||
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
|
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
|
||||||
$intMax = PHP_INT_MAX;
|
$intMax = PHP_INT_MAX;
|
||||||
|
|
|
@ -125,12 +125,7 @@ class ParseException extends RuntimeException
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->parsedFile) {
|
if (null !== $this->parsedFile) {
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
|
||||||
} else {
|
|
||||||
$jsonOptions = 0;
|
|
||||||
}
|
|
||||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->parsedLine >= 0) {
|
if ($this->parsedLine >= 0) {
|
||||||
|
|
|
@ -18,11 +18,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetMessage()
|
public function testGetMessage()
|
||||||
{
|
{
|
||||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
$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")';
|
$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")';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($message, $exception->getMessage());
|
$this->assertEquals($message, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -30,11 +26,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetMessageWithUnicodeInFilename()
|
public function testGetMessageWithUnicodeInFilename()
|
||||||
{
|
{
|
||||||
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
$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")';
|
$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")';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($message, $exception->getMessage());
|
$this->assertEquals($message, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue