本文整理汇总了PHP中lithium\analysis\Inspector::properties方法的典型用法代码示例。如果您正苦于以下问题:PHP Inspector::properties方法的具体用法?PHP Inspector::properties怎么用?PHP Inspector::properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\analysis\Inspector
的用法示例。
在下文中一共展示了Inspector::properties方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMap
private function getMap($class)
{
$properties = Inspector::properties($class, array('public' => false));
//parse out fields
$fields = array();
/** @var \ReflectionProperty $p */
foreach ($properties as $p) {
if (($p->getModifiers() & \ReflectionProperty::IS_PROTECTED) == \ReflectionProperty::IS_PROTECTED) {
$name = $p->getName();
if ($name[0] != '_') {
$fields[$name] = Docblock::comment($p->getDocComment());
}
}
}
//Parse out types
$ret = array();
foreach ($fields as $field => $data) {
if (isset($data['tags']['var'])) {
$ret[$field] = $this->dynamicType($data['tags']['var']);
}
}
return $ret;
}
示例2: _class
protected static function _class(array $object, array $data, array $options = array())
{
$identifier = $object['identifier'];
$proto = array('parent' => get_parent_class($identifier), 'methods' => Inspector::methods($identifier, null, array('public' => false)), 'properties' => Inspector::properties($identifier, array('public' => false)));
$classes = Libraries::find($object['library'], array('recursive' => true));
$proto['subClasses'] = array_filter($classes, function ($class) use($identifier) {
if (preg_match('/\\\\(libraries)\\\\|\\\\(mocks)\\\\|\\\\(tests)\\\\/', $class)) {
return false;
}
try {
return get_parent_class($class) == $identifier;
} catch (Exception $e) {
return false;
}
});
sort($proto['subClasses']);
return $proto + $object + array('tags' => isset($data['tags']) ? $data['tags'] : array());
}
示例3: _properties
/**
* Get the properties for the class
*
* @param string $class
* @param array $options
* @return array
*/
protected function _properties($class, $options = array())
{
$defaults = array('name' => null);
$options += $defaults;
$properties = Inspector::properties($class);
$results = array();
foreach ($properties as &$property) {
$comment = Docblock::comment($property['docComment']);
$description = trim($comment['description']);
$type = isset($comment['tags']['var']) ? strtok($comment['tags']['var'], ' ') : null;
$name = str_replace('_', '-', Inflector::underscore($property['name']));
$usage = $type == 'boolean' ? "-{$name}" : "--{$name}=" . strtoupper($name);
$results[$name] = compact('name', 'description', 'type', 'usage');
if ($name == $options['name']) {
return array($name => $results[$name]);
}
}
return $results;
}
示例4: testGetClassProperties
/**
* Tests getting static and non-static properties from various types of classes.
*/
public function testGetClassProperties()
{
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties(__CLASS__));
$expected = array('test', 'test2');
$this->assertEqual($expected, $result);
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties(__CLASS__, array('public' => false)));
$expected = array('test', 'test2', '_test');
$this->assertEqual($expected, $result);
$result = Inspector::properties(__CLASS__);
$expected = array(array('modifiers' => array('public'), 'docComment' => false, 'name' => 'test', 'value' => null), array('modifiers' => array('public', 'static'), 'docComment' => false, 'name' => 'test2', 'value' => 'bar'));
$this->assertEqual($expected, $result);
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties('lithium\\action\\Controller'));
$this->assertTrue(in_array('request', $result));
$this->assertTrue(in_array('response', $result));
$this->assertFalse(in_array('_render', $result));
$this->assertFalse(in_array('_classes', $result));
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties('lithium\\action\\Controller', array('public' => false)));
$this->assertTrue(in_array('request', $result));
$this->assertTrue(in_array('response', $result));
$this->assertTrue(in_array('_render', $result));
$this->assertTrue(in_array('_classes', $result));
$this->assertNull(Inspector::properties('\\lithium\\core\\Foo'));
}
示例5: testGetClassProperties
/**
* Tests getting static and non-static properties from various types of classes.
*
* @return void
*/
public function testGetClassProperties()
{
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties(__CLASS__));
$expected = array('test', 'test2');
$this->assertEqual($expected, $result);
$result = array_map(function ($property) {
return $property['name'];
}, Inspector::properties(__CLASS__, array('public' => false)));
$expected = array('test', 'test2', '_test');
$this->assertEqual($expected, $result);
$result = Inspector::properties(__CLASS__);
$expected = array(array('modifiers' => array('public'), 'docComment' => false, 'name' => 'test', 'value' => null), array('modifiers' => array('public', 'static'), 'docComment' => false, 'name' => 'test2', 'value' => 'bar'));
$this->assertEqual($expected, $result);
}