本文整理汇总了PHP中runkit_constant_redefine函数的典型用法代码示例。如果您正苦于以下问题:PHP runkit_constant_redefine函数的具体用法?PHP runkit_constant_redefine怎么用?PHP runkit_constant_redefine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runkit_constant_redefine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 应用程序初始化
* @access public
* @return void
*/
public static function init()
{
// 加载动态应用公共文件和配置
load_ext_file(COMMON_PATH);
// 日志目录转换为绝对路径 默认情况下存储到公共模块下面
C('LOG_PATH', realpath(LOG_PATH) . '/Common/');
// 定义当前请求的系统常量
runkit_constant_redefine('NOW_TIME', $_SERVER['REQUEST_TIME']);
runkit_constant_redefine('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
runkit_constant_redefine('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
runkit_constant_redefine('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
runkit_constant_redefine('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
runkit_constant_redefine('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
// URL调度
Dispatcher::dispatch();
if (C('REQUEST_VARS_FILTER')) {
// 全局安全过滤
array_walk_recursive($_GET, 'think_filter');
array_walk_recursive($_POST, 'think_filter');
array_walk_recursive($_REQUEST, 'think_filter');
}
// URL调度结束标签
Hook::listen('url_dispatch');
runkit_constant_redefine('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')]) ? true : false);
// TMPL_EXCEPTION_FILE 改为绝对地址
C('TMPL_EXCEPTION_FILE', realpath(C('TMPL_EXCEPTION_FILE')));
return;
}
示例2: testWhichCrlf
/**
* @using runkit pecl extension
* if not define PMA_USR_OS, then define it as Win
* if installed runkit, then constant will not change
*/
public function testWhichCrlf()
{
$runkit = function_exists('runkit_constant_redefine');
if ($runkit && defined('PMA_USR_OS')) {
$pma_usr_os = PMA_USR_OS;
}
if (defined('PMA_USR_OS') && !$runkit) {
if (PMA_USR_OS == 'Win') {
$this->assertEquals("\r\n", PMA_whichCrlf());
} else {
$this->assertEquals("\n", PMA_whichCrlf());
}
$this->markTestIncomplete('Cannot redefine constant');
} else {
if ($runkit) {
define('PMA_USR_OS', 'Linux');
$this->assertEquals("\n", PMA_whichCrlf());
}
if ($runkit) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
define('PMA_USR_OS', 'Win');
}
$this->assertEquals("\r\n", PMA_whichCrlf());
}
if ($runkit) {
if (isset($pma_usr_os)) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
runkit_constant_remove('PMA_USR_OS');
}
}
}
示例3: redefineConstant
/**
* @param RunkitConstant $constant
*
* @return boolean
*/
public function redefineConstant(\Runkit\RunkitConstant $constant)
{
if (!function_exists('runkit_constant_redefine')) {
return false;
}
return runkit_constant_redefine($constant->getName(), $constant->getValue());
}
示例4: resetConstant
/**
* Reset original definition.
*/
public static function resetConstant($constant)
{
$originalConstant = "__ORIGINAL_{$constant}";
if (defined($originalConstant)) {
runkit_constant_redefine($constant, constant($originalConstant));
runkit_constant_remove($originalConstant);
}
}
示例5: testGetImplementation
public function testGetImplementation()
{
$nativePathClass = strtoupper(substr(PHP_OS, 0, 3)) === "WIN" ? "Spol\\Path\\WindowsPath" : "Spol\\Path\\UnixPath";
$this->assertInstanceOf($nativePathClass, Path::getImplementation());
runkit_constant_redefine("Spol\\Path\\Path::OS", "WINNT");
$this->assertInstanceOf("Spol\\Path\\WindowsPath", Path::getImplementation());
runkit_constant_redefine("Spol\\Path\\Path::OS", "Darwin");
$this->assertInstanceOf("Spol\\Path\\UnixPath", Path::getImplementation());
}
示例6: ensureConstant
/**
* @param string $constant
* @param mixed $expected
*
* @return null
*/
protected static function ensureConstant($constant, $expected)
{
if (defined($constant)) {
$value = constant($constant);
if ($value !== $expected) {
if (extension_loaded('runkit')) {
if (!runkit_constant_redefine($constant, $expected)) {
self::markTestSkipped(sprintf("Failed to redefine constant %s to %s", $constant, $expected));
}
} else {
self::markTestSkipped(sprintf("Skipping test because constant %s is %s instead of %s", $constant, $value, $expected));
}
}
} else {
define($constant, $expected);
}
}
示例7: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
// Drizzle does not support GIS data types
if (!defined("PMA_DRIZZLE")) {
define("PMA_DRIZZLE", false);
} else {
if (PMA_DRIZZLE) {
//PMA_DRIZZLE is defined and PMA_DRIZZLE = true
if (PMA_HAS_RUNKIT) {
runkit_constant_redefine("PMA_DRIZZLE", false);
} else {
//Drizzle does not support GIS data types
$this->markTestSkipped("Drizzle does not support GIS data types");
}
}
}
//setting
$GLOBALS['plugin_param'] = 'table';
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;
$GLOBALS['import_file'] = 'test/test_data/timezone.shp.zip';
//Mock DBI
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
$GLOBALS['dbi'] = $dbi;
include_once 'libraries/plugins/import/ImportShp.class.php';
$this->object = new ImportShp();
/**
* Load interface for zip extension.
*/
include_once 'libraries/zip_extension.lib.php';
$result = PMA_getZipContents($GLOBALS['import_file']);
$GLOBALS['import_text'] = $result["data"];
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['read_multiply'] = 10;
$GLOBALS['import_type'] = 'ods';
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
}
示例8: testWhichCrlf
/**
* Test for whichCrlf
*
* @return void
*
* @using runkit pecl extension
* if not define PMA_USR_OS, then define it as Win
* if installed runkit, then constant will not change
*/
public function testWhichCrlf()
{
if (PMA_HAS_RUNKIT && defined('PMA_USR_OS')) {
$pma_usr_os = PMA_USR_OS;
}
if (defined('PMA_USR_OS') && !PMA_HAS_RUNKIT) {
if (PMA_USR_OS == 'Win') {
$this->assertEquals("\r\n", PMA_Util::whichCrlf());
} else {
$this->assertEquals("\n", PMA_Util::whichCrlf());
}
$this->markTestIncomplete('Cannot redefine constant');
} else {
if (PMA_HAS_RUNKIT) {
if (!defined('PMA_USR_OS')) {
define('PMA_USR_OS', 'Linux');
} else {
runkit_constant_redefine('PMA_USR_OS', 'Linux');
}
$this->assertEquals("\n", PMA_Util::whichCrlf());
}
if (PMA_HAS_RUNKIT) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
define('PMA_USR_OS', 'Win');
}
$this->assertEquals("\r\n", PMA_Util::whichCrlf());
}
if (PMA_HAS_RUNKIT) {
if (isset($pma_usr_os)) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
runkit_constant_remove('PMA_USR_OS');
}
}
}
示例9: setUp
/**
* Configures environment
*
* @return void
*/
protected function setUp()
{
//we test:
//1. without Runkit, PMA_DRIZZLE = false;
//2. with Runkit, PMA_DRIZZLE = true;
if (!defined("PMA_DRIZZLE")) {
define("PMA_DRIZZLE", false);
}
parent::setUp();
//RunKit
if (PMA_HAS_RUNKIT) {
runkit_constant_redefine("PMA_DRIZZLE", true);
}
}
示例10: runkit_constant_redefine
<?php
namespace Think\Upload\Driver\Bcs;
use Think\Upload\Driver\Bcs\BCS_MimeTypes;
use Think\Upload\Driver\Bcs\BCS_RequestCore;
use Think\Upload\Driver\Bcs\BCS_ResponseCore;
if (!defined('BCS_API_PATH')) {
runkit_constant_redefine('BCS_API_PATH', dirname(__FILE__));
}
//AK 公钥
define('BCS_AK', '');
//SK 私钥
define('BCS_SK', '');
//superfile 每个object分片后缀
define('BCS_SUPERFILE_POSTFIX', '_bcs_superfile_');
//sdk superfile分片大小 ,单位 B(字节)
define('BCS_SUPERFILE_SLICE_SIZE', 1024 * 1024);
require_once BCS_API_PATH . '/requestcore.class.php';
require_once BCS_API_PATH . '/mimetypes.class.php';
/**
* Default BCS Exception.
*/
class BCS_Exception extends \Exception
{
}
/**
* BCS API
*/
class BaiduBCS
{
示例11: testPMAGetSqlQueriesForDisplayAndAddUser
/**
* Test for PMA_getSqlQueriesForDisplayAndAddUser
*
* @return void
*/
public function testPMAGetSqlQueriesForDisplayAndAddUser()
{
$restoreMySQLVersion = "PMANORESTORE";
if (! PMA_HAS_RUNKIT) {
$this->markTestSkipped(
'Cannot redefine constant. Missing runkit extension'
);
} else {
$restoreMySQLVersion = PMA_MYSQL_INT_VERSION;
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', 50706);
}
$username = "PMA_username";
$hostname = "PMA_hostname";
$password = "pma_password";
$_POST['pred_password'] = 'keep';
$_REQUEST['authentication_plugin'] = 'mysql_native_password';
$dbname = "PMA_db";
list($create_user_real, $create_user_show, $real_sql_query, $sql_query)
= PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password);
//validate 1: $create_user_real
$this->assertEquals(
"CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED "
. "WITH mysql_native_password AS 'pma_password';",
$create_user_real
);
//validate 2: $create_user_show
$this->assertEquals(
"CREATE USER 'PMA_username'@'PMA_hostname' IDENTIFIED "
. "WITH mysql_native_password AS '***';",
$create_user_show
);
//validate 3:$real_sql_query
$this->assertEquals(
"GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
$real_sql_query
);
//validate 4:$sql_query
$this->assertEquals(
"GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
$sql_query
);
//test for PMA_addUserAndCreateDatabase
list($sql_query, $message) = PMA_addUserAndCreateDatabase(
false, $real_sql_query, $sql_query, $username, $hostname, $dbname
);
//validate 5: $sql_query
$this->assertEquals(
"GRANT USAGE ON *.* TO 'PMA_username'@'PMA_hostname' REQUIRE NONE;",
$sql_query
);
//validate 6: $message
$this->assertEquals(
"You have added a new user.",
$message->getMessage()
);
if ($restoreMySQLVersion !== "PMANORESTORE") {
runkit_constant_redefine('PMA_MYSQL_INT_VERSION', $restoreMySQLVersion);
}
}
示例12: define
function define($k, $v)
{
if (defined($k)) {
runkit_constant_redefine($k, $v);
} else {
runkit_constant_add($k, $v);
}
}
示例13: redefineConstant
public static function redefineConstant($className, $constName, $value)
{
$runkitName = ($className === null ? "" : $className . "::") . $constName;
yTest_debugCC("redefineConstant {$runkitName} to value " . var_export($value, true));
$res = runkit_constant_redefine($runkitName, $value);
yTest_assert($res);
}
示例14: _defineConstant
/**
* Defines resp. redefines a constant.
*
* @param string $name A name.
* @param string $value A value.
*
* @return void
*/
private function _defineConstant($name, $value)
{
if (!defined($name)) {
define($name, $value);
} else {
runkit_constant_redefine($name, $value);
}
}
示例15: testSendHeaderLocationWithSidUrlWithoutQuestionMark
/**
* Test for PMA_sendHeaderLocation
*
* @return void
*/
public function testSendHeaderLocationWithSidUrlWithoutQuestionMark()
{
if (defined('PMA_TEST_HEADERS')) {
runkit_constant_redefine('SID', md5('test_hash'));
$testUri = 'http://testurl.com/test.php';
$header = array('Location: ' . $testUri . '?' . SID);
PMA_sendHeaderLocation($testUri);
// sets $GLOBALS['header']
$this->assertEquals($header, $GLOBALS['header']);
} else {
$this->markTestSkipped('Cannot redefine constant/function - missing runkit extension');
}
}