本文整理汇总了PHP中phpDocumentor\Reflection\DocBlock\Tag::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::getType方法的具体用法?PHP Tag::getType怎么用?PHP Tag::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpDocumentor\Reflection\DocBlock\Tag
的用法示例。
在下文中一共展示了Tag::getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createProperty
protected function createProperty(Tag $tag)
{
$name = trim($tag->getVariableName(), '$');
$prop = new ClassProperty();
$prop->name = $name;
$prop->setType($this->getFQCN($tag->getType()));
return $prop;
}
示例2: setTypes
/**
* Adds type information to the structure.
*
* @param string[] $types Array with types in any format; will be transformed
* to FQCN.
*
* @todo Move this method to a better spot with namespace and alias access
* (together with namespace and alias stuff).
*
* @return void
*/
public function setTypes($types)
{
foreach ($types as $type) {
if ($type == '') {
continue;
}
$type = trim($this->expandType($type));
// strip ampersands
$name = str_replace('&', '', $type);
$type_object = $this->xml->addChild('type', $name);
// register whether this variable is by reference by checking
// the first and last character
$type_object['by_reference'] = substr($type, 0, 1) === '&' || substr($type, -1) === '&' ? 'true' : 'false';
}
$this->xml['type'] = $this->expandType($this->tag->getType());
}
示例3: findType
/**
* @param string $actualNamespace
* @param Tag $tag
*
* @return string
*/
private function findType(Tag $tag, $actualNamespace, array $use, array $classes)
{
$rawType = $tag->getType();
if ($rawType === 'integer') {
$rawType = 'int';
}
$primitiveTypes = array('string', 'int', 'integer', 'float', 'double', 'bool', 'boolean', 'array', 'null', 'callable', 'scalar', 'void', 'object');
$excludedType = array('mixed', 'callable', 'callable[]', 'scalar', 'scalar[]', 'void', 'object', 'self', 'resource', 'true');
if (in_array($rawType, $excludedType) === true || count(explode('|', $rawType)) !== 1) {
return array('value' => '', 'isClass' => false);
}
$arrayOfPrimitiveTypes = array_map(function ($val) {
return $val . '[]';
}, $primitiveTypes);
if (preg_match("/^[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*\$/", $rawType) === 0) {
// this is a typo
$this->logger->log(sprintf('Type "%s" does not exist in docblock', $rawType));
$type = array('value' => '', 'isClass' => false);
} elseif (in_array(strtolower($rawType), $primitiveTypes)) {
$type = array('value' => strtolower($rawType), 'isClass' => false);
} elseif (in_array(strtolower($rawType), $arrayOfPrimitiveTypes)) {
$type = array('value' => strtolower($rawType), 'isClass' => false);
} else {
// considered as class
$type = array('value' => $rawType, 'isClass' => true);
}
return $type;
}
示例4: getType
/**
* Gets the type of the parameter or null if it is not defined.
*
* @param Tag $tag
*
* @return array
*/
private function getType(Tag $tag) : array
{
$type = $tag->getType();
if ($type instanceof Compound) {
if ($type->has(2)) {
// Several types, cannot guess
return [];
}
$type0 = $type->get(0);
$type1 = $type->get(1);
if ($type0 instanceof Null_ && $type1 instanceof Null_) {
// No type hint
return [];
}
if (!$type0 instanceof Null_ && $type1 instanceof Null_) {
return [$type0->__toString(), true];
}
if (!$type1 instanceof Null_ && $type0 instanceof Null_) {
return [$type1->__toString(), true];
}
// Mixed types, cannot guess
return [];
}
return [$type->__toString(), false];
}
示例5: getTypeFromTag
/**
* Gets the type of the parameter or an empty array if it is not defined.
*
* @param Tag $tag
*
* @return array
*/
private function getTypeFromTag(Tag $tag) : array
{
$type = $tag->getType();
if (null === $type) {
// No type specified
return [];
}
if ($type instanceof Compound) {
if ($type->has(2)) {
// Several types, cannot guess
return [];
}
$type0 = $type->get(0);
$type1 = $type->get(1);
if ($type0 instanceof Null_ && $type1 instanceof Null_) {
// No type hint
return [];
}
if (!$type0 instanceof Null_ && $type1 instanceof Null_) {
return [$type0->__toString(), true];
}
if (!$type1 instanceof Null_ && $type0 instanceof Null_) {
return [$type1->__toString(), true];
}
// Mixed types, cannot guess
return [];
}
if ($type instanceof Array_) {
// May contain more specific type declarations, but we only
// convert to pure arrays
return ['array', false];
}
return [$type->__toString(), false];
}