コード例 #1
0
 public function testGetExtension()
 {
     self::assertEquals($this->php_fctM1->getExtension(), $this->fctM1->getExtension());
     self::assertEquals($this->php_fctM2->getExtension(), $this->fctM2->getExtension());
     self::assertEquals($this->php_fctM3->getExtension(), $this->fctM3->getExtension());
     self::assertEquals((string) $this->php_fct_method_exists->getExtension(), (string) $this->fct_method_exists->getExtension());
 }
コード例 #2
0
 /**
  * Returns NULL or the extension the function belongs to
  *
  * @return ezcReflectionExtension Extension the function belongs to
  */
 public function getExtension()
 {
     if ($this->getExtensionName() === false) {
         return null;
     } else {
         if ($this->reflectionSource instanceof ReflectionFunction) {
             return new ezcReflectionExtension($this->reflectionSource->getExtension());
         } else {
             // using the name, since otherwhise the object would be treated like an
             // external reflection implementation and that would decrease performance
             return new ezcReflectionExtension(parent::getExtensionName());
         }
     }
 }
コード例 #3
0
 /**
  * @return ExtensionReflection
  */
 public function getExtension()
 {
     return ($ref = parent::getExtension()) ? ExtensionReflection::import($ref) : NULL;
 }
コード例 #4
0
ファイル: find_tested.php プロジェクト: cefalo19/php-src
/**
 * returns an array containing a record for each defined method.
 */
function populate_method_info()
{
    $method_info = array();
    // get functions
    $all_functions = get_defined_functions();
    $internal_functions = $all_functions["internal"];
    foreach ($internal_functions as $function) {
        // populate new method record
        $function_record = array();
        $function_record[CLASS_NAME] = "Function";
        $function_record[METHOD_NAME] = $function;
        $function_record[IS_TESTED] = "no";
        $function_record[TESTS] = "";
        $function_record[IS_DUPLICATE] = false;
        // record the extension that the function belongs to
        $reflectionFunction = new ReflectionFunction($function);
        $extension = $reflectionFunction->getExtension();
        if ($extension != null) {
            $function_record[EXTENSION_NAME] = $extension->getName();
        } else {
            $function_record[EXTENSION_NAME] = "";
        }
        // insert new method record into info array
        $method_info[] = $function_record;
    }
    // get methods
    $all_classes = get_declared_classes();
    foreach ($all_classes as $class) {
        $reflectionClass = new ReflectionClass($class);
        $methods = $reflectionClass->getMethods();
        foreach ($methods as $method) {
            // populate new method record
            $new_method_record = array();
            $new_method_record[CLASS_NAME] = $reflectionClass->getName();
            $new_method_record[METHOD_NAME] = $method->getName();
            $new_method_record[IS_TESTED] = "no";
            $new_method_record[TESTS] = "";
            $extension = $reflectionClass->getExtension();
            if ($extension != null) {
                $new_method_record[EXTENSION_NAME] = $extension->getName();
            } else {
                $new_method_record[EXTENSION_NAME] = "";
            }
            // check for duplicate method names
            $new_method_record[IS_DUPLICATE] = false;
            foreach ($method_info as &$current_record) {
                if (strcmp($current_record[METHOD_NAME], $new_method_record[METHOD_NAME]) == 0) {
                    $new_method_record[IS_DUPLICATE] = true;
                    $current_record[IS_DUPLICATE] = true;
                }
            }
            // insert new method record into info array
            $method_info[] = $new_method_record;
        }
    }
    return $method_info;
}
コード例 #5
0
<?php

function foo()
{
}
$function = new ReflectionFunction('sort');
var_dump($function->getExtension());
$function = new ReflectionFunction('foo');
var_dump($function->getExtension());