type() публичный статический Метод

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
Результат string Identifier type. One of `property`, `method`, `class` or `namespace`.
Пример #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;
 }
Пример #2
0
 /**
  * Tests that class and namepace names which are equivalent in a case-insensitive search still
  * match properly.
  */
 public function testCaseSensitiveIdentifiers()
 {
     $result = Inspector::type('lithium\\storage\\Cache');
     $expected = 'class';
     $this->assertEqual($expected, $result);
     $result = Inspector::type('lithium\\storage\\cache');
     $expected = 'namespace';
     $this->assertEqual($expected, $result);
 }