本文整理汇总了PHP中ReflectionMethod::isUserDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::isUserDefined方法的具体用法?PHP ReflectionMethod::isUserDefined怎么用?PHP ReflectionMethod::isUserDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::isUserDefined方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isUserDefined
/**
* Returns whether this is a user-defined method
*
* @return boolean True if this is a user-defined method
*/
public function isUserDefined()
{
if ($this->reflectionSource instanceof ReflectionMethod) {
return $this->reflectionSource->isUserDefined();
} else {
return parent::isUserDefined();
}
}
示例2: reflectMethod
function reflectMethod($class, $method)
{
$methodInfo = new ReflectionMethod($class, $method);
echo "**********************************\n";
echo "Reflecting on method {$class}::{$method}()\n\n";
echo "\ngetName():\n";
var_dump($methodInfo->getName());
echo "\nisInternal():\n";
var_dump($methodInfo->isInternal());
echo "\nisUserDefined():\n";
var_dump($methodInfo->isUserDefined());
echo "\n**********************************\n";
}
示例3: callAction
/**
* {@inheritdoc}
*/
public function callAction($action = '', array $parameters = [])
{
//Action should include prefix and be always specified
$action = static::ACTION_PREFIX . (!empty($action) ? $action : $this->defaultAction);
if (!method_exists($this, $action)) {
throw new ControllerException("No such action '{$action}'.", ControllerException::BAD_ACTION);
}
$reflection = new \ReflectionMethod($this, $action);
if ($reflection->getName() == SaturableInterface::SATURATE_METHOD || $reflection->isStatic() || !$reflection->isPublic() || !$reflection->isUserDefined() || $reflection->getDeclaringClass()->getName() == __CLASS__) {
throw new ControllerException("Action '{$action}' can not be executed.", ControllerException::BAD_ACTION);
}
try {
//Getting set of arguments should be sent to requested method
$arguments = $this->container->resolveArguments($reflection, $parameters);
} catch (ArgumentException $exception) {
throw new ControllerException("Missing/invalid parameter '{$exception->getParameter()->name}'.", ControllerException::BAD_ARGUMENT);
}
//Executing our action
return $this->executeAction($reflection, $arguments, $parameters);
}
示例4: methodData
function methodData(ReflectionMethod $method)
{
$details = "";
$name = $method->getName();
if ($method->isUserDefined()) {
$details .= "{$name} -- метод определён пользователем<br>";
}
if ($method->isInternal()) {
$details .= "{$name} -- внутренний метод<br>";
}
if ($method->isAbstract()) {
$details .= "{$name} -- абстрактный метод<br>";
}
if ($method->isPublic()) {
$details .= "{$name} -- публичный метод<br>";
}
if ($method->isProtected()) {
$details .= "{$name} -- защищенный метод<br>";
}
if ($method->isPrivate()) {
$details .= "{$name} -- закрытый метод метод<br>";
}
if ($method->isStatic()) {
$details .= "{$name} -- статичный метод<br>";
}
if ($method->isFinal()) {
$details .= "{$name} -- финальный метод<br>";
}
if ($method->isConstructor()) {
$details .= "{$name} -- метод конструктора<br>";
}
if ($method->returnsReference()) {
$details .= "{$name} -- метод возвращает ссылку а не значение<br>";
}
return $details;
}
示例5: retrieve_shortcode_info_from_file
/**
* Try and retrieve additional information about a shortcode using Reflection on the function/method
*
* @param array $info Shortcode info
* @param string $shortcode Current shortcode
* @return array Updated shortcode info
*/
public function retrieve_shortcode_info_from_file($info, $shortcode)
{
$shortcodes = $GLOBALS['shortcode_tags'];
if (!isset($shortcodes[$shortcode])) {
// Not a registered shortcode
return $info;
}
$callback = $shortcodes[$shortcode];
if (!is_string($callback) && (!is_array($callback) || is_array($callback) && (!is_string($callback[0]) && !is_object($callback[0])))) {
// Not a valid callback
return $info;
}
/* Set up reflection */
if (is_string($callback) && strpos($callback, '::') === false) {
$reflection = new ReflectionFunction($callback);
} else {
if (is_string($callback) && strpos($callback, '::') !== false) {
$reflection = new ReflectionMethod($callback);
} else {
if (is_array($callback)) {
$reflection = new ReflectionMethod($callback[0], $callback[1]);
}
}
}
if (!isset($reflection) || $reflection->isUserDefined() === false) {
// Not a user defined callback, i.e. native PHP, nothing to find out about it (shouldn't ever happen)
return $info;
}
$info['description'] = nl2br($this->strip_comment_markers($reflection->getDocComment()));
$info['self_closing'] = true;
if ($reflection->getNumberOfRequiredParameters() > 1) {
$info['self_closing'] = false;
}
$info['info_url'] = $this->get_plugin_url_from_file($reflection->getFileName(), $shortcode);
return $info;
}
示例6: isExecutable
/**
* Check if method is callable.
*
* @param \ReflectionMethod $method
* @return bool
*/
protected function isExecutable(\ReflectionMethod $method)
{
if ($method->isStatic() || !$method->isUserDefined()) {
return false;
}
//Place to implement custom logic
return true;
}
示例7: f
} catch (TypeError $re) {
echo "Ok - " . $re->getMessage() . PHP_EOL;
}
try {
new ReflectionMethod('a', 'b', 'c');
} catch (TypeError $re) {
echo "Ok - " . $re->getMessage() . PHP_EOL;
}
class C
{
public function f()
{
}
}
$rm = new ReflectionMethod('C', 'f');
var_dump($rm->isFinal(1));
var_dump($rm->isAbstract(1));
var_dump($rm->isPrivate(1));
var_dump($rm->isProtected(1));
var_dump($rm->isPublic(1));
var_dump($rm->isStatic(1));
var_dump($rm->isConstructor(1));
var_dump($rm->isDestructor(1));
var_dump($rm->getModifiers(1));
var_dump($rm->isInternal(1));
var_dump($rm->isUserDefined(1));
var_dump($rm->getFileName(1));
var_dump($rm->getStartLine(1));
var_dump($rm->getEndLine(1));
var_dump($rm->getStaticVariables(1));
var_dump($rm->getName(1));
示例8: getRequests
$right = strrpos($value, '.');
$left = strlen($dir) + 1;
$name = substr($value, $left, $right - $left);
if (stristr($name, 'Service')) {
$tokens = split('_', $name);
$str = '';
foreach ($tokens as $t => $token) {
$str = $str . strtoupper(substr($token, 0, 1)) . substr($token, 1);
}
if ($str != '') {
require_once $value;
$instance = new $str();
$methods = get_class_methods($instance);
foreach ($methods as $m => $method) {
$rm = new ReflectionMethod($str, $method);
if ($rm->isUserDefined() && !$rm->isConstructor() && !$rm->isDestructor() && $rm->getNumberOfParameters() == 2) {
$comment = $rm->getDocComment();
$metadata = getServiceMetadata($comment);
if ($metadata === FALSE) {
// could not parse metadata
continue;
}
$request = $metadata['request'];
$adapter = new ServiceAdapter($instance, $rm, $metadata);
registerService($request, $adapter, $services);
}
}
}
}
}
function getRequests($content_type, $input)
示例9: callOriginal
public static function callOriginal($callable, $args, $class = null)
{
if (is_array($callable)) {
if (is_object($callable[0])) {
$obj = $callable[0];
if (!$class) {
$class = get_class($obj);
}
} else {
$class = $callable[0];
}
$method = $callable[1];
} else {
if (is_scalar($callable) && strpos($callable, '::') !== false) {
list($class, $method) = explode("::", $callable);
} else {
return call_user_func_array($callable, $args);
}
}
try {
$Rm = new \ReflectionMethod($class, $method);
if ($Rm->isUserDefined()) {
self::$temp_disable = true;
// we can only mock and check for mocks for user defined methods
}
} catch (\ReflectionException $e) {
// do nothing, it is ok in this case because it means that mock disabling is not needed
}
if (isset($obj)) {
return self::callMethod($obj, $class, $method, $args);
} else {
return self::callStaticMethod($class, $method, $args);
}
}