Remove code for PHP <5.5.9
This commit is contained in:
parent
dda085e8c4
commit
879771170e
@ -40,7 +40,7 @@ class DeprecationErrorHandler
|
|||||||
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT : true);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||||
|
|
||||||
$i = count($trace);
|
$i = count($trace);
|
||||||
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
|
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
|
||||||
|
@ -196,7 +196,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
|
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
|
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -171,12 +171,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
private function writeData(array $data, array $options)
|
private function writeData(array $data, array $options)
|
||||||
{
|
{
|
||||||
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
||||||
if (defined('JSON_PRETTY_PRINT')) {
|
|
||||||
$flags |= JSON_PRETTY_PRINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->write(json_encode($data, $flags)."\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,12 +280,10 @@ class ClassCollectionLoader
|
|||||||
|
|
||||||
$traits = array();
|
$traits = array();
|
||||||
|
|
||||||
if (function_exists('get_declared_traits')) {
|
foreach ($classes as $c) {
|
||||||
foreach ($classes as $c) {
|
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
||||||
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
|
if ($trait !== $c) {
|
||||||
if ($trait !== $c) {
|
$traits[] = $trait;
|
||||||
$traits[] = $trait;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ class Command
|
|||||||
throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.');
|
throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
|
if ($code instanceof \Closure) {
|
||||||
$r = new \ReflectionFunction($code);
|
$r = new \ReflectionFunction($code);
|
||||||
if (null === $r->getClosureThis()) {
|
if (null === $r->getClosureThis()) {
|
||||||
$code = \Closure::bind($code, $this);
|
$code = \Closure::bind($code, $this);
|
||||||
|
@ -295,10 +295,6 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
/** @dataProvider getSetCodeBindToClosureTests */
|
/** @dataProvider getSetCodeBindToClosureTests */
|
||||||
public function testSetCodeBindToClosure($previouslyBound, $expected)
|
public function testSetCodeBindToClosure($previouslyBound, $expected)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50400) {
|
|
||||||
$this->markTestSkipped('Test skipped, for PHP 5.4+ only.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$code = createClosure();
|
$code = createClosure();
|
||||||
if ($previouslyBound) {
|
if ($previouslyBound) {
|
||||||
$code = $code->bindTo($this);
|
$code = $code->bindTo($this);
|
||||||
|
@ -698,9 +698,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container');
|
$class = new \ReflectionClass('Symfony\Component\DependencyInjection\Container');
|
||||||
$clone = $class->getMethod('__clone');
|
$clone = $class->getMethod('__clone');
|
||||||
if (PHP_VERSION_ID >= 540000) {
|
$this->assertFalse($class->isCloneable());
|
||||||
$this->assertFalse($class->isCloneable());
|
|
||||||
}
|
|
||||||
$this->assertTrue($clone->isPrivate());
|
$this->assertTrue($clone->isPrivate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,10 +118,6 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
|||||||
|
|
||||||
public function testTransformDateTimeImmutable()
|
public function testTransformDateTimeImmutable()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
$this->markTestSkipped('DateTimeImmutable was introduced in PHP 5.5.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
|
$transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||||
|
|
||||||
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
||||||
|
@ -143,10 +143,6 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
|||||||
|
|
||||||
public function testTransformDateTimeImmutableTimezones()
|
public function testTransformDateTimeImmutableTimezones()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
$this->markTestSkipped('DateTimeImmutable was introduced in PHP 5.5.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
|
$transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
|
||||||
|
|
||||||
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
||||||
|
@ -84,10 +84,6 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
|
|||||||
*/
|
*/
|
||||||
public function testTransformDateTimeImmutable($fromTz, $toTz, $from, $to)
|
public function testTransformDateTimeImmutable($fromTz, $toTz, $from, $to)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
$this->markTestSkipped('DateTimeImmutable was introduced in PHP 5.5.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new DateTimeToRfc3339Transformer($fromTz, $toTz);
|
$transformer = new DateTimeToRfc3339Transformer($fromTz, $toTz);
|
||||||
|
|
||||||
$this->assertSame($to, $transformer->transform(null !== $from ? new \DateTimeImmutable($from) : null));
|
$this->assertSame($to, $transformer->transform(null !== $from ? new \DateTimeImmutable($from) : null));
|
||||||
|
@ -97,10 +97,6 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
|||||||
|
|
||||||
public function testTransformDateTimeImmutable()
|
public function testTransformDateTimeImmutable()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
$this->markTestSkipped('DateTimeImmutable was introduced in PHP 5.5.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s');
|
$transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s');
|
||||||
|
|
||||||
$input = new \DateTimeImmutable('2010-02-03 12:05:06 America/New_York');
|
$input = new \DateTimeImmutable('2010-02-03 12:05:06 America/New_York');
|
||||||
|
@ -58,10 +58,6 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
|||||||
|
|
||||||
public function testTransformDateTimeImmutable()
|
public function testTransformDateTimeImmutable()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
$this->markTestSkipped('DateTimeImmutable was introduced in PHP 5.5.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
|
$transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
|
||||||
|
|
||||||
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
$input = new \DateTimeImmutable('2010-02-03 04:05:06 America/New_York');
|
||||||
|
@ -102,39 +102,12 @@ class JsonResponse extends Response
|
|||||||
$data = json_encode($data, $this->encodingOptions);
|
$data = json_encode($data, $this->encodingOptions);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (PHP_VERSION_ID < 50400) {
|
// PHP 5.4 and up wrap exceptions thrown by JsonSerializable
|
||||||
// PHP 5.3 triggers annoying warnings for some
|
// objects in a new exception that needs to be removed.
|
||||||
// types that can't be serialized as JSON (INF, resources, etc.)
|
// Fortunately, PHP 5.5 and up do not trigger any warning anymore.
|
||||||
// but doesn't provide the JsonSerializable interface.
|
$data = json_encode($data, $this->encodingOptions);
|
||||||
set_error_handler('var_dump', 0);
|
|
||||||
$data = @json_encode($data, $this->encodingOptions);
|
|
||||||
} else {
|
|
||||||
// PHP 5.4 and up wrap exceptions thrown by JsonSerializable
|
|
||||||
// objects in a new exception that needs to be removed.
|
|
||||||
// Fortunately, PHP 5.5 and up do not trigger any warning anymore.
|
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
// Clear json_last_error()
|
|
||||||
json_encode(null);
|
|
||||||
$errorHandler = set_error_handler('var_dump');
|
|
||||||
restore_error_handler();
|
|
||||||
set_error_handler(function () use ($errorHandler) {
|
|
||||||
if (JSON_ERROR_NONE === json_last_error()) {
|
|
||||||
return $errorHandler && false !== call_user_func_array($errorHandler, func_get_args());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = json_encode($data, $this->encodingOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50500) {
|
|
||||||
restore_error_handler();
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (PHP_VERSION_ID < 50500) {
|
if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
|
||||||
restore_error_handler();
|
|
||||||
}
|
|
||||||
if (PHP_VERSION_ID >= 50400 && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
|
|
||||||
throw $e->getPrevious() ?: $e;
|
throw $e->getPrevious() ?: $e;
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -1247,6 +1247,7 @@ class Response
|
|||||||
{
|
{
|
||||||
$status = ob_get_status(true);
|
$status = ob_get_status(true);
|
||||||
$level = count($status);
|
$level = count($status);
|
||||||
|
// PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
|
||||||
$flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
|
$flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
|
||||||
|
|
||||||
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) {
|
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) {
|
||||||
|
@ -247,7 +247,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
|||||||
|
|
||||||
private function doDump($data, $name, $file, $line)
|
private function doDump($data, $name, $file, $line)
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) {
|
if ($this->dumper instanceof CliDumper) {
|
||||||
$contextDumper = function ($name, $file, $line, $fileLinkFormat) {
|
$contextDumper = function ($name, $file, $line, $fileLinkFormat) {
|
||||||
if ($this instanceof HtmlDumper) {
|
if ($this instanceof HtmlDumper) {
|
||||||
if ('' !== $file) {
|
if ('' !== $file) {
|
||||||
|
@ -71,11 +71,7 @@ class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$collector->collect(new Request(), new Response());
|
$collector->collect(new Request(), new Response());
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
|
||||||
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
|
|
||||||
} else {
|
|
||||||
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n123\n", $output);
|
|
||||||
}
|
|
||||||
$this->assertSame(1, $collector->getDumpsCount());
|
$this->assertSame(1, $collector->getDumpsCount());
|
||||||
$collector->serialize();
|
$collector->serialize();
|
||||||
}
|
}
|
||||||
@ -89,23 +85,12 @@ class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$collector->dump($data);
|
$collector->dump($data);
|
||||||
$line = __LINE__ - 1;
|
$line = __LINE__ - 1;
|
||||||
$file = __FILE__;
|
$file = __FILE__;
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
$xOutput = <<<EOTXT
|
||||||
$xOutput = <<<EOTXT
|
|
||||||
<pre class=sf-dump id=sf-dump data-indent-pad=" "><a href="test://{$file}:{$line}" title="{$file}"><span class=sf-dump-meta>DumpDataCollectorTest.php</span></a> on line <span class=sf-dump-meta>{$line}</span>:
|
<pre class=sf-dump id=sf-dump data-indent-pad=" "><a href="test://{$file}:{$line}" title="{$file}"><span class=sf-dump-meta>DumpDataCollectorTest.php</span></a> on line <span class=sf-dump-meta>{$line}</span>:
|
||||||
<span class=sf-dump-num>123</span>
|
<span class=sf-dump-num>123</span>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
EOTXT;
|
EOTXT;
|
||||||
} else {
|
|
||||||
$len = strlen("DumpDataCollectorTest.php on line {$line}:");
|
|
||||||
$xOutput = <<<EOTXT
|
|
||||||
<pre class=sf-dump id=sf-dump data-indent-pad=" ">"<span class=sf-dump-str title="{$len} characters">DumpDataCollectorTest.php on line {$line}:</span>"
|
|
||||||
</pre>
|
|
||||||
<pre class=sf-dump id=sf-dump data-indent-pad=" "><span class=sf-dump-num>123</span>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
EOTXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
@ -129,10 +114,6 @@ EOTXT;
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$collector = null;
|
$collector = null;
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
|
||||||
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
|
|
||||||
} else {
|
|
||||||
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,7 @@ class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInte
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case self::MIGRATE:
|
case self::MIGRATE:
|
||||||
// Destroying the old session is broken in php 5.4.0 - 5.4.10
|
$request->getSession()->migrate(true);
|
||||||
// See php bug #63379
|
|
||||||
$destroy = PHP_VERSION_ID < 50400 || PHP_VERSION_ID >= 50411;
|
|
||||||
$request->getSession()->migrate($destroy);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -39,10 +39,6 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testSessionIsMigrated()
|
public function testSessionIsMigrated()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50411) {
|
|
||||||
$this->markTestSkipped('We cannot destroy the old session on PHP 5.4.0 - 5.4.10.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
||||||
$session->expects($this->once())->method('migrate')->with($this->equalTo(true));
|
$session->expects($this->once())->method('migrate')->with($this->equalTo(true));
|
||||||
|
|
||||||
@ -50,19 +46,6 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
|
|||||||
$strategy->onAuthentication($this->getRequest($session), $this->getToken());
|
$strategy->onAuthentication($this->getRequest($session), $this->getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSessionIsMigratedWithPhp54Workaround()
|
|
||||||
{
|
|
||||||
if (PHP_VERSION_ID < 50400 || PHP_VERSION_ID >= 50411) {
|
|
||||||
$this->markTestSkipped('This PHP version is not affected.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
|
||||||
$session->expects($this->once())->method('migrate')->with($this->equalTo(false));
|
|
||||||
|
|
||||||
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
|
|
||||||
$strategy->onAuthentication($this->getRequest($session), $this->getToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSessionIsInvalidated()
|
public function testSessionIsInvalidated()
|
||||||
{
|
{
|
||||||
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
||||||
|
Reference in New Issue
Block a user