From b717500558d9433b10a40e6a91c67c811001e5cb Mon Sep 17 00:00:00 2001 From: Gareth Evans Date: Fri, 20 Jun 2014 21:29:47 +0100 Subject: [PATCH] Add a PHPDoc post --- _posts/15-01-01-PHPDoc.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 _posts/15-01-01-PHPDoc.md diff --git a/_posts/15-01-01-PHPDoc.md b/_posts/15-01-01-PHPDoc.md new file mode 100644 index 0000000..6b10b60 --- /dev/null +++ b/_posts/15-01-01-PHPDoc.md @@ -0,0 +1,36 @@ +--- +anchor: phpdoc +--- + +# PHPDoc {#phpdoc} + +PHPDoc is an informal standard for commenting PHP code. There are a *lot* of different [tags](http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.pkg.html) available. The full list of tags and examples can be found at the [PHPDoc manual](http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.pkg.html). + +Below is an example of how you might comment a class and a method; + +{% highlight php %} + + * @link http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.link.pkg.html + * @package demo + */ +class DateTimeHelper +{ + /** + * @param mixed $anything + * + * @return \DateTime + * @throws \InvalidArgumentException + */ + public static function dateTimeFromAnything($anything) { + $type = gettype($anything); + + switch ($type) { + case "object": + if ($anything instanceof \DateTime) { + return $anything; + } + break; +... +{% endhighlight %}