PHP函数注释

2024-01-10

我看到一些 PHP 函数在顶部被注释,使用的格式我不知道:

/**
 *
 * Convert an object to an array
 *
 * @param    object  $object The object to convert
 * @return      array
 *
 */

我的 IDE 为我提供了 @param 和 @return 等内容的下拉选择,因此必须将其记录在某处。我尝试过搜索谷歌,但它的搜索中不包含@符号。

这种评论格式是什么?我在哪里可以找到相关信息?


功能:

/**
 * Does something interesting
 *
 * @param Place   $where  Where something interesting takes place
 * @param integer $repeat How many times something interesting should happen
 * 
 * @throws Some_Exception_Class If something interesting cannot happen
 * @author Monkey Coder <[email protected] /cdn-cgi/l/email-protection>
 * @return Status
 */ 

Classes:

/**
 * Short description for class
 *
 * Long description for class (if any)...
 *
 * @copyright  2006 Zend Technologies
 * @license    http://www.zend.com/license/3_0.txt   PHP License 3.0
 * @version    Release: @package_version@
 * @link       http://dev.zend.com/package/PackageName
 * @since      Class available since Release 1.2.0
 */ 

样本文件:

<?php

/**
 * Short description for file
 *
 * Long description for file (if any)...
 *
 * PHP version 5.6
 *
 * LICENSE: This source file is subject to version 3.01 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to [email protected] /cdn-cgi/l/email-protection so we can mail you a copy immediately.
 *
 * @category   CategoryName
 * @package    PackageName
 * @author     Original Author <[email protected] /cdn-cgi/l/email-protection>
 * @author     Another Author <[email protected] /cdn-cgi/l/email-protection>
 * @copyright  1997-2005 The PHP Group
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version    SVN: $Id$
 * @link       http://pear.php.net/package/PackageName
 * @see        NetOther, Net_Sample::Net_Sample()
 * @since      File available since Release 1.2.0
 * @deprecated File deprecated in Release 2.0.0
 */

/**
 * This is a "Docblock Comment," also known as a "docblock."  The class'
 * docblock, below, contains a complete description of how to write these.
 */
require_once 'PEAR.php';

// {{{ constants

/**
 * Methods return this if they succeed
 */
define('NET_SAMPLE_OK', 1);

// }}}
// {{{ GLOBALS

/**
 * The number of objects created
 * @global int $GLOBALS['_NET_SAMPLE_Count']
 */
$GLOBALS['_NET_SAMPLE_Count'] = 0;

// }}}
// {{{ Net_Sample

/**
 * An example of how to write code to PEAR's standards
 *
 * Docblock comments start with "/**" at the top.  Notice how the "/"
 * lines up with the normal indenting and the asterisks on subsequent rows
 * are in line with the first asterisk.  The last line of comment text
 * should be immediately followed on the next line by the closing asterisk
 * and slash and then the item you are commenting on should be on the next
 * line below that.  Don't add extra lines.  Please put a blank line
 * between paragraphs as well as between the end of the description and
 * the start of the @tags.  Wrap comments before 80 columns in order to
 * ease readability for a wide variety of users.
 *
 * Docblocks can only be used for programming constructs which allow them
 * (classes, properties, methods, defines, includes, globals).  See the
 * phpDocumentor documentation for more information.
 * http://phpdoc.org/tutorial_phpDocumentor.howto.pkg.html
 *
 * The Javadoc Style Guide is an excellent resource for figuring out
 * how to say what needs to be said in docblock comments.  Much of what is
 * written here is a summary of what is found there, though there are some
 * cases where what's said here overrides what is said there.
 * http://java.sun.com/j2se/javadoc/writingdoccomments/index.html#styleguide
 *
 * The first line of any docblock is the summary.  Make them one short
 * sentence, without a period at the end.  Summaries for classes, properties
 * and constants should omit the subject and simply state the object,
 * because they are describing things rather than actions or behaviors.
 *
 * Below are the tags commonly used for classes. @category through @version
 * are required.  The remainder should only be used when necessary.
 * Please use them in the order they appear here.  phpDocumentor has
 * several other tags available, feel free to use them.
 *
 * @category   CategoryName
 * @package    PackageName
 * @author     Original Author <[email protected] /cdn-cgi/l/email-protection>
 * @author     Another Author <[email protected] /cdn-cgi/l/email-protection>
 * @copyright  1997-2005 The PHP Group
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version    Release: @package_version@
 * @link       http://pear.php.net/package/PackageName
 * @see        NetOther, Net_Sample::Net_Sample()
 * @since      Class available since Release 1.2.0
 * @deprecated Class deprecated in Release 2.0.0
 */
class Net_Sample
{
    // {{{ properties

    /**
     * The status of foo's universe
     * Potential values are 'good', 'fair', 'poor' and 'unknown'.
     * @var string $foo
     */
    public $foo = 'unknown';

    /**
     * The status of life
     * Note that names of private properties or methods must be
     * preceeded by an underscore.
     * @var bool $_good
     */
    private $_good = true;

    // }}}
    // {{{ setFoo()

    /**
     * Registers the status of foo's universe
     *
     * Summaries for methods should use 3rd person declarative rather
     * than 2nd person imperative, beginning with a verb phrase.
     *
     * Summaries should add description beyond the method's name. The
     * best method names are "self-documenting", meaning they tell you
     * basically what the method does.  If the summary merely repeats
     * the method name in sentence form, it is not providing more
     * information.
     *
     * Summary Examples:
     *   + Sets the label              (preferred)
     *   + Set the label               (avoid)
     *   + This method sets the label  (avoid)
     *
     * Below are the tags commonly used for methods.  A @param tag is
     * required for each parameter the method has.  The @return
     * and @access tags are mandatory.  The @throws tag is required if
     * the method uses exceptions.  @static is required if the method can
     * be called statically.  The remainder should only be used when
     * necessary.  Please use them in the order they appear here.
     * phpDocumentor has several other tags available, feel free to use
     * them.
     *
     * The @param tag contains the data type, then the parameter's
     * name, followed by a description.  By convention, the first noun in
     * the description is the data type of the parameter.  Articles like
     * "a", "an", and  "the" can precede the noun.  The descriptions
     * should start with a phrase.  If further description is necessary,
     * follow with sentences.  Having two spaces between the name and the
     * description aids readability.
     *
     * When writing a phrase, do not capitalize and do not end with a
     * period:
     *   + the string to be tested
     *
     * When writing a phrase followed by a sentence, do not capitalize the
     * phrase, but end it with a period to distinguish it from the start
     * of the next sentence:
     *   + the string to be tested. Must use UTF-8 encoding.
     *
     * Return tags should contain the data type then a description of
     * the data returned.  The data type can be any of PHP's data types
     * (int, float, bool, string, array, object, resource, mixed)
     * and should contain the type primarily returned.  For example, if
     * a method returns an object when things work correctly but false
     * when an error happens, say 'object' rather than 'mixed.'  Use
     * 'void' if nothing is returned.
     *
     * Here's an example of how to format examples:
     * <code>
     * require_once 'Net/Sample.php';
     *
     * $s = new Net_Sample();
     * if (PEAR::isError($s)) {
     *     echo $s->getMessage() . "\n";
     * }
     * </code>
     *
     * Here is an example for non-php example or sample:
     * <samp>
     * pear install net_sample
     * </samp>
     *
     * @param string $arg1 the string to quote
     * @param int    $arg2 an integer of how many problems happened.
     *                     Indent to the description's starting point
     *                     for long ones.
     *
     * @return int the integer of the set mode used. FALSE if foo
     *             foo could not be set.
     * @throws exceptionclass [description]
     *
     * @access public
     * @static
     * @see Net_Sample::$foo, Net_Other::someMethod()
     * @since Method available since Release 1.2.0
     * @deprecated Method deprecated in Release 2.0.0
     */
    function setFoo($arg1, $arg2 = 0)
    {
        /*
         * This is a "Block Comment."  The format is the same as
         * Docblock Comments except there is only one asterisk at the
         * top.  phpDocumentor doesn't parse these.
         */
        if ($arg1 == 'good' || $arg1 == 'fair') {
            $this->foo = $arg1;
            return 1;
        } elseif ($arg1 == 'poor' && $arg2 > 1) {
            $this->foo = 'poor';
            return 2;
        } else {
            return false;
        }
    }

    // }}}
}

// }}}

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * c-hanging-comment-ender-p: nil
 * End:
 */

?>

Source: PEAR Docblock 注释标准 http://pear.php.net/manual/en/standards.sample.php

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PHP函数注释 的相关文章

  • 将子域重定向到 CakePHP 操作

    背景 我有一个 CakePHP 应用程序 位于 m 我想写一个根级别的 htaccess文件 它将重定向网站的 子域 作为操作的参数 例如 我想编写一个重写规则 这将导致像这样的重定向 http mysite myserver com ht
  • PHP/PDO/MySQL:插入 MEDIUMBLOB 会存储错误数据

    我有一个简单的 PHP Web 应用程序 它通过文件上传接受图标图像并将它们存储在 MEDIUMBLOB 列中 在我的机器 Windows 和两台 Linux 服务器上 这工作得很好 在第三台 Linux 服务器上 插入的图像已损坏 在 S
  • PHP中如何替换字符串?

    我有一个变量 其中包含如下所示的字符串 p The post a href http zed1 com journalized archives 2012 03 11 wordpress 3 for business bloggers Wo
  • 如何自定义 Zend_Form 正则表达式错误消息?

    我有以下代码 postcode form gt createElement text postcode postcode gt setLabel Post code postcode gt addValidator regex false
  • 图片无法直接上传到相册

    我正在开发上传图片文件的应用程序 但图片不能直接上传到相册 上传之前始终必须经过批准 如何解决这个问题 问题 您想将这些照片添加到您的相册吗 下面的照片是从另一个应用程序上传的 您需要批准它们 你需要user photos允许直接上传到相册
  • 使用 href 和 php 从 sql 数据库对 html 表进行排序

    我有一个 html 表 其中包含来自 php 吐出的 sql 表的产品数据 我想通过单击表列的标题对数据进行排序 我像这样输出我的表 php product list sql mysql query SELECT FROM products
  • PDO 如何在执行 rollBack() 函数之前回滚查询?

    这是我的脚本 try dbh con gt beginTransaction stmt1 dbh conn gt prepare UPDATE activate account num SET num num 1 stmt1 gt exec
  • 如何在 laravel/php 中访问该集合的内容

    我是 Laravel 的新手 正在做一个构建迷你社交网络应用程序的项目 我有一个与用户模型有关系的帖子模型 我有一个帖子页面 其中仅显示经过身份验证的用户及其朋友的帖子 在我的 PostController 中 我像这样查询经过身份验证的用
  • 如何正确使用Javascript“导出”和“导入”功能?

    我想将函数从 lib js 文件导出到 main js 文件 我有 lib js export const sqrt Math sqrt export function square x return x x export function
  • CodeIgniter Active Record - 组 OR 语句

    这是我的问题 MySQL 或 条件 https stackoverflow com questions 8604380 mysql or condition 解决方案是将 OR 语句分组 但我正在使用 CodeIgniters Active
  • CMake:如何将 .def 文件添加到 Visual Studio 项目过滤器?

    如何将 def 文件添加到 Visual Studio 项目过滤器 filters文件 Visual Studio 使用 def 文件 CMake代码 set a src a cpp a def add library a SHARED a
  • MPDF 未定义索引错误

    我正在使用 MPDF 库将 HTML 转换为 PDF 这是我的代码 HTML HTML CONTENT GOES HERE HTML STRING MPDF gt WriteHTML html Converting MPDF gt Outp
  • 如何使用 PHP SoapClient 添加任意命名空间?

    如何使用 PHP SoapClient 添加任意名称空间 命名空间实际上并未在请求中使用 但我认为它阻止了我的消息被正确使用 WSDL 在这里 http abr business gov au abrxmlsearchRPC ABRXMLS
  • 密码验证 PHP 正则表达式

    我是正则表达式的新手 我需要使用 php 验证密码 并使用正则表达式执行以下密码策略 密码 必须至少有 8 个字符 必须有2个号码 允许的符号有 我已经尝试过以下方法 d A Za z 0 9A Za z 以下完全符合您的要求 d d 0
  • mysqli_connect(): (HY000/2002): 无法建立连接,因为目标机器主动拒绝

    我知道有很多这样的问题 但我没有找到任何解决方案 我尝试过的事情 检查防火墙 重新启动我的电脑和 Apache 服务器 重新启动MYSQL 检查了我的代码 尝试了我所知道的和在互联网上找到的一切 这是我的代码
  • 如何在 Api-Platform 中按链接属性过滤结果?

    我有一个User实体和一个Organisation实体 存在关系ManyToOne之间Booking and User ORM ManyToOne targetEntity App Entity User inversedBy bookin
  • 尝试使用curl进行GET,发送的值允许为空

    我正在尝试使用curl 来执行一个简单的GET 其中包含一个名为redirect uri 的参数 被调用的 php 文件打印出 GET redirect uri 的空字符串 它显示 red 并且似乎没有发送任何内容 执行获取操作的代码 Ge
  • 使用 PHP 将子项添加到 XML 文件

    添加子项时 抛出此错误 无法添加孩子 父级不是 XML 树的永久成员 我无法解决这个问题 这是我的代码 if visited FIRST xml new SimpleXMLElement
  • Curl 和 Php 5.3.3 中的 SSL 连接错误

    我的网站自 3 年来一直运行良好 代码如下 现在突然从 2 天开始出现以下错误 SSL 连接错误 在 Curl error 中 下面是我的代码
  • 日期函数的奇怪行为

    我今天在 StackOverflow 上遇到了这个问题 但没有得到答案 我的问题是 echo date Y m d strtotime 2012 september 09 output 2012 09 01 echo date Y m d

随机推荐

  • ZipArchive 在 Laravel 中不起作用

    我有 laravel 项目 想要添加压缩文件的功能 我正在使用 php ZipArchive 当我尝试仅使用 PHP 创建 ZIP 文件时 我很幸运 但是当我尝试使用 Laravel 时 未创建 zip 文件 所以我添加了 使用ZipArc
  • 时间:2019-03-17 标签:c++STLmin_element

    我想找到数组中的最小元素 但如果最小元素出现多次 那么我想要该元素的最后一次出现 我用了std min element 和我的comp 功能 vector
  • Julia 浮点比较为零

    julia gt r 3 3 Array Float64 2 1 77951 0 79521 2 57472 0 0 0 630793 0 630793 0 0 0 0 1 66533e 16 julia gt sort abs diag
  • 使用核心转储在 Linux 中进行调试

    使用 GDB 调试核心转储时的 最佳实践 是什么 目前 我面临一个问题 我的应用程序的发行版是在没有 g 编译器标志的情况下编译的 我的应用程序的调试版本 使用 g 编译 已存档 以及源代码和发布二进制文件的副本 最近 当用户给我一个核心转
  • 如何将图像保存为变量?

    现在 我有一个带有精灵的 python 游戏 它从其目录中的文件中获取图像 我想让它变得我什至不需要这些文件 不知何故 将图像预先存储在变量中 以便我可以从程序中调用它 而无需额外的 gif 文件的帮助 我使用图像的实际方式是 image
  • 如何在jsp中显示图片?

    我有一个字节数组图像 我需要在 jsp 页面中以 jpg 格式显示该图像 单击该图像时 我可以将图像下载到我的电脑上 我正在从 mysql 数据库将图像加载为字节数组 我的代码是 ResultSet res statement execut
  • SCORM 1.2 API 示例/教程

    我花了相当多的时间搜索 SCORM 1 2 API 教程 示例 结果证明这是一项相当困难的任务 我发现的唯一样本是这样的 http www vsscorm net 2009 05 30 ground rules http www vssco
  • maven-compiler-plugin:jar:3.8.1 丢失

    尝试使用 3 8 1 而不是 3 8 0 但收到消息 警告 org apache maven plugins maven compiler plugin jar 3 8 1 的 POM 丢失 没有可用的依赖信息 我的 pom xml 在 3
  • 如果 File 不存在,如何确定它是否是文件或目录?

    File isFile and File isDirectory 不仅当File不是指定的类型 而且当File其本身不存在于文件系统上 如何判断是否File当文件或目录不存在时代表它 一般来说 一个特定的路径既可以代表一个目录 也可以代表一
  • 使用 Node.JS

    昨晚我转储了 Windows 7 并格式化了我的硬盘驱动程序以移植到基于 Linux 的操作系统 纯粹是因为我想开始使用Node JS 所以我已经安装了Node JS并做了一些测试 http 服务器和套接字等 我想做的是构建一个与 MVC
  • 如何使用 pgAdmin 添加几何列

    我正在使用在 PostgreSQL 中创建的数据库 在其架构中有两个表 我想在其中一个表中添加一个geometry柱子 问题是我创建了 postgis 扩展 CREATE EXTENSION postgis 对于数据库 但我无法使用 pgA
  • MVC AuthenticationManager.SignOut() 未注销

    我的项目基于 Visual Studio 2013 中的 MVC 5 项目模板 个人用户帐户选项 我一直依赖用户的默认登录和注销方法 但我不确定我做了什么 在某些时候 用户无法再注销 但他们可以以其他用户的身份登录 这是帐户控制器的默认注销
  • 是否有一种补充方法来获取鼠标事件之类的东西?

    直接使用 jQuery 如果我有一个固定框 例如 一个彩色矩形 并且将鼠标移入或移出其中 则如果我将鼠标光标以一种或另一种方式移动到框的边界上 jQuery 就会给我事件 如果我有一个以编程方式移动的彩色矩形 例如向右移动 然后我将鼠标放在
  • 无法在模拟器中运行应用程序:运行时遇到错误(域 = LaunchServicesError,代码 = 0)

    在 Xcode 6 中成功编译项目后 我无法在模拟器中运行它并显示上述消息 我做了所有可能的研究 尝试了一切 但仍然没有任何进展 我不使用 swift 也不使用小部件或扩展 因此请不要建议由这些引起的解决方案 如类似问题中所示 如果有人发现
  • Applet 与 Servlet

    JAVA中Applet和Servlet有什么区别 Applet运行在客户端 servlet运行在服务器上 就这么简单 更具体地说 该小程序被下载到客户端 并在浏览器内的 JRE 中执行 并且可以在小程序框架内显示它想要显示的任何内容 相反
  • 屏幕抓取建议:交互式图表

    我最近学习了一些关于如何在 Python 中使用 BeautifulSoup 的教程 并学习了如何简单地从网页中抓取文本和 URL 我现在正在尝试从以下链接中抓取数据 http www study cam ac uk undergradua
  • ClosedXML 添加图像

    我可以使用 OpenXML 将图像添加到 Excel 电子表格中 然而 对于程序的其余部分 我使用 ClosedXML 来添加数据 我可以使用列和行索引在特定单元格添加数据 如果我可以将图像添加到 Excel 它目前似乎是一个单独的层 悬停
  • 解析可选参数和非可选参数

    我是 bash 的新手 在阅读并尝试了很多有关如何解析参数的内容后 我无法做我真正想做的事情 我想解析可选参数和非可选参数 更具体地说 我想解析 3 个参数 第一个 fastaq 文件 第二个 第二个可选 fastaq 文件 第三个参数将是
  • pgAdmin Docker 错误:“用户名或密码不正确”

    有一些简单的 docker compose yml 文件配置 但我不确定为什么我不能使用登录到 pgAdmin 电子邮件受保护 cdn cgi l email protection作为电子邮件和admin作为密码 是否需要更多配置或者我使用
  • PHP函数注释

    我看到一些 PHP 函数在顶部被注释 使用的格式我不知道 Convert an object to an array param object object The object to convert return array 我的 IDE