mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-18 11:31:16 +02:00
Add a PHPDoc post
This commit is contained in:
36
_posts/15-01-01-PHPDoc.md
Normal file
36
_posts/15-01-01-PHPDoc.md
Normal 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 %}
|
Reference in New Issue
Block a user