lithium\analysis\Inspector::type PHP Method

type() public static method

Determines if a given $identifier is a class property, a class method, a class itself, or a namespace identifier.
public static type ( string $identifier ) : string
$identifier string The identifier to be analyzed
return string Identifier type. One of `property`, `method`, `class` or `namespace`.
    public static function type($identifier)
    {
        $identifier = ltrim($identifier, '\\');
        if (strpos($identifier, '::')) {
            return strpos($identifier, '$') !== false ? 'property' : 'method';
        }
        if (is_readable(Libraries::path($identifier))) {
            if (class_exists($identifier) && in_array($identifier, get_declared_classes())) {
                return 'class';
            }
        }
        return 'namespace';
    }

Usage Example

Beispiel #1
0
 public static function get($library, $identifier, array $options = array())
 {
     static::_ensureIndexedLibrary($library);
     $defaults = array('namespaceDoc' => array(), 'language' => 'en');
     $options += $defaults;
     $options['namespaceDoc'] = (array) $options['namespaceDoc'];
     $config = Libraries::get('li3_docs');
     if (isset($config['namespaceDoc'])) {
         $options['namespaceDoc'] = array_merge($options['namespaceDoc'], (array) $config['namespaceDoc']);
     }
     $path = Libraries::path($identifier);
     static::_ensurePathInBase($path);
     if (file_exists($path) && !static::_isClassFile($path)) {
         return static::_file(compact('library', 'path', 'identifier'), $options);
     }
     $data = Inspector::info($identifier);
     $proto = compact('identifier', 'library') + array('name' => null, 'type' => Inspector::type($identifier), 'info' => array(), 'classes' => null, 'methods' => null, 'properties' => null, 'parent' => null, 'children' => null, 'source' => null, 'subClasses' => array(), 'description' => isset($data['description']) ? $data['description'] : null, 'text' => isset($data['text']) ? $data['text'] : null);
     $format = "_{$proto['type']}";
     $data = static::$format($proto, (array) $data, $options);
     if (!$data) {
         return false;
     }
     foreach (array('text', 'description') as $key) {
         $data[$key] = Code::embed($data[$key], compact('library'));
     }
     return $data;
 }
All Usage Examples Of lithium\analysis\Inspector::type