gpt4 book ai didi

php - PHPDoc 的@param 注释的有效值是什么?

转载 作者:可可西里 更新时间:2023-11-01 00:33:42 27 4
gpt4 key购买 nike

我正在阅读 PHPdocs this :

The datatype should be a valid PHP type (int, string, bool, etc)," which is fine, but they don't say which strings (such as int, string, bool) to use to identify the other types.

我猜他们使用 (cast) 语法来确定要用于注释的类型,但是像 PHP 中的 float 这样的东西没有用于它的 cast 运算符,所以我不确定该使用什么为了那个原因。可能是 float,也可能是 fp。

有没有人有 PHP 中基本类型的明确列表,以及在您的 PHP 文档中应该使用什么字符串来识别它们?

最佳答案

文档中都列出了:http://phpdoc.org/docs/latest/references/phpdoc/types.html (原始链接已失效;现在链接到 Internet Archive 副本)

对于 float ,关键字(逻辑上足够)是float


The following keywords are recognized:

string, the element to which this type applies is a string of binarycharacters.

integer or int, the element to which this type applies is a wholenumber or integer.

boolean or bool, the element to which this type applies only has statetrue or false.

float or double, the element to which this type applies is acontinuous, or real, number.

object, the element to which this type applies is the instance of anundetermined class.

mixed, the element to which this type applies can be of any type asspecified here. It is not known on compile time which type will beused.

array, the element to which this type applies is an array of values,see the section on Arrays for more details.

resource, the element to which this type applies is a resource per thedefinition of PHP athttp://www.php.net/manual/en/language.types.resource.php.

void, this type is commonly only used when defining the return type ofa method or function. The basic definition is that the elementindicated with this type does not contain a value and the user shouldnot rely on any retrieved value.

null, the element to which this type applies is a NULL value or, intechnical terms, does not exist.

A big difference compared to void is that this type is used in anysituation where the described element may at any given time contain anexplicit NULL value.

callable, the element to which this type applies is a pointer to a function call. This may be any type of callback asdefined in the PHP manual athttp://php.net/manual/en/language.pseudo-types.php(dead link).

false or true, the element to which this type applies will have thevalue true or false. No other value will be returned from thiselement.

This type is commonly used in conjunction with another type toindicate that it is possible that true or false may be returnedinstead of an instance of the other type.

self, the element to which this type applies is of the same Class, orany of its children, as which the documented element is originallycontained.

phpDoc via Internet Archive

关于php - PHPDoc 的@param 注释的有效值是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15998473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com