当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionClass::isUserDefined方法代码示例

本文整理汇总了PHP中ReflectionClass::isUserDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::isUserDefined方法的具体用法?PHP ReflectionClass::isUserDefined怎么用?PHP ReflectionClass::isUserDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionClass的用法示例。


在下文中一共展示了ReflectionClass::isUserDefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCallableMethods

 /**
  * get callable methods within the classObj
  *
  * @param string|object $classObj
  * @param int $filter
  * @param bool $filterOwn
  * @return array array of \ReflectionMethod
  */
 public function getCallableMethods($classObj, $filter, $filterOwn = true)
 {
     if (is_string($classObj) && !class_exists($classObj, false)) {
         throw new ClassNotDefinedException('Class name: ' . $classObj . ' not defined yet!');
     }
     $className = $classObj;
     if (is_object($classObj)) {
         $className = get_class($classObj);
     }
     $reflectClass = new \ReflectionClass($classObj);
     $methods = array();
     if (!$reflectClass->isUserDefined() || !$reflectClass->isInstantiable()) {
         return $methods;
     }
     $methods = $reflectClass->getMethods($filter);
     if ($filterOwn) {
         $needNeaten = false;
         foreach ($methods as $k => $method) {
             if ($method->class != $className) {
                 unset($methods[$k]);
                 !$needNeaten && ($needNeaten = true);
             }
         }
         $needNeaten && ($methods = array_values($methods));
     }
     return $methods;
 }
开发者ID:TF-Joynic,项目名称:Hydrogen,代码行数:35,代码来源:ConsoleHelper.php

示例2: classData

function classData(ReflectionClass $class)
{
    $details = "";
    $name = $class->getName();
    if ($class->isUserDefined()) {
        $details .= "{$name} is user defined\n";
    }
    if ($class->isInternal()) {
        $details .= "{$name} is built-in\n";
    }
    if ($class->isInterface()) {
        $details .= "{$name} is interface\n";
    }
    if ($class->isAbstract()) {
        $details .= "{$name} is an abstract class\n";
    }
    if ($class->isFinal()) {
        $details .= "{$name} is a final class\n";
    }
    if ($class->isInstantiable()) {
        $details .= "{$name} can be instantiated\n";
    } else {
        $details .= "{$name} can not be instantiated\n";
    }
    return $details;
}
开发者ID:jabouzi,项目名称:projet,代码行数:26,代码来源:listing5.26.php

示例3: getInheritanceInspection

 /**
  * Returns inheritance inspection.
  *
  * The inspection result:
  *
  * must:
  *
  * * shortName
  * * name
  * * userDefined
  *
  * optional:
  *
  * * namespace
  *
  * @param \ReflectionClass $declaringClass ReflectionClass object.
  * @return array Inheritance inspection.
  */
 protected function getInheritanceInspection(\ReflectionClass $declaringClass)
 {
     $inheritanceInspection = array('shortname' => $declaringClass->getShortName(), 'name' => $declaringClass->getName(), 'filename' => $declaringClass->getFileName(), 'userDefined' => $declaringClass->isUserDefined());
     if ($declaringClass->inNamespace()) {
         $inheritanceInspection['namespace'] = $declaringClass->getNamespaceName();
     }
     return $inheritanceInspection;
 }
开发者ID:satooshi,项目名称:object-inspector,代码行数:26,代码来源:ObjectInspector.php

示例4: getReflectionController

 private function getReflectionController($name)
 {
     $controllerName = __NAMESPACE__ . '\\' . $name . 'Controller';
     if (!class_exists($controllerName, true)) {
         throw new NotFoundException("Controller {$controllerName} not found.");
     }
     $foundController = new \ReflectionClass($controllerName);
     if ($foundController->isAbstract() || $foundController->isInterface() || !$foundController->isUserDefined()) {
         throw new NotFoundException("Class {$controllerName} is not a correct controller class.");
     }
     return $foundController;
 }
开发者ID:Endymion1977,项目名称:phonebook,代码行数:12,代码来源:RequestHandler.php

示例5: build

 private function build($parent, $items)
 {
     foreach ($this->all[$items] as $item) {
         $ref = new \ReflectionClass($item);
         if ($ref->isUserDefined()) {
             continue;
         }
         $p = $this->append($parent, array($item, $ref));
         if (!empty($this->all[$item])) {
             $this->build($p, $item);
         }
     }
 }
开发者ID:johannes,项目名称:php-explorer,代码行数:13,代码来源:ClassTree.php

示例6: classData

function classData(ReflectionClass $class)
{
    // получаем объект типа ReflectionClass
    $details = "";
    $name = $class->getName();
    if ($class->isUserDefined()) {
        $details .= "{$name} -- класс определён пользователем<br>";
    }
    if ($class->isInterface()) {
        $details .= "{$name} -- это интерфейс";
    }
    if ($class->isAbstract()) {
        $details .= "{$name} -- это абстрактный класс";
    }
    if ($class->isFinal()) {
        $details .= "{$name} -- это финальный класс";
    }
    if ($class->isInstantiable()) {
        $details .= "{$name} -- можно создать экземпляр класса";
    } else {
        $details .= "{$name} -- нельзя создать экземпляр класса";
    }
    return $details;
}
开发者ID:Overfinch,项目名称:oop,代码行数:24,代码来源:index.php

示例7: backupStaticAttributes

 public static function backupStaticAttributes(array $blacklist)
 {
     self::$staticAttributes = array();
     $declaredClasses = get_declared_classes();
     $declaredClassesNum = count($declaredClasses);
     for ($i = $declaredClassesNum - 1; $i >= 0; $i--) {
         if (strpos($declaredClasses[$i], 'PHPUnit') !== 0 && !$declaredClasses[$i] instanceof PHPUnit_Framework_Test) {
             $class = new ReflectionClass($declaredClasses[$i]);
             if (!$class->isUserDefined()) {
                 break;
             }
             $backup = array();
             foreach ($class->getProperties() as $attribute) {
                 if ($attribute->isStatic()) {
                     $name = $attribute->getName();
                     if (!isset($blacklist[$declaredClasses[$i]]) || !in_array($name, $blacklist[$declaredClasses[$i]])) {
                         $attribute->setAccessible(TRUE);
                         $backup[$name] = serialize($attribute->getValue());
                     }
                 }
             }
             if (!empty($backup)) {
                 self::$staticAttributes[$declaredClasses[$i]] = $backup;
             }
         }
     }
 }
开发者ID:arjenschol,项目名称:phpunit,代码行数:27,代码来源:GlobalState.php

示例8: userMethod

<?php

class userClass
{
    public function userMethod($userParameter = 'default')
    {
    }
}
echo '<pre>';
// get_declared_classes() 获得已定义的类(系统类&&用户自定义的类)
foreach (get_declared_classes() as $class) {
    $reflectionClass = new ReflectionClass($class);
    // isUserDefined() 检查是否是用户自定义的类
    if ($reflectionClass->isUserDefined()) {
        Reflection::export($reflectionClass);
    }
}
开发者ID:ZSShang,项目名称:mylearn,代码行数:17,代码来源:get_declared_classes01.php

示例9: collectEndAsFiles

 /**
  * Stops the collection of loaded classes and
  * returns the names of the files that declare the loaded classes.
  *
  * @return array
  */
 public static function collectEndAsFiles()
 {
     $result = self::collectEnd();
     $count = count($result);
     for ($i = 0; $i < $count; $i++) {
         $class = new ReflectionClass($result[$i]);
         if ($class->isUserDefined()) {
             $file = $class->getFileName();
             if (file_exists($file)) {
                 $result[$i] = $file;
             } else {
                 unset($result[$i]);
             }
         }
     }
     return $result;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:23,代码来源:Class.php

示例10: isInterface

print "\n";
print "--- isInterface() ---\n";
var_dump($rb->isInterface());
print "\n";
print "--- isInternal() ---\n";
var_dump($rb->isInternal());
print "\n";
print "--- isIterateable() ---\n";
var_dump($rb->isIterateable());
print "\n";
print "--- isSubclassOf() ---\n";
var_dump($rb->isSubclassOf('A'));
var_dump($rb->isSubclassOf('C'));
print "\n";
print "--- isUserDefined() ---\n";
var_dump($rb->isUserDefined());
print "\n";
print "--- newInstance() ---\n";
var_dump($rb->newInstance());
print "\n";
print "--- newInstanceArgs() ---\n";
var_dump($rb->newInstanceArgs());
print "\n";
print "--- get_defined_functions() ---\n";
$a = get_defined_functions()["user"];
sort($a);
var_dump($a);
print "--- get_defined_constants() ---\n";
$a = get_defined_constants();
print "SOME_CONSTANT: " . $a["SOME_CONSTANT"] . "\n";
if (isset($a["ANOTHER_CONSTANT"])) {
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:reflection.php

示例11: getExceptionData

 private function getExceptionData(ExceptionDataCollector $collector)
 {
     $exception = $collector->getException();
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $data = $exception->toArray();
     foreach ($data as $nb => $exData) {
         // skip non-public exceptions
         $class = new \ReflectionClass($exData['class']);
         if ($class->isUserDefined() && !$this->isNamespaceWhitelisted($exData['class'])) {
             unset($data[$nb]);
             continue;
         }
         // skip built-in exceptions that are thrown from a non-public class
         if (!$class->isUserDefined() && (!isset($exData['trace'][1]) || !$this->isNamespaceWhitelisted($exData['trace'][1]['class']))) {
             unset($data[$nb]);
             continue;
         }
         foreach ($exData['trace'] as $key => $trace) {
             unset($data[$nb]['trace'][$key]['namespace'], $data[$nb]['trace'][$key]['short_class']);
             if ('' === $trace['class']) {
                 $public = isset($exData['trace'][$key + 1]) && $this->isNamespaceWhitelisted($exData['trace'][$key + 1]['class']);
             } else {
                 $public = $this->isNamespaceWhitelisted($trace['class']);
             }
             if (!$public) {
                 foreach ($trace as $k => $v) {
                     if (is_array($v)) {
                         $data[$nb]['trace'][$key][$k] = array();
                     } else {
                         if (is_string($v)) {
                             if ('' !== $v) {
                                 $data[$nb]['trace'][$key][$k] = 'XXX';
                             }
                         } else {
                             $data[$nb]['trace'][$key][$k] = 'XXX';
                         }
                     }
                 }
                 continue;
             }
             // additional heuristics for config data handling
             if ('Symfony\\Component\\DependencyInjection\\Loader\\YamlFileLoader' === $trace['class'] && 'parseImports' === $trace['function']) {
                 $trace['args'] = array(array('array', array()), array('string', basename($trace['args'][1][1])));
             }
             if ('Symfony\\Component\\Yaml\\Parser' === $trace['class'] && 'parse' === $trace['function']) {
                 $trace['args'] = array(array('string', 'XXX'));
             }
             $data[$nb]['trace'][$key]['file'] = basename($trace['file']);
             $data[$nb]['trace'][$key]['args'] = $this->purgeArgsRecursive($trace['args']);
         }
     }
     return array_values($data);
 }
开发者ID:richardmiller,项目名称:DebuggingBundle,代码行数:55,代码来源:ProfilerNormalizer.php

示例12: backupStaticAttributes

 public static function backupStaticAttributes(array $blacklist)
 {
     self::$staticAttributes = array();
     $declaredClasses = get_declared_classes();
     $declaredClassesNum = count($declaredClasses);
     for ($i = $declaredClassesNum - 1; $i >= 0; $i--) {
         if (strpos($declaredClasses[$i], 'PHPUnit') !== 0 && strpos($declaredClasses[$i], 'File_Iterator') !== 0 && strpos($declaredClasses[$i], 'PHP_CodeCoverage') !== 0 && strpos($declaredClasses[$i], 'PHP_Invoker') !== 0 && strpos($declaredClasses[$i], 'PHP_Timer') !== 0 && strpos($declaredClasses[$i], 'PHP_TokenStream') !== 0 && strpos($declaredClasses[$i], 'Symfony') !== 0 && strpos($declaredClasses[$i], 'Text_Template') !== 0 && !$declaredClasses[$i] instanceof PHPUnit_Framework_Test) {
             $class = new ReflectionClass($declaredClasses[$i]);
             if (!$class->isUserDefined()) {
                 break;
             }
             $backup = array();
             foreach ($class->getProperties() as $attribute) {
                 if ($attribute->isStatic()) {
                     $name = $attribute->getName();
                     if (!isset($blacklist[$declaredClasses[$i]]) || !in_array($name, $blacklist[$declaredClasses[$i]])) {
                         $attribute->setAccessible(TRUE);
                         $value = $attribute->getValue();
                         if (!$value instanceof Closure) {
                             $backup[$name] = serialize($value);
                         }
                     }
                 }
             }
             if (!empty($backup)) {
                 self::$staticAttributes[$declaredClasses[$i]] = $backup;
             }
         }
     }
 }
开发者ID:DieguinhoHR,项目名称:kratos_store,代码行数:30,代码来源:GlobalState.php

示例13: calculateDependencies

 /**
  * Calculates the dependencies for this function or method.
  *
  */
 protected function calculateDependencies()
 {
     foreach ($this->function->getParameters() as $parameter) {
         try {
             $class = $parameter->getClass();
             if ($class) {
                 $className = $class->getName();
                 if ($className != $this->scope && !in_array($className, $this->dependencies)) {
                     $this->dependencies[] = $className;
                 }
             }
         } catch (ReflectionException $e) {
         }
     }
     $inNew = FALSE;
     foreach ($this->tokens as $token) {
         if (is_string($token)) {
             if (trim($token) == ';') {
                 $inNew = FALSE;
             }
             continue;
         }
         list($token, $value) = $token;
         switch ($token) {
             case T_NEW:
                 $inNew = TRUE;
                 break;
             case T_STRING:
                 if ($inNew) {
                     if ($value != $this->scope && class_exists($value, FALSE)) {
                         try {
                             $class = new ReflectionClass($value);
                             if ($class->isUserDefined() && !in_array($value, $this->dependencies)) {
                                 $this->dependencies[] = $value;
                             }
                         } catch (ReflectionException $e) {
                         }
                     }
                 }
                 $inNew = FALSE;
                 break;
         }
     }
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:48,代码来源:Function.php

示例14: array

<?php

// Copyright (c) 2014 Robin Bailey @ Dionach Ltd.
$classlist = get_declared_classes();
// The methods we're interested in
$magic = array("__wakeup", "__destruct", "__toString", "__get", "__set", "__call");
foreach ($classlist as $class) {
    $reflClass = new ReflectionClass($class);
    // Ignore classes from PHP core/extensions
    if ($reflClass->isUserDefined()) {
        foreach ($magic as $method) {
            try {
                if ($reflClass->getMethod($method)) {
                    $reflMethod = new ReflectionMethod($class, $method);
                    $parent = $reflMethod->getDeclaringClass()->getName();
                    $filename = $reflMethod->getDeclaringClass()->getFileName();
                    $startline = $reflMethod->getStartLine();
                    // If filename is not defined the class inherits from a core/extension class
                    if ($filename) {
                        // Get the source code of the method
                        $exp = $reflMethod->export($class, $method, 1);
                        // Extract the filename, start and end line numbers
                        preg_match("/@@\\s(.*)\\s(\\d+)\\s-\\s(\\d+)/i", $exp, $matches);
                        $source = file($filename);
                        // -1/+1 to include the first and last lines, incase code is on same line as method declaration
                        $functionBody = implode("", array_slice($source, $matches[2] - 1, $matches[3] - $matches[2] + 1));
                        // Check for interesting function calls
                        if (preg_match("/eval|assert|call_user_func|system|popen|shell_exec|include|require|file_get_contents|unlink|exec/", $functionBody, $m)) {
                            $interesting = $m[0];
                        }
                        print $class . "::" . $method . "() ";
开发者ID:datasiph0n,项目名称:magicmapping,代码行数:31,代码来源:magicmapping.php

示例15: ReflectionClass

<?php

$r1 = new ReflectionClass("stdClass");
var_dump($r1->isUserDefined('X'));
var_dump($r1->isUserDefined('X', true));
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:ReflectionClass_isUserDefined_error.php


注:本文中的ReflectionClass::isUserDefined方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。