From a239324a0d6370de86c998bcc1594d4c83474e0c Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 26 Jul 2015 15:35:03 +0200 Subject: [PATCH] use constant PHP_SAPI --- lib/Cake/Cache/Engine/XcacheEngine.php | 2 +- lib/Cake/Console/Templates/skel/webroot/index.php | 2 +- lib/Cake/Error/ErrorHandler.php | 2 +- lib/Cake/Test/Case/BasicsTest.php | 8 ++++---- lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php | 2 +- lib/Cake/Test/Case/Network/CakeResponseTest.php | 4 ++-- lib/Cake/Test/Case/Utility/DebuggerTest.php | 8 ++++---- lib/Cake/basics.php | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php index 9c1855605..97c851818 100644 --- a/lib/Cake/Cache/Engine/XcacheEngine.php +++ b/lib/Cake/Cache/Engine/XcacheEngine.php @@ -44,7 +44,7 @@ class XcacheEngine extends CacheEngine { * @return bool True if the engine has been successfully initialized, false if not */ public function init($settings = array()) { - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { parent::init(array_merge(array( 'engine' => 'Xcache', 'prefix' => Inflector::slug(APP_DIR) . '_', diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 4b67fafa4..e546e52ca 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -77,7 +77,7 @@ if (!defined('WWW_ROOT')) { } // for built-in server -if (php_sapi_name() === 'cli-server') { +if (PHP_SAPI === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) { return false; } diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index bde45f513..2cce57689 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -156,7 +156,7 @@ class ErrorHandler { $message .= "\nException Attributes: " . var_export($exception->getAttributes(), true); } } - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $request = Router::getRequest(); if ($request) { $message .= "\nRequest URL: " . $request->here(); diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 25b9e3395..65821693e 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -952,7 +952,7 @@ EXPECTED; ########################### EXPECTED; - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 20); @@ -977,7 +977,7 @@ EXPECTED; ########################### EXPECTED; - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19); @@ -1043,7 +1043,7 @@ EXPECTED; * @return void */ public function testPr() { - $this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode'); + $this->skipIf(PHP_SAPI === 'cli', 'Skipping web test in cli mode'); ob_start(); pr('this is a test'); $result = ob_get_clean(); @@ -1063,7 +1063,7 @@ EXPECTED; * @return void */ public function testPrCli() { - $this->skipIf(php_sapi_name() != 'cli', 'Skipping cli test in web mode'); + $this->skipIf(PHP_SAPI !== 'cli', 'Skipping cli test in web mode'); ob_start(); pr('this is a test'); $result = ob_get_clean(); diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 91f019b62..9c56241c2 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -34,7 +34,7 @@ class ApcEngineTest extends CakeTestCase { parent::setUp(); $this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.'); - if (php_sapi_name() === 'cli') { + if (PHP_SAPI === 'cli') { $this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.'); } diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 82a2f0419..41e2eba07 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -373,7 +373,7 @@ class CakeResponseTest extends CakeTestCase { * @return void */ public function testCompress() { - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $this->markTestSkipped('The response compression can only be tested in cli.'); } @@ -491,7 +491,7 @@ class CakeResponseTest extends CakeTestCase { if (!extension_loaded("zlib")) { $this->markTestSkipped('Skipping further tests for outputCompressed as zlib extension is not loaded'); } - if (php_sapi_name() !== 'cli') { + if (PHP_SAPI !== 'cli') { $this->markTestSkipped('Testing outputCompressed method with compression enabled done only in cli'); } diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index e967e7776..4179a7636 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -516,8 +516,8 @@ TEXT; Debugger::dump($var); $result = ob_get_clean(); - $open = php_sapi_name() === 'cli' ? "\n" : '
';
-		$close = php_sapi_name() === 'cli' ? "\n" : '
'; + $open = PHP_SAPI === 'cli' ? "\n" : '
';
+		$close = PHP_SAPI === 'cli' ? "\n" : '
'; $expected = << array( @@ -540,8 +540,8 @@ TEXT; Debugger::dump($var, 1); $result = ob_get_clean(); - $open = php_sapi_name() === 'cli' ? "\n" : '
';
-		$close = php_sapi_name() === 'cli' ? "\n" : '
'; + $open = PHP_SAPI === 'cli' ? "\n" : '
';
+		$close = PHP_SAPI === 'cli' ? "\n" : '
'; $expected = << array( diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 3b8070942..51afffa18 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -100,7 +100,7 @@ HTML; TEXT; $template = $html; - if (php_sapi_name() === 'cli' || $showHtml === false) { + if (PHP_SAPI === 'cli' || $showHtml === false) { $template = $text; if ($showFrom) { $lineInfo = sprintf('%s (line %s)', $file, $line); @@ -275,7 +275,7 @@ if (!function_exists('pr')) { */ function pr($var) { if (Configure::read('debug') > 0) { - $template = php_sapi_name() !== 'cli' ? '
%s
' : "\n%s\n"; + $template = PHP_SAPI !== 'cli' ? '
%s
' : "\n%s\n"; printf($template, print_r($var, true)); } }