Last active
June 15, 2024 23:33
-
-
Save guiliredu/35a687699aab9ca6d0948670b8775935 to your computer and use it in GitHub Desktop.
Example of a PHP Class with Doc Block annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 <[email protected]> | |
* @author Another Author <[email protected]> | |
* @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