我正在阅读 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 binary characters.
integer or int, the element to which this type applies is a whole number or integer.
boolean or bool, the element to which this type applies only has state true or false.
float or double, the element to which this type applies is a continuous, or real, number.
object, the element to which this type applies is the instance of an undetermined class.
mixed, the element to which this type applies can be of any type as specified here. It is not known on compile time which type will be used.
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 the definition of PHP at http://www.php.net/manual/en/language.types.resource.php.
void, this type is commonly only used when defining the return type of a method or function. The basic definition is that the element indicated with this type does not contain a value and the user should not rely on any retrieved value.
null, the element to which this type applies is a NULL value or, in technical terms, does not exist.
A big difference compared to void is that this type is used in any situation where the described element may at any given time contain an explicit NULL value.
callable, the element to which this type applies is a pointer to a function call. This may be any type of callback as defined in the PHP manual at
(dead link).http://php.net/manual/en/language.pseudo-types.php
false or true, the element to which this type applies will have the value true or false. No other value will be returned from this element.
This type is commonly used in conjunction with another type to indicate that it is possible that true or false may be returned instead of an instance of the other type.
self, the element to which this type applies is of the same Class, or any of its children, as which the documented element is originally contained.
关于php - PHPDoc 的@param 注释的有效值是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15998473/