Skip to content

Commit

Permalink
Using FQ name for PHP_VERSION_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 1, 2017
1 parent 65c55f2 commit dff6754
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions JsonResponse.php
Expand Up @@ -121,7 +121,7 @@ public function setData($data = array())
$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.
Expand All @@ -131,7 +131,7 @@ public function setData($data = array())
// 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');
Expand All @@ -146,14 +146,14 @@ public function setData($data = array())
$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;
Expand Down
2 changes: 1 addition & 1 deletion Request.php
Expand Up @@ -1502,7 +1502,7 @@ public function isMethodCacheable()
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.');
}

Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Handler/NativeSessionHandler.php
Expand Up @@ -13,7 +13,7 @@

// Adds SessionHandler functionality if available.
// @see http://php.net/sessionhandler
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
class NativeSessionHandler extends \SessionHandler
{
}
Expand Down
14 changes: 7 additions & 7 deletions Session/Storage/NativeSessionStorage.php
Expand Up @@ -102,7 +102,7 @@ public function __construct(array $options = array(), $handler = null, MetadataB
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');
Expand Down Expand Up @@ -132,11 +132,11 @@ public function start()
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).');
}
Expand Down Expand Up @@ -197,12 +197,12 @@ public function setName($name)
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;
}

Expand Down Expand Up @@ -384,13 +384,13 @@ public function setSaveHandler($saveHandler = null)
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(
Expand Down
4 changes: 2 additions & 2 deletions Session/Storage/Proxy/AbstractProxy.php
Expand Up @@ -72,7 +72,7 @@ public function isWrapper()
*/
public function isActive()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
return $this->active = \PHP_SESSION_ACTIVE === session_status();
}

Expand All @@ -93,7 +93,7 @@ public function isActive()
*/
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+');
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/RequestTest.php
Expand Up @@ -1029,7 +1029,7 @@ public function testContentAsResource()
*/
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.');
}

Expand Down
Expand Up @@ -29,7 +29,7 @@ public function testConstruct()
{
$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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Session/Storage/Handler/NativeSessionHandlerTest.php
Expand Up @@ -30,7 +30,7 @@ public function testConstruct()

// 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 {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Session/Storage/NativeSessionStorageTest.php
Expand Up @@ -196,7 +196,7 @@ public function testSetSaveHandlerException()

public function testSetSaveHandler53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand Down Expand Up @@ -249,7 +249,7 @@ public function testStartedOutside()

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());
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Session/Storage/PhpBridgeSessionStorageTest.php
Expand Up @@ -62,7 +62,7 @@ protected function getStorage()

public function testPhpSession53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand Down
8 changes: 4 additions & 4 deletions Tests/Session/Storage/Proxy/AbstractProxyTest.php
Expand Up @@ -88,7 +88,7 @@ public function testIsWrapper()

public function testIsActivePhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand All @@ -109,7 +109,7 @@ public function testIsActivePhp54()

public function testSetActivePhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public function testName()
*/
public function testNameExceptionPhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function testId()
*/
public function testIdExceptionPhp53()
{
if (PHP_VERSION_ID >= 50400) {
if (\PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
Expand Up @@ -54,7 +54,7 @@ public function testOpen()

$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());
Expand Down

0 comments on commit dff6754

Please sign in to comment.