本文整理汇总了PHP中Method::getReturnType方法的典型用法代码示例。如果您正苦于以下问题:PHP Method::getReturnType方法的具体用法?PHP Method::getReturnType怎么用?PHP Method::getReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method::getReturnType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isParamType
/**
* validate param type for {$offset}th param
* !!!will return true if we are not sure about the type!!!
*
* @param int $offset Param offset
* @param string $type Doctype styled type
* @return bool
*/
public function isParamType($offset, $expectedType)
{
$param = $this->_params[$offset];
$value = $param->value;
$type = self::TYPE_MIXED;
if ($param->value instanceof \PHPParser_Node_Expr_MethodCall) {
$method = new Method($param->value->name, $param->value->args, null);
$type = $method->getReturnType();
} elseif ($param->value instanceof \PHPParser_Node_Scalar_String || $param->value instanceof \PHPParser_Node_Scalar_ClassConst || $param->value instanceof \PHPParser_Node_Scalar_DirConst || $param->value instanceof \PHPParser_Node_Scalar_FileConst || $param->value instanceof \PHPParser_Node_Scalar_FuncConst || $param->value instanceof \PHPParser_Node_Scalar_LineConst || $param->value instanceof \PHPParser_Node_Scalar_MethodConst || $param->value instanceof \PHPParser_Node_Scalar_NSConst || $param->value instanceof \PHPParser_Node_Scalar_TraitConst) {
$type = self::TYPE_STRING;
} elseif ($param->value instanceof \PHPParser_Node_Scalar_DNumber) {
$type = self::TYPE_FLOAT;
} elseif ($param->value instanceof \PHPParser_Node_Scalar_LNumber) {
$type = self::TYPE_INT;
} elseif ($param->value instanceof \PHPParser_Node_Expr_Array) {
$type = self::TYPE_FLOAT;
}
if (in_array($expectedType, array(self::TYPE_UNKNOWN, self::TYPE_MIXED))) {
return true;
}
return $type == $expectedType;
}