minor #23021 Using FQ name for PHP_VERSION_ID (fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

Using FQ name for PHP_VERSION_ID

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22650, replaces #23000
| License       | MIT
| Doc PR        | n/a

Commits
-------

f91a020b84 Using FQ name for PHP_VERSION_ID
This commit is contained in:
Fabien Potencier 2017-06-01 13:48:21 -07:00
commit 78c4a5ff43
65 changed files with 121 additions and 121 deletions

View File

@ -11,7 +11,7 @@ array_shift($dirs);
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
$packages = array();
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
$flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
foreach ($dirs as $k => $dir) {
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {

View File

@ -7,7 +7,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}
if (PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
if (\PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.0');
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');

View File

@ -174,7 +174,7 @@ class CodeExtension extends \Twig_Extension
$text = "$text at line $line";
if (false !== $link = $this->getFileLink($file, $line)) {
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;

View File

@ -81,9 +81,9 @@ if ($this->env->isDebug()) {
}
EOTXT;
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
} elseif (PHP_VERSION_ID >= 50400) {
} elseif (\PHP_VERSION_ID >= 50400) {
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
} else {
$expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected);
@ -114,9 +114,9 @@ if ($this->env->isDebug()) {
EOTXT;
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
} elseif (PHP_VERSION_ID >= 50400) {
} elseif (\PHP_VERSION_ID >= 50400) {
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
} else {
$expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected);

View File

@ -67,11 +67,11 @@ class FormThemeTest extends TestCase
protected function getVariableGetter($name)
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
}
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
}

View File

@ -264,11 +264,11 @@ class SearchAndRenderBlockNodeTest extends TestCase
protected function getVariableGetter($name)
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
}
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
}

View File

@ -40,11 +40,11 @@ class TransNodeTest extends TestCase
protected function getVariableGetterWithoutStrictCheck($name)
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
}
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
}
@ -57,11 +57,11 @@ class TransNodeTest extends TestCase
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
}
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
}
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
}

View File

@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand
*/
public function isEnabled()
{
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
if (\PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
return false;
}

View File

@ -154,7 +154,7 @@ class CodeHelper extends Helper
*/
public function formatFile($file, $line, $text = null)
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;

View File

@ -85,7 +85,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
foreach ($files as $file) {
$this->parseTokens(token_get_all(file_get_contents($file)), $catalog);
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
gc_mem_caches();
}

View File

@ -232,7 +232,7 @@ REGEX;
$output .= self::compressCode($rawChunk);
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
unset($tokens, $rawChunk);
gc_mem_caches();

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\ClassLoader;
if (!defined('SYMFONY_TRAIT')) {
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
define('SYMFONY_TRAIT', T_TRAIT);
} else {
define('SYMFONY_TRAIT', 0);
@ -72,7 +72,7 @@ class ClassMapGenerator
$classes = self::findClasses($path);
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
gc_mem_caches();
}

View File

@ -108,7 +108,7 @@ class ClassMapGeneratorTest extends TestCase
)),
);
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$data[] = array(__DIR__.'/Fixtures/php5.4', array(
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
@ -119,7 +119,7 @@ class ClassMapGeneratorTest extends TestCase
));
}
if (PHP_VERSION_ID >= 50500) {
if (\PHP_VERSION_ID >= 50500) {
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
));

View File

@ -247,7 +247,7 @@ class TextDescriptor extends Descriptor
}
}
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
}

View File

@ -404,7 +404,7 @@ class ErrorHandler
$throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
}
if (PHP_VERSION_ID <= 50407 && (PHP_VERSION_ID >= 50400 || PHP_VERSION_ID <= 50317)) {
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.

View File

@ -434,7 +434,7 @@ EOF;
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
}
/**
@ -442,7 +442,7 @@ EOF;
*/
private function escapeHtml($str)
{
return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
}
/**

View File

@ -61,7 +61,7 @@ class DebugClassLoaderTest extends TestCase
public function testUnsilencing()
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
}
if (defined('HHVM_VERSION')) {
@ -111,7 +111,7 @@ class DebugClassLoaderTest extends TestCase
restore_error_handler();
restore_exception_handler();
$this->assertStringStartsWith(__FILE__, $exception->getFile());
if (PHP_VERSION_ID < 70000) {
if (\PHP_VERSION_ID < 70000) {
$this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage());
$this->assertEquals(E_STRICT, $exception->getSeverity());
} else {
@ -227,7 +227,7 @@ class DebugClassLoaderTest extends TestCase
public function testReservedForPhp7()
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('PHP7 already prevents using reserved names.');
}

View File

@ -344,7 +344,7 @@ class Parser
$node = new Node\GetAttrNode($node, $arg, $arguments, $type);
} elseif ('[' === $token->value) {
if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && PHP_VERSION_ID < 50400) {
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->getExpression());
}

View File

@ -29,7 +29,7 @@ abstract class FilterIterator extends \FilterIterator
*/
public function rewind()
{
if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
parent::rewind();
return;

View File

@ -119,7 +119,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
}
// @see https://bugs.php.net/68557
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
parent::next();
}

View File

@ -272,7 +272,7 @@ class DateType extends AbstractType
$timezone = $formatter->getTimezoneId();
$formattedTimestamps = array();
if ($setTimeZone = PHP_VERSION_ID >= 50500 || method_exists($formatter, 'setTimeZone')) {
if ($setTimeZone = \PHP_VERSION_ID >= 50500 || method_exists($formatter, 'setTimeZone')) {
$formatter->setTimeZone('UTC');
} else {
$formatter->setTimeZoneId('UTC');

View File

@ -85,7 +85,7 @@ class DefaultCsrfProvider implements CsrfProviderInterface
*/
protected function getSessionId()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
if (PHP_SESSION_NONE === session_status()) {
session_start();
}

View File

@ -90,7 +90,7 @@ class ValidatorTypeGuesserTest extends TestCase
*/
public function testLegacyGuessRequired()
{
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Cannot use a class called True on PHP 7 or higher.');
}
$true = 'Symfony\Component\Validator\Constraints\True';

View File

@ -121,7 +121,7 @@ class JsonResponse extends Response
$data = json_encode($data, $this->encodingOptions);
} else {
try {
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
// PHP 5.3 triggers annoying warnings for some
// types that can't be serialized as JSON (INF, resources, etc.)
// but doesn't provide the JsonSerializable interface.
@ -131,7 +131,7 @@ class JsonResponse extends Response
// 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) {
if (\PHP_VERSION_ID < 50500) {
// Clear json_last_error()
json_encode(null);
$errorHandler = set_error_handler('var_dump');
@ -146,14 +146,14 @@ class JsonResponse extends Response
$data = json_encode($data, $this->encodingOptions);
}
if (PHP_VERSION_ID < 50500) {
if (\PHP_VERSION_ID < 50500) {
restore_error_handler();
}
} catch (\Exception $e) {
if (PHP_VERSION_ID < 50500) {
if (\PHP_VERSION_ID < 50500) {
restore_error_handler();
}
if (PHP_VERSION_ID >= 50400 && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
if (\PHP_VERSION_ID >= 50400 && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
throw $e->getPrevious() ?: $e;
}
throw $e;

View File

@ -1502,7 +1502,7 @@ class Request
public function getContent($asResource = false)
{
$currentContentIsResource = is_resource($this->content);
if (PHP_VERSION_ID < 50600 && false === $this->content) {
if (\PHP_VERSION_ID < 50600 && false === $this->content) {
throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.');
}

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
// Adds SessionHandler functionality if available.
// @see http://php.net/sessionhandler
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
class NativeSessionHandler extends \SessionHandler
{
}

View File

@ -102,7 +102,7 @@ class NativeSessionStorage implements SessionStorageInterface
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
ini_set('session.use_cookies', 1);
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
session_register_shutdown();
} else {
register_shutdown_function('session_write_close');
@ -132,11 +132,11 @@ class NativeSessionStorage implements SessionStorageInterface
return true;
}
if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) {
if (\PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) {
throw new \RuntimeException('Failed to start the session: already started by PHP.');
}
if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) {
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).');
}
@ -197,12 +197,12 @@ class NativeSessionStorage implements SessionStorageInterface
public function regenerate($destroy = false, $lifetime = null)
{
// Cannot regenerate the session ID for non-active sessions.
if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE !== session_status()) {
if (\PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE !== session_status()) {
return false;
}
// Check if session ID exists in PHP 5.3
if (PHP_VERSION_ID < 50400 && '' === session_id()) {
if (\PHP_VERSION_ID < 50400 && '' === session_id()) {
return false;
}
@ -384,13 +384,13 @@ class NativeSessionStorage implements SessionStorageInterface
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
$saveHandler = new SessionHandlerProxy($saveHandler);
} elseif (!$saveHandler instanceof AbstractProxy) {
$saveHandler = PHP_VERSION_ID >= 50400 ?
$saveHandler = \PHP_VERSION_ID >= 50400 ?
new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy();
}
$this->saveHandler = $saveHandler;
if ($this->saveHandler instanceof \SessionHandlerInterface) {
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
session_set_save_handler($this->saveHandler, false);
} else {
session_set_save_handler(

View File

@ -72,7 +72,7 @@ abstract class AbstractProxy
*/
public function isActive()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return $this->active = \PHP_SESSION_ACTIVE === session_status();
}
@ -93,7 +93,7 @@ abstract class AbstractProxy
*/
public function setActive($flag)
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
throw new \LogicException('This method is disabled in PHP 5.4.0+');
}

View File

@ -1029,7 +1029,7 @@ class RequestTest extends TestCase
*/
public function testGetContentCantBeCalledTwiceWithResources($first, $second)
{
if (PHP_VERSION_ID >= 50600) {
if (\PHP_VERSION_ID >= 50600) {
$this->markTestSkipped('PHP >= 5.6 allows to open php://input several times.');
}

View File

@ -29,7 +29,7 @@ class NativeFileSessionHandlerTest extends TestCase
{
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
$this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
$this->assertEquals('files', ini_get('session.save_handler'));
} else {

View File

@ -30,7 +30,7 @@ class NativeSessionHandlerTest extends TestCase
// 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) {
if (\PHP_VERSION_ID < 50400) {
$this->assertFalse($handler instanceof \SessionHandler);
$this->assertTrue($handler instanceof NativeSessionHandler);
} else {

View File

@ -196,7 +196,7 @@ class NativeSessionStorageTest extends TestCase
public function testSetSaveHandler53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
@ -249,7 +249,7 @@ class NativeSessionStorageTest extends TestCase
session_start();
$this->assertTrue(isset($_SESSION));
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
// this only works in PHP >= 5.4 where session_status is available
$this->assertTrue($storage->getSaveHandler()->isActive());
}

View File

@ -62,7 +62,7 @@ class PhpBridgeSessionStorageTest extends TestCase
public function testPhpSession53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

View File

@ -88,7 +88,7 @@ class AbstractProxyTest extends TestCase
public function testIsActivePhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
@ -109,7 +109,7 @@ class AbstractProxyTest extends TestCase
public function testSetActivePhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
@ -147,7 +147,7 @@ class AbstractProxyTest extends TestCase
*/
public function testNameExceptionPhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
@ -184,7 +184,7 @@ class AbstractProxyTest extends TestCase
*/
public function testIdExceptionPhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

View File

@ -54,7 +54,7 @@ class SessionHandlerProxyTest extends TestCase
$this->assertFalse($this->proxy->isActive());
$this->proxy->open('name', 'id');
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
$this->assertTrue($this->proxy->isActive());
} else {
$this->assertFalse($this->proxy->isActive());

View File

@ -71,7 +71,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
}
$trace = DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS;
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$trace = debug_backtrace($trace, 7);
} else {
$trace = debug_backtrace($trace);
@ -263,7 +263,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
private function doDump($data, $name, $file, $line)
{
if (PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) {
if (\PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) {
$contextDumper = function ($name, $file, $line, $fileLinkFormat) {
if ($this instanceof HtmlDumper) {
if ('' !== $file) {

View File

@ -107,7 +107,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
}
$renderedAttributes = '';
if (count($attributes) > 0) {
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;

View File

@ -753,7 +753,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
$output .= $rawChunk;
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
unset($tokens, $rawChunk);
gc_mem_caches();

View File

@ -184,7 +184,7 @@ class ControllerResolverTest extends TestCase
$request->attributes->set('foobar', 'foobar');
$controller = array(new self(), 'controllerMethod3');
if (PHP_VERSION_ID === 50316) {
if (\PHP_VERSION_ID === 50316) {
$this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system');
} else {
try {

View File

@ -68,7 +68,7 @@ class DumpDataCollectorTest extends TestCase
$collector->collect(new Request(), new Response());
$output = ob_get_clean();
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
} else {
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n123\n", $output);
@ -86,7 +86,7 @@ class DumpDataCollectorTest extends TestCase
$collector->dump($data);
$line = __LINE__ - 1;
$file = __FILE__;
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$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>:
<span class=sf-dump-num>123</span>
@ -124,7 +124,7 @@ EOTXT;
ob_start();
$collector->__destruct();
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$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());

View File

@ -35,7 +35,7 @@ class JsonBundleWriter implements BundleWriterInterface
}
});
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
// Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs
file_put_contents(
$path.'/'.$locale.'.json',

View File

@ -209,7 +209,7 @@ class IntlDateFormatter
$argumentError = null;
if (!is_int($timestamp) && !$timestamp instanceof \DateTime) {
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
}
}
@ -371,7 +371,7 @@ class IntlDateFormatter
}
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
return date_default_timezone_get();
}
}
@ -536,7 +536,7 @@ class IntlDateFormatter
{
if (null === $timeZoneId) {
// In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$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
@ -567,7 +567,7 @@ class IntlDateFormatter
$timeZone = $this->getTimeZoneId();
}
} catch (\Exception $e) {
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$timeZoneId = $timeZone = $this->getTimeZoneId();
} else {
$timeZoneId = 'UTC';

View File

@ -854,7 +854,7 @@ class NumberFormatter
// The negative PHP_INT_MAX was being converted to float
if (
$value == -self::$int32Max - 1 &&
((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone')))
((\PHP_VERSION_ID < 50400 && \PHP_VERSION_ID >= 50314) || \PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone')))
) {
return (int) $value;
}
@ -867,7 +867,7 @@ class NumberFormatter
// A 32 bit integer was being generated instead of a 64 bit integer
if (
($value > self::$int32Max || $value < -self::$int32Max - 1) &&
(PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) &&
(\PHP_VERSION_ID < 50314 || (\PHP_VERSION_ID >= 50400 && \PHP_VERSION_ID < 50404)) &&
!(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))
) {
$value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value));

View File

@ -51,7 +51,7 @@ class IntlBundleReaderTest extends TestCase
public function testReadDoesNotFollowFallback()
{
if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) {
if (\PHP_VERSION_ID < 50307 || \PHP_VERSION_ID === 50400) {
$this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.');
}
@ -71,7 +71,7 @@ class IntlBundleReaderTest extends TestCase
public function testReadDoesNotFollowFallbackAlias()
{
if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) {
if (\PHP_VERSION_ID < 50307 || \PHP_VERSION_ID === 50400) {
$this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.');
}

View File

@ -44,7 +44,7 @@ class JsonBundleWriterTest extends TestCase
protected function tearDown()
{
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
return;
}

View File

@ -69,7 +69,7 @@ class PhpBundleWriterTest extends TestCase
*/
public function testWriteResourceBundle()
{
if (PHP_VERSION_ID < 50315 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) {
if (\PHP_VERSION_ID < 50315 || (\PHP_VERSION_ID >= 50400 && \PHP_VERSION_ID < 50404)) {
$this->markTestSkipped('ResourceBundle implements Traversable only as of PHP 5.3.15 and 5.4.4');
}

View File

@ -37,7 +37,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
// In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
} else {
$this->assertNull($formatter->getTimeZoneId());
@ -277,7 +277,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
public function formatErrorProvider()
{
// With PHP 5.5 IntlDateFormatter accepts empty values ('0')
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
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'),
);
@ -330,7 +330,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
);
// As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC
if (PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
// 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');
@ -413,7 +413,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
{
$formatter = $this->getDefaultDateFormatter('zzzz');
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$formatter->setTimeZone('GMT+03:00');
} else {
$formatter->setTimeZoneId('GMT+03:00');
@ -426,7 +426,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
{
$formatter = $this->getDefaultDateFormatter('zzzz');
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$formatter->setTimeZone('GMT+00:30');
} else {
$formatter->setTimeZoneId('GMT+00:30');
@ -439,7 +439,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
{
$formatter = $this->getDefaultDateFormatter('zzzz');
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$formatter->setTimeZone('Pacific/Fiji');
} else {
$formatter->setTimeZoneId('Pacific/Fiji');
@ -471,7 +471,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
public function testFormatWithDateTimeZoneGmtOffset()
{
if (defined('HHVM_VERSION_ID') || PHP_VERSION_ID <= 50509) {
if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) {
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
}
@ -485,7 +485,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
if (!extension_loaded('intl')) {
$this->markTestSkipped('Extension intl is required.');
}
if (PHP_VERSION_ID < 50500 && !method_exists('IntlDateFormatter', 'setTimeZone')) {
if (\PHP_VERSION_ID < 50500 && !method_exists('IntlDateFormatter', 'setTimeZone')) {
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
}
@ -496,7 +496,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
public function testFormatWithTimezoneFromEnvironmentVariable()
{
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
}
@ -519,7 +519,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
public function testFormatWithTimezoneFromPhp()
{
if (PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
}
@ -949,7 +949,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
{
$formatter = $this->getDefaultDateFormatter();
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$formatter->setTimeZone($timeZoneId);
} else {
$formatter->setTimeZoneId($timeZoneId);
@ -960,7 +960,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
public function setTimeZoneIdProvider()
{
$isPhp55 = PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'));
$isPhp55 = \PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'));
return array(
array('UTC', 'UTC'),

View File

@ -701,7 +701,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
// 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 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if ((\PHP_VERSION_ID < 50400 && \PHP_VERSION_ID >= 50314) || \PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->assertInternalType('int', $parsedValue);
} else {
$this->assertInternalType('float', $parsedValue);
@ -758,7 +758,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
// 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)) {
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).');
@ -769,7 +769,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
// 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)) {
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).');

View File

@ -166,7 +166,7 @@ class PropertyAccessor implements PropertyAccessorInterface
$overwrite = true;
try {
if (PHP_VERSION_ID < 70000 && false === self::$previousErrorHandler) {
if (\PHP_VERSION_ID < 70000 && false === self::$previousErrorHandler) {
self::$previousErrorHandler = set_error_handler(self::$errorHandler);
}
@ -222,7 +222,7 @@ class PropertyAccessor implements PropertyAccessorInterface
} catch (\Throwable $e) {
}
if (PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
if (\PHP_VERSION_ID < 70000 && false !== self::$previousErrorHandler) {
restore_error_handler();
self::$previousErrorHandler = false;
}

View File

@ -64,7 +64,7 @@ class AnnotationFileLoader extends FileLoader
$collection->addResource(new FileResource($path));
$collection->addCollection($this->loader->load($class, $type));
}
if (PHP_VERSION_ID >= 70000) {
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
gc_mem_caches();
}

View File

@ -108,7 +108,7 @@ class NativeSessionTokenStorage implements TokenStorageInterface
private function startSession()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
if (PHP_SESSION_NONE === session_status()) {
session_start();
}

View File

@ -49,7 +49,7 @@ class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInte
case self::MIGRATE:
// Destroying the old session is broken in php 5.4.0 - 5.4.10
// See php bug #63379
$destroy = PHP_VERSION_ID < 50400 || PHP_VERSION_ID >= 50411;
$destroy = \PHP_VERSION_ID < 50400 || \PHP_VERSION_ID >= 50411;
$request->getSession()->migrate($destroy);
return;

View File

@ -40,7 +40,7 @@ class SessionAuthenticationStrategyTest extends TestCase
public function testSessionIsMigrated()
{
if (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50411) {
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.');
}
@ -53,7 +53,7 @@ class SessionAuthenticationStrategyTest extends TestCase
public function testSessionIsMigratedWithPhp54Workaround()
{
if (PHP_VERSION_ID < 50400 || PHP_VERSION_ID >= 50411) {
if (\PHP_VERSION_ID < 50400 || \PHP_VERSION_ID >= 50411) {
$this->markTestSkipped('This PHP version is not affected.');
}

View File

@ -101,7 +101,7 @@ class JsonDecode implements DecoderInterface
$recursionDepth = $context['json_decode_recursion_depth'];
$options = $context['json_decode_options'];
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
} else {
$decodedData = json_decode($data, $associative, $recursionDepth);

View File

@ -417,7 +417,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
protected function initializeEscapers()
{
$that = $this;
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
} else {
$flags = ENT_QUOTES;

View File

@ -19,7 +19,7 @@ class JsonFileDumperTest extends TestCase
{
public function testDump()
{
if (PHP_VERSION_ID < 50400) {
if (\PHP_VERSION_ID < 50400) {
$this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing');
}

View File

@ -36,7 +36,7 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
{
protected static function addPhp5Dot5Comparisons(array $comparisons)
{
if (PHP_VERSION_ID < 50500) {
if (\PHP_VERSION_ID < 50500) {
return $comparisons;
}
@ -130,7 +130,7 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
if ($dirtyValue instanceof \DateTime || $dirtyValue instanceof \DateTimeInterface) {
IntlTestHelper::requireIntl($this, '57.1');
if (PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
if (\PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4');
}
}

View File

@ -64,7 +64,7 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
array(null, 1),
);
if (PHP_VERSION_ID >= 50500) {
if (\PHP_VERSION_ID >= 50500) {
$immutableDate = new \DateTimeImmutable('2000-01-01');
$comparisons[] = array($immutableDate, $immutableDate);
}

View File

@ -194,7 +194,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
array(new \DateTime('March 20, 2014')),
);
if (PHP_VERSION_ID >= 50500) {
if (\PHP_VERSION_ID >= 50500) {
$tests[] = array(new \DateTimeImmutable('March 10, 2014'));
$tests[] = array(new \DateTimeImmutable('March 15, 2014'));
$tests[] = array(new \DateTimeImmutable('March 20, 2014'));
@ -216,7 +216,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
);
if (PHP_VERSION_ID >= 50500) {
if (\PHP_VERSION_ID >= 50500) {
$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');
}
@ -237,7 +237,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
);
if (PHP_VERSION_ID >= 50500) {
if (\PHP_VERSION_ID >= 50500) {
$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');
}

View File

@ -308,7 +308,7 @@ class VarCloner extends AbstractCloner
} else {
// check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
$obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush');
foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) {
foreach (debug_backtrace(\PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) {
if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], $obFuncs)) {
$frame['line'] = 0;
break;

View File

@ -45,7 +45,7 @@ class CliDumperTest extends VarDumperTestCase
$closure54 = '';
$r = defined('HHVM_VERSION') ? '' : '#%d';
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$closure54 = <<<EOTXT
class: "Symfony\Component\VarDumper\Tests\CliDumperTest"
@ -364,7 +364,7 @@ EOTXT
*/
public function testBuggyRefs()
{
if (PHP_VERSION_ID >= 50600) {
if (\PHP_VERSION_ID >= 50600) {
$this->markTestSkipped('PHP 5.6 fixed refs counting');
}

View File

@ -49,7 +49,7 @@ class HtmlDumperTest extends TestCase
$closure54 = '';
$r = defined('HHVM_VERSION') ? '' : '<a class=sf-dump-ref>#%d</a>';
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$closure54 = <<<EOTXT
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="48 characters">Symfony\Component\VarDumper\Tests\HtmlDumperTest</span>"

View File

@ -10,6 +10,6 @@
*/
// Skipping trait tests for PHP < 5.4
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
require __DIR__.'/VarDumperTestTraitRequire54.php';
}

View File

@ -123,7 +123,7 @@ class ParseException extends RuntimeException
}
if (null !== $this->parsedFile) {
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
} else {
$jsonOptions = 0;

View File

@ -19,7 +19,7 @@ class ParseExceptionTest extends TestCase
public function testGetMessage()
{
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
} else {
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
@ -31,7 +31,7 @@ class ParseExceptionTest extends TestCase
public function testGetMessageWithUnicodeInFilename()
{
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
} else {
$message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';