本文整理汇总了PHP中is_callable函数的典型用法代码示例。如果您正苦于以下问题:PHP is_callable函数的具体用法?PHP is_callable怎么用?PHP is_callable使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_callable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notify
public function notify($errno, $errstr, $errfile, $errline, $trace)
{
$body = array();
$body[] = $this->_makeSection("", join("\n", array(@$_SERVER['GATEWAY_INTERFACE'] ? "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" : "", "{$errno}: {$errstr}", "at {$errfile} on line {$errline}")));
if ($this->_whatToLog & self::LOG_TRACE && $trace) {
$body[] = $this->_makeSection("TRACE", Debug_ErrorHook_Util::backtraceToString($trace));
}
/*if ($this->_whatToLog & self::LOG_SERVER) {
$body[] = $this->_makeSection("SERVER", Debug_ErrorHook_Util::varExport($_SERVER));
}*/
if (!empty($_COOKIE) && $this->_whatToLog & self::LOG_COOKIE) {
$body[] = $this->_makeSection("COOKIES", Debug_ErrorHook_Util::varExport($_COOKIE));
}
if (!empty($_GET) && $this->_whatToLog & self::LOG_GET) {
$body[] = $this->_makeSection("GET", Debug_ErrorHook_Util::varExport($_GET));
}
if (!empty($_POST) && $this->_whatToLog & self::LOG_POST) {
$body[] = $this->_makeSection("POST", Debug_ErrorHook_Util::varExport($_POST));
}
if (!empty($_SESSION) && $this->_whatToLog & self::LOG_SESSION) {
$body[] = $this->_makeSection("SESSION", Debug_ErrorHook_Util::varExport(@$_SESSION));
}
// Append body suffix?
$suffix = $this->_bodySuffix && is_callable($this->_bodySuffix) ? call_user_func($this->_bodySuffix) : $this->_bodySuffix;
if ($suffix) {
$body[] = $this->_makeSection("ADDITIONAL INFO", $suffix);
}
// Remain only 1st line for subject.
$errstr = preg_replace("/\r?\n.*/s", '', $errstr);
$this->_notifyText("{$errno}: {$errstr} at {$errfile} on line {$errline}", join("\n", $body));
}
示例2: assertErrorsAreTriggered
/**
* @param int $expectedType Expected triggered error type (pass one of PHP's E_* constants)
* @param string[] $expectedMessages Expected error messages
* @param callable $testCode A callable that is expected to trigger the error messages
*/
public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
{
if (!is_callable($testCode)) {
throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
}
$e = null;
$triggeredMessages = array();
try {
$prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
if ($expectedType !== $type) {
return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
}
$triggeredMessages[] = $message;
});
call_user_func($testCode);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
restore_error_handler();
if (null !== $e) {
throw $e;
}
\PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
foreach ($triggeredMessages as $i => $message) {
\PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
}
}
示例3: addError
public function addError($error, $passedMetaData = array())
{
// Check if this error should be sent to Bugsnag
if (!$this->config->shouldNotify()) {
return false;
}
// Add global meta-data to error
$error->setMetaData($this->config->metaData);
// Add request meta-data to error
if (Bugsnag_Request::isRequest()) {
$error->setMetaData(Bugsnag_Request::getRequestMetaData());
}
// Add environment meta-data to error
if ($this->config->sendEnvironment && !empty($_ENV)) {
$error->setMetaData(array("Environment" => $_ENV));
}
// Add user-specified meta-data to error
$error->setMetaData($passedMetaData);
// Run beforeNotify function (can cause more meta-data to be merged)
if (isset($this->config->beforeNotifyFunction) && is_callable($this->config->beforeNotifyFunction)) {
$beforeNotifyReturn = call_user_func($this->config->beforeNotifyFunction, $error);
}
// Skip this error if the beforeNotify function returned FALSE
if (!isset($beforeNotifyReturn) || $beforeNotifyReturn !== false) {
$this->errorQueue[] = $error;
return true;
} else {
return false;
}
}
示例4: smarty_modifier_truncate
/**
* Smarty truncate modifier plugin
*
* Type: modifier<br>
* Name: truncate<br>
* Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
*
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $string input string
* @param integer $length lenght of truncated text
* @param string $etc end string
* @param boolean $break_words truncate at word boundary
* @param boolean $middle truncate in the middle of text
* @return string truncated string
*/
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{
if ($length == 0) {
return '';
}
if (is_callable('mb_strlen')) {
if (mb_strlen($string) > $length) {
$length -= min($length, mb_strlen($etc));
if (!$break_words && !$middle) {
$string = mb_ereg_replace('/\\s+?(\\S+)?$/', '', mb_substr($string, 0, $length + 1), 'p');
}
if (!$middle) {
return mb_substr($string, 0, $length) . $etc;
} else {
return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, -$length / 2);
}
} else {
return $string;
}
} else {
if (strlen($string) > $length) {
$length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, $length + 1));
}
if (!$middle) {
return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
}
} else {
return $string;
}
}
}
示例5: _filter
private function _filter($value)
{
if ($this->_filter && is_callable($this->_filter)) {
$value = call_user_func($this->_filter, $value);
}
return $value;
}
示例6: content_55ccdf859b05a7_65053932
function content_55ccdf859b05a7_65053932($_smarty_tpl)
{
if (!is_callable('smarty_function_style')) {
include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.style.php';
}
echo smarty_function_style(array('src' => "addons/discussion/styles.less"), $_smarty_tpl);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:7,代码来源:4b94b65969cc309e0bb1b3060252d011bbb089f6.tygh.styles.post.tpl.php
示例7: __call
public function __call($name, $arguments)
{
if (isset($this->apis[$name]) && is_callable($this->apis[$name])) {
return call_user_func_array($this->apis[$name], $arguments);
}
return null;
}
示例8: get
/**
* Request a page and return it as string.
*
* @param string $url A url to request.
* @param string $method Request method, GET or POST.
* @param string $query Query string. eg: 'option=com_content&id=11&Itemid=125'. <br /> Only use for POST.
* @param array $option An option array to override CURL OPT.
*
* @throws \Exception
* @return mixed If success, return string, or return false.
*/
public static function get($url, $method = 'get', $query = '', $option = array())
{
if ((!function_exists('curl_init') || !is_callable('curl_init')) && ini_get('allow_url_fopen')) {
$return = new Object();
$return->body = file_get_contents($url);
return $return;
}
$options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1", CURLOPT_FOLLOWLOCATION => !ini_get('open_basedir') ? true : false, CURLOPT_SSL_VERIFYPEER => false);
// Merge option
$options = $option + $options;
$http = \JHttpFactory::getHttp(new \JRegistry($options), 'curl');
try {
switch ($method) {
case 'post':
case 'put':
case 'patch':
$result = $http->{$method}(UriHelper::safe($url), $query);
break;
default:
$result = $http->{$method}(UriHelper::safe($url));
break;
}
} catch (\Exception $e) {
return new NullObject();
}
return $result;
}
示例9: createStorage
private function createStorage($storageKey, array $storages, $urlResolver, Config $config)
{
if (!array_key_exists($storageKey, $storages)) {
throw new InvalidArgumentException("{$storageKey} is not a valid fineuploader server storage");
}
$storage = $storages[$storageKey];
if (!array_key_exists('class', $storage)) {
throw new InvalidArgumentException("{$storageKey} does not have a valid storage class");
}
$storageConfig = array_key_exists('config', $storage) ? $storage['config'] : [];
if (is_array($urlResolver)) {
if (!array_key_exists('class', $urlResolver)) {
throw new InvalidArgumentException("urlResolver needs a class key");
}
$resolverConfig = array_key_exists('config', $urlResolver) ? $urlResolver['config'] : [];
$urlResolver = new $urlResolver['class']($resolverConfig);
if (!$urlResolver instanceof UrlResolverInterface) {
throw new InvalidArgumentException(get_class($urlResolver) . " does not implement " . "Optimus\\Http\\UrlResolverInterface");
}
} elseif (!is_callable($urlResolver)) {
throw new InvalidArgumentException("Url resolver is not a method.");
}
$storage = new $storage['class']($storageConfig, $config, $urlResolver);
return $storage;
}
示例10: content_561617a7564969_20234583
function content_561617a7564969_20234583($_smarty_tpl)
{
if (!is_callable('smarty_modifier_replace')) {
include 'D:\\workspace\\php\\nagoya6\\tools\\smarty\\plugins\\modifier.replace.php';
}
?>
<h3><?php
echo smartyTranslate(array('s' => 'Referral program rules', 'mod' => 'referralprogram'), $_smarty_tpl);
?>
</h3>
<?php
if (isset($_smarty_tpl->tpl_vars['xml']->value)) {
?>
<div id="referralprogram_rules">
<?php
if (isset($_smarty_tpl->tpl_vars['xml']->value->body->{$_smarty_tpl->tpl_vars['paragraph']->value})) {
?>
<div class="rte"><?php
echo smarty_modifier_replace(smarty_modifier_replace($_smarty_tpl->tpl_vars['xml']->value->body->{$_smarty_tpl->tpl_vars['paragraph']->value}, "\\'", "'"), '\\"', '"');
?>
</div><?php
}
?>
</div>
<?php
}
}
开发者ID:usky105,项目名称:nagoya6er,代码行数:29,代码来源:8d022ee8d4dab6222435b4c29606090f2ff45224.file.rules.tpl.php
示例11: checkType
/**
* Returns `true` if value is of the specified type
*
* @param string $type
* @param mixed $value
* @return bool
*/
protected function checkType($type, $value)
{
switch ($type) {
case 'array':
return is_array($value);
case 'bool':
case 'boolean':
return is_bool($value);
case 'callable':
return is_callable($value);
case 'float':
case 'double':
return is_float($value);
case 'int':
case 'integer':
return is_int($value);
case 'null':
return is_null($value);
case 'numeric':
return is_numeric($value);
case 'object':
return is_object($value);
case 'resource':
return is_resource($value);
case 'scalar':
return is_scalar($value);
case 'string':
return is_string($value);
case 'mixed':
return true;
default:
return $value instanceof $type;
}
}
示例12: testTheJobRunnerFactoryIsReturnedIfProperlyConfigured
/**
* @covers ::__construct
* @covers ::getJobRunnerFactory
* @dataProvider configProvider
*/
public function testTheJobRunnerFactoryIsReturnedIfProperlyConfigured($options)
{
$config = new JobQueueConfig($options);
$callback = $config->getJobRunnerFactory();
$this->assertTrue(is_callable($callback));
$this->assertSame($options['job_runner'], $callback);
}
示例13: when
/**
* @param DomainEvent $event
* @return void
*/
protected function when(DomainEvent $event)
{
$method = 'when' . ClassFunctions::short($event);
if (is_callable([$this, $method])) {
$this->{$method}($event);
}
}
示例14: InvokeInternal
protected function InvokeInternal(array $arguments = null)
{
$func = $this->_Callback;
if ($this->_Object != null) {
$func = array($this->_Object, $func);
}
$parameters = $this->_Params;
if ($parameters != null) {
$parameter_keys = array_keys($parameters);
$count = count($parameter_keys);
$argument_list = array();
for ($i = 0; $i < $count; $i++) {
$key = $parameter_keys[$i];
$parameter = $parameters[$key];
$value = isset($parameter['default']) ? $parameter['default'] : null;
if (isset($arguments[$key])) {
$value = $arguments[$key];
} else {
if (isset($arguments[$i])) {
$value = $arguments[$i];
}
}
$argument_list[$i] = $value;
}
$arguments = $argument_list;
}
if (!isset($arguments[0]) || $arguments[0] === null) {
$arguments[0] = $this->_Default;
}
if (is_callable($func)) {
return call_user_func_array($func, $arguments);
}
return $arguments[0];
}
示例15: __callStatic
public static function __callStatic($name, array $params)
{
$params = $params[0];
#print_r($params); #die;
#echo 'Вы хотели вызвать '.__CLASS__.'::'.$name.', но его не существует, и сейчас выполняется '.__METHOD__.'()';
#print_r(self::$codes);
#echo $name . "<br/>\n";
#var_dump(self::$codes[$name]);
#die;
if (isset(self::$codes[$name]) && is_callable(self::$codes[$name])) {
#return self::$codes[$name]($params);
return call_user_func(self::$codes[$name], $params);
} else {
$return = array();
if (is_array($params)) {
foreach ($params as $key => $val) {
$return[] = "{$key}={$val}";
}
}
$return = implode(" ", $return);
if ($return != '') {
$return = ' ' . $return;
}
return "[" . $name . $return . "]";
}
}