Skip to content

Instantly share code, notes, and snippets.

@guiliredu
Last active August 23, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guiliredu/35a687699aab9ca6d0948670b8775935 to your computer and use it in GitHub Desktop.
Save guiliredu/35a687699aab9ca6d0948670b8775935 to your computer and use it in GitHub Desktop.
Example of a PHP Class with Doc Block annotation
<?php
/**
* This class acts as an example on where to position a DocBlock.
*
* A blank line must be place after each paragraph. A title and a description
* can be add. Multiple paragraph descriptions can be used.
*
* @see https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md
* @see http://docs.phpdoc.org/guides/docblocks.html#list-of-tags
*
* @category CategoryName
* @package PackageName
* @author Original Author <author@example.com>
* @author Another Author <another@example.com>
* @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
* @since File available since Release 1.2.0
* @deprecated File deprecated in Release 2.0.0
*/
class Foo
{
/** @var string|null $title contains a title for the Foo */
protected $title = null;
/**
* Sets a single-line title.
*
* @param string $title A text for the title.
*
* @return void
*/
public function setTitle($title)
{
// there should be no docblock here
$this->title = $title;
}
/**
* @param bool $new Comment
*
* @return stdClass|null Comment
* @throws Exception Comment
* @access public
* @see Comment
* @deprecated Comment
*/
function foo($new)
{
if ($new) {
return new stdClass();
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment