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函数注释 的相关文章

  • 检查php中位字段是否打开的正确方法是什么

    检查位字段是否打开的正确方法是什么 在 php 中 我想检查来自 db mysql 的位字段是否打开 这是正确的方法吗 if bit 1 还有其他方法吗 我看到有人使用代码ord http jameslow com 2008 08 12 m
  • 通过 Ajax 加载内容时,WORDPRESS 音频播放器未加载,MediaElement.js 未应用

    我正在创建一个 WordPress 主题 当我使用 ajax 加载内容时 它不会将 MediaElements js 应用于我的音频播放器 因此不会显示音频 我认为这是因为 MediaElement js 加载了 wp footer 并且此
  • 删除PHP字符串中所有不匹配的字符?

    我有一个文本 我想从中删除所有不属于以下字符的字符 所需字符 0123456789 abcdefghijklmnopqrstuvwxyz n 最后一个是我确实想保留的 n 换行符 要匹配除列出的字符之外的所有字符 请使用反转字符集 http
  • 重定向而不改变url

    我总是不喜欢 htaccess 我正在尝试建立一个所有请求都通过index php 的网站 但我希望URL 类似于www sample com home 该网址实际上会加载 www sample com index php page hom
  • 生成大随机数 php [重复]

    这个问题在这里已经有答案了 我想使用 PHP 生成一个包含 75 个字符的数字 我到处寻找 但一无所获 除了这个 http dailycoding com tools RandomNumber aspx http dailycoding c
  • 如何使用 php 发送服务器错误响应?

    一旦用户点击删除按钮我的 jQuery 脚本要求服务器删除所选项目 现在我想要我的php发送成功或错误响应的脚本 是否有可能触发错误回调万一该项目无法删除 Thanks 我的 jQuery 代码 ajax type post url myA
  • posts_search 中的自定义查询

    如何使用此查询作为我的自定义搜索查询 add filter posts search my search is perfect 20 2 function my search is perfect search wp query sWord
  • 如何使用 php 下载/打印页面的特定部分

    我有一个 HTML 页面如下 Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the indust
  • 将“php”作为 shell 脚本执行时的自定义 php.ini 文件

    我在跑php作为 shell 脚本 我不确定 shell脚本 是否正确 该文件以 usr bin php 这很好用 但 MongoDB 类没有正确加载php ini文件 具有extension mongo so 未使用 我该如何使用它tha
  • “使用未定义常量”注意,但该常量应该被定义

    共有三个文件 common php controller php 和 user php 文件 common php 如下所示 文件controller php看起来像 文件 user php 如下所示 执行脚本时 会给出通知 注意 使用未定
  • 为什么 iconv 在 php:7.4-fpm-alpine docker 中返回空字符串

    给出以下代码
  • PHP 在输入流中使用 fwrite 和 fread

    我正在寻找将 PHP 输入流的内容写入磁盘的最有效方法 而不使用授予 PHP 脚本的大量内存 例如 如果可以上传的最大文件大小为 1 GB 但 PHP 只有 32 MB 内存 define MAX FILE LEN 1073741824 1
  • PHP 脚本可以在终端中运行,但不能在浏览器中运行

    我正在尝试执行exec命令 但我遇到了问题 当我运行以下代码时 当我通过浏览器运行它时它不起作用 但如果我把输出 str将其复制并粘贴到终端中 它工作得很好 造成这种情况的原因是什么 我该如何解决 目前我正在运行localhost php
  • 在 Wordpress 站点中进行 AJAX 调用时出现问题

    我在使用 Wordpress 站点功能的 AJAX 部分时遇到了一些问题 该功能接受在表单上输入的邮政编码 使用 PHP 函数来查找邮政编码是否引用特定位置并返回到该位置的永久链接 我的第一个问题是关于我构建的表单 现在我的表单操作是空白的
  • PHP 与 MySQL 查询性能( if 、 函数 )

    我只看到这个artice http www onextrapixel com 2010 06 23 mysql has functions part 5 php vs mysql performance 我需要知道在这种情况下什么是最好的表
  • PHP preg_filter 返回意外的长值

    尝试在 Woocommerce 中删除标签并过滤值 但无法以正确的格式获取它 有东西有腥味 我正在使用WC gt cart gt get cart subtotal 来检索该值 在此示例中 我的值是 2 429kr 原始返回值是 span
  • 一次播种多行 laravel 5

    我目前正在尝试为我的用户表播种 如果我像这样尝试 2 行 就会失败 如果我只使用单个数组而不是 users 数组内的 2 个数组来创建一些假数据 那么效果很好 我做错了什么 正确的方法是什么 class UserTableSeeder ex
  • 使用正则表达式提取两个短语之间的所有单词[重复]

    这个问题在这里已经有答案了 我正在尝试使用以下正则表达式提取两个短语之间的所有单词 b item W w W 0 2 1 one W w W 0 3 business b b item W w W 0 2 3 three W w W 0 3
  • ini_set 'session.gc_maxlifetime' 为 1 天

    If I do ini set session gc maxlifetime 86400 这是否意味着用户可以将浏览器留在同一页面 非活动状态 最多 1 天 而不必担心会话被垃圾收集并被注销 如果服务器配置不支持此功能会发生什么 它会给我一
  • 为什么 Composer 降级了我的包?

    php composer phar update这样做了 删除了 2 3 0 软件包并安装了整个 2 2 5 Zend Framework php composer phar update Loading composer reposito

随机推荐

  • 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