什么是正确的PHP函数文档格式? [英] What is the proper PHP function documentation format?

查看:123
本文介绍了什么是正确的PHP函数文档格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP文档是一种野生动物,即使是underscore_vsCamelCase样式也不是这样。所以给出我迄今为止看到的所有类型的PHP文档 - 哪个是标准?我的函数和方法应该如何标记,以便大多数IDE和文档库可以读取它们?

PHP documentation is one wild animal, even the underscore_vsCamelCase styling isn't this varied. So given all the types of PHP documentation I have seen so far - which is the standard? How are my functions and methods supposed to be marked up so that the majority of IDE's and documentation libraries can read them?

在下面的示例中,(type)是

In the below examples the (type) is one of:


  • bool

  • int

  • li>
  • 对象

  • string

  • float

  • bool
  • int
  • array
  • object
  • string
  • float

,名称只是param变量的名称(如$ values)

and the name is just the name of the param variable (like $values)

/*
 * Function name
 *
 * what the function does
 *
 * @param (type) about this param
 * @return (type)
 */
function example((name))

/*
 * What the function does
 *
 * @param (name) about this param
 * @return (name)
 */
function example((name))

/**
 * Function name
 *
 * what the function does
 *
 * @param (type) (name) about this param
 * @return (type) (name)
 */
function example((name))

/**
 * Function name
 * what the function does
 *
 * Parameters:
 *     (name) - about this param
 */
function example((name))


推荐答案

没有官方的根据Hoyle ,评论风格。最接近的是Zend Framework的编码指南。 Zend框架由Zend生产,Zend深入参与创建PHP,所以你可以认为他们的编码指南是应该遵循的。

There is no official, according to Hoyle, comment style. The closest you'll find is the Zend Framework's coding guidelines. Zend Framework is produced by Zend, which is deeply involved in the creation of PHP, so you could argue that their coding guidelines are the ones that should be followed.

也可以认为,任何以

/** <--- starts with
*/  <--- ends with

是一种官方文档格式,因为这些格式将被解析并通过反射API提供。许多人利用此功能,以及 PHPDoc 格式来生成官方的评论格式。

Is an "official" documentation format, as these will be parsed and made available via the reflection API. Many people leverage this, and the PHPDoc format to produce an official-ish comment format.

这篇关于什么是正确的PHP函数文档格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆