本文整理汇总了PHP中ReflectionMethod::isAbstract方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::isAbstract方法的具体用法?PHP ReflectionMethod::isAbstract怎么用?PHP ReflectionMethod::isAbstract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::isAbstract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAutoloadMethod
/**
* @param \ReflectionMethod $method
* @return bool
*/
private function isAutoloadMethod(\ReflectionMethod $method)
{
if (strpos($method->getName(), KnotConsts::AUTOLOAD_METHOD_PREFIX) !== 0 || $method->getNumberOfParameters() != 1 || $method->getNumberOfRequiredParameters() != 1 || $method->isStatic() || $method->isAbstract() || !Extractor::instance()->has($method, KnotConsts::AUTOLOAD_ANNOTATIONS)) {
return false;
}
return true;
}
示例2: run
/**
* @param App\Request $request
* @return App\IResponse
*/
public function run(App\Request $request)
{
$this->request = $request;
$this->startup();
if (!$this->startupCheck) {
$class = (new \ReflectionClass($this))->getMethod('startup')->getDeclaringClass()->getName();
throw new Nette\InvalidStateException("'{$class}::startup()' or its descendant does not call parent method");
}
try {
$rm = new \ReflectionMethod($this, $this->getAction());
} catch (\ReflectionException $e) {
}
if (isset($e) || $rm->isAbstract() || $rm->isStatic() || !$rm->isPublic()) {
throw new App\BadRequestException("Method '{$request->getMethod()}' not allowed", 405);
}
$params = $this->getParameters();
$args = App\UI\PresenterComponentReflection::combineArgs($rm, $params);
$response = $rm->invokeArgs($this, $args);
if ($response === null) {
$response = new Responses\NullResponse();
} elseif (!$response instanceof App\IResponse) {
throw new Nette\InvalidStateException("Action '{$this->getAction(true)}' does not return instance of Nette\\Application\\IResponse");
}
return $response;
}
示例3: isAbstract
/**
* Returns whether this method is abstract
*
* @return boolean TRUE if this method is abstract
*/
public function isAbstract()
{
if ($this->reflectionSource instanceof ReflectionMethod) {
return $this->reflectionSource->isAbstract();
} else {
return parent::isAbstract();
}
}
示例4: condition
/**
* @inheritdoc
*/
public function condition(\ReflectionMethod $method)
{
if ($method->isPublic() && !($method->isAbstract() || $method->isConstructor() || $method->isDestructor())) {
if ($this->isTest || strlen($method->name) > 4 && substr($method->name, 0, 4) === 'test') {
return true;
}
}
return false;
}
示例5: fromReflection
public static function fromReflection(\ReflectionMethod $ref)
{
$method = new static();
$method->setFinal($ref->isFinal())->setAbstract($ref->isAbstract())->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE))->setReferenceReturned($ref->returnsReference())->setName($ref->name);
if ($docComment = $ref->getDocComment()) {
$method->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment));
}
foreach ($ref->getParameters() as $param) {
$method->addParameter(static::createParameter($param));
}
// FIXME: Extract body?
return $method;
}
示例6: fromReflection
public static function fromReflection(\ReflectionMethod $ref)
{
$method = new static($ref->name);
$method->setFinal($ref->isFinal())->setAbstract($ref->isAbstract())->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE))->setReferenceReturned($ref->returnsReference())->setBody(ReflectionUtils::getFunctionBody($ref));
$docblock = new Docblock($ref);
$method->setDocblock($docblock);
$method->setDescription($docblock->getShortDescription());
$method->setLongDescription($docblock->getLongDescription());
foreach ($ref->getParameters() as $param) {
$method->addParameter(static::createParameter($param));
}
return $method;
}
示例7: assertEqualMethods
/**
* @param \ReflectionMethod $reflectionMethod
* @param \Donquixote\HastyReflectionCommon\Reflection\FunctionLike\MethodReflectionInterface $methodReflection
*/
private function assertEqualMethods(\ReflectionMethod $reflectionMethod, MethodReflectionInterface $methodReflection)
{
$this->assertEquals($reflectionMethod->isAbstract(), $methodReflection->isAbstract());
$this->assertEquals($reflectionMethod->getDeclaringClass()->getName(), $methodReflection->getDeclaringClassName());
$this->assertEquals($reflectionMethod->getDocComment(), $methodReflection->getDocComment());
$this->assertEquals($reflectionMethod->getShortName(), $methodReflection->getName());
$this->assertEquals($reflectionMethod->getName(), $methodReflection->getName());
$this->assertEquals($reflectionMethod->class . '::' . $reflectionMethod->getName(), $methodReflection->getQualifiedName());
$this->assertEquals($reflectionMethod->returnsReference(), $methodReflection->isByReference());
$this->assertEquals($reflectionMethod->isPrivate(), $methodReflection->isPrivate());
$this->assertEquals($reflectionMethod->isProtected(), $methodReflection->isProtected());
$this->assertEquals($reflectionMethod->isPublic(), $methodReflection->isPublic());
$this->assertEquals($reflectionMethod->isStatic(), $methodReflection->isStatic());
}
示例8: ofClassMethod
/**
* Resolve if callable is class method
*
* @param $callable
* @return Invokable
*/
public static function ofClassMethod($callable)
{
// parse class::method to [class, method]
if (is_string($callable) and strpos($callable, '::') !== false) {
$callable = explode('::', $callable);
}
// resolve [class, method]
if (is_array($callable) and count($callable) === 2) {
$reflector = new \ReflectionMethod($callable[0], $callable[1]);
if ($reflector->isPublic() and !$reflector->isStatic() and !$reflector->isAbstract()) {
$annotations = array_merge(Annotation::ofClass($callable[0]), Annotation::ofMethod($callable[0], $callable[1]));
return new Invokable($callable, Invokable::CLASS_METHOD, $annotations, $reflector);
}
}
}
示例9: method
/**
* @param \ReflectionMethod $method
* @return \Phpy\Method\Method
*/
public function method(\ReflectionMethod $method)
{
$phpyMethod = new Method($method->getName());
$phpyMethod->setStatic($method->isStatic())->setFinal($method->isFinal())->setAbstract($method->isAbstract());
if ($method->isPublic()) {
$phpyMethod->setVisibility('public');
} elseif ($method->isProtected()) {
$phpyMethod->setVisibility('protected');
} else {
$phpyMethod->setVisibility('private');
}
foreach ($method->getParameters() as $refParameter) {
$phpyMethod->addParameter($this->parameter($refParameter));
}
return $phpyMethod;
}
示例10: getType
/**
*
* @param Closure|string $action
* @return string
* */
public static function getType($action)
{
if ($action instanceof \Closure) {
return static::TYPE_CLOSURE;
} elseif (function_exists($action)) {
return static::TYPE_FUNCTION;
}
if (strpos($action, '::') === false) {
throw new \UnexpectedValueException('Invalid value for action');
}
$reflection = new \ReflectionMethod($action);
if ($reflection->isAbstract() || !$reflection->isPublic()) {
throw new \UnexpectedValueException('Action cannot use abstract or private methods');
}
if ($reflection->isStatic()) {
return static::TYPE_STATIC_METHOD;
}
return static::TYPE_DINAMIC_METHOD;
}
示例11: reflectMethod
function reflectMethod($class, $method)
{
$methodInfo = new ReflectionMethod($class, $method);
echo "**********************************\n";
echo "Reflecting on method {$class}::{$method}()\n\n";
echo "\nisFinal():\n";
var_dump($methodInfo->isFinal());
echo "\nisAbstract():\n";
var_dump($methodInfo->isAbstract());
echo "\nisPublic():\n";
var_dump($methodInfo->isPublic());
echo "\nisPrivate():\n";
var_dump($methodInfo->isPrivate());
echo "\nisProtected():\n";
var_dump($methodInfo->isProtected());
echo "\nisStatic():\n";
var_dump($methodInfo->isStatic());
echo "\nisConstructor():\n";
var_dump($methodInfo->isConstructor());
echo "\nisDestructor():\n";
var_dump($methodInfo->isDestructor());
echo "\n**********************************\n";
}
示例12: methodData
function methodData(ReflectionMethod $method)
{
$details = "";
$name = $method->getName();
if ($method->isUserDefined()) {
$details .= "{$name} is user defined\n";
}
if ($method->isInternal()) {
$details .= "{$name} is built-in\n";
}
if ($method->isAbstract()) {
$details .= "{$name} is abstract\n";
}
if ($method->isPublic()) {
$details .= "{$name} is public\n";
}
if ($method->isProtected()) {
$details .= "{$name} is protected\n";
}
if ($method->isPrivate()) {
$details .= "{$name} is private\n";
}
if ($method->isStatic()) {
$details .= "{$name} is static\n";
}
if ($method->isFinal()) {
$details .= "{$name} is final\n";
}
if ($method->isConstructor()) {
$details .= "{$name} is the constructor\n";
}
if ($method->returnsReference()) {
$details .= "{$name} returns a reference (as opposed to a value)\n";
}
return $details;
}
示例13: 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));
示例14: scan
public function scan()
{
require_once $this->path;
$ns = "";
$_ns = "";
$ns_bracket = false;
$aliases = [];
$tokens = new Tokenizer(FS::get($this->path));
while ($tokens->valid()) {
if ($tokens->is(T_NAMESPACE)) {
$ns = "";
$_ns = "";
$tokens->next();
if ($tokens->is(T_STRING)) {
$ns = $this->_parseName($tokens);
if ($tokens->is('{')) {
$tokens->skip();
$ns_bracket = true;
} else {
$tokens->skipIf(';');
}
$_ns = $ns . '\\';
} elseif ($tokens->is('{')) {
$ns_bracket = true;
$tokens->next();
}
} elseif ($tokens->is(T_USE)) {
do {
$tokens->next();
$name = $this->_parseName($tokens);
if ($tokens->is(T_AS)) {
$aliases[$tokens->next()->get(T_STRING)] = $name;
$tokens->next();
} else {
if (strpos($name, '\\') === false) {
$aliases[$name] = $name;
} else {
$aliases[ltrim('\\', strrchr($name, '\\'))] = $name;
}
}
} while ($tokens->is(','));
$tokens->need(';')->next();
} elseif ($tokens->is(T_CONST)) {
$name = $tokens->next()->get(T_STRING);
$constant = new EntityConstant($_ns . $name);
$constant->setValue(constant($_ns . $name));
$constant->setLine($this->line($tokens->getLine()));
$this->constants[$_ns . $name] = $constant;
$tokens->forwardTo(';')->next();
} elseif ($tokens->is(T_FUNCTION)) {
$name = $tokens->next()->get(T_STRING);
$function = new EntityFunction($_ns . $name);
$function->setLine($this->line($tokens->getLine()));
$function->setAliases($aliases);
$this->parseCallable($function, new \ReflectionFunction($function->name));
$function->setBody($tokens->forwardTo('{')->getScope());
$tokens->next();
$this->functions[$function->name] = $function;
} elseif ($tokens->is(T_FINAL, T_ABSTRACT, T_INTERFACE, T_TRAIT, T_CLASS)) {
$tokens->forwardTo(T_STRING);
$name = $tokens->current();
$class = new EntityClass($_ns . $name);
$ref = new \ReflectionClass($class->name);
$doc = $ref->getDocComment();
// if($name == "NamesInterface") {
// drop($ref);
// }
if ($ref->isInterface()) {
$class->addFlag(Flags::IS_INTERFACE);
} elseif ($ref->isTrait()) {
$class->addFlag(Flags::IS_TRAIT);
} else {
$class->addFlag(Flags::IS_CLASS);
}
if ($ref->isAbstract()) {
$class->addFlag(Flags::IS_ABSTRACT);
} elseif ($ref->isFinal()) {
$class->addFlag(Flags::IS_FINAL);
}
if ($doc) {
$info = ToolKit::parseDoc($doc);
$class->setDescription($info['desc']);
$class->addOptions($info['options']);
}
$class->setAliases($aliases);
$class->setLine($this->line($tokens->getLine()));
$tokens->next();
if ($tokens->is(T_EXTENDS)) {
// process 'extends' keyword
do {
$tokens->next();
$root = $tokens->is(T_NS_SEPARATOR);
$parent = $this->_parseName($tokens);
if ($root) {
// extends from root namespace
$class->setParent($parent, $class->isInterface());
} elseif (isset($aliases[$parent])) {
$class->setParent($aliases[$parent], $class->isInterface());
} else {
$class->setParent($_ns . $parent, $class->isInterface());
//.........这里部分代码省略.........
示例15: wrap_php_class
/**
* Given a user-defined PHP class or php object, map its methods onto a list of
* PHP 'wrapper' functions that can be exposed as xmlrpc methods from an xmlrpc_server
* object and called from remote clients (as well as their corresponding signature info).
*
* @param mixed $classname the name of the class whose methods are to be exposed as xmlrpc methods, or an object instance of that class
* @param array $extra_options see the docs for wrap_php_method for more options
* string method_type 'static', 'nonstatic', 'all' and 'auto' (default); the latter will switch between static and non-static depending on wheter $classname is a class name or object instance
* @return array or false on failure
*
* @todo get_class_methods will return both static and non-static methods.
* we have to differentiate the action, depending on wheter we recived a class name or object
*/
function wrap_php_class($classname, $extra_options = array())
{
$methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : '';
$methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto';
if (version_compare(phpversion(), '5.0.3') == -1) {
// up to php 5.0.3 some useful reflection methods were missing
error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3');
return false;
}
$result = array();
$mlist = get_class_methods($classname);
foreach ($mlist as $mname) {
if ($methodfilter == '' || preg_match($methodfilter, $mname)) {
// echo $mlist."\n";
$func = new ReflectionMethod($classname, $mname);
if (!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) {
if ($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || $methodtype == 'auto' && is_string($classname)) || !$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || $methodtype == 'auto' && is_object($classname))) {
$methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options);
if ($methodwrap) {
$result[$methodwrap['function']] = $methodwrap['function'];
}
}
}
}
}
return $result;
}