Add a PHPDoc post

This commit is contained in:
Gareth Evans
2014-06-20 21:29:47 +01:00
parent de4495fac2
commit b717500558

36
_posts/15-01-01-PHPDoc.md Normal file
View File

@@ -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 %}
<?php
/**
* @author A Name <a.name@example.com>
* @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 %}