PHP code example of stein197 / doxer

1. Go to this page and download the library: Download stein197/doxer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stein197 / doxer example snippets


$docblock = <<<DOC
/**
 * Description.
 * Another line
 * of description.
 * @param int \$age Age parameter.
 * @param string \$name Name
 *                      parameter.
 * @return Person The person.
 * @throws Exception In case of errors.
 * 
DOC;
$doc = new Stein197\Doxer\Doc($docblock);
if ($doc->exists()) { // Checks for existance
	$doc->getDescription(); // "Description. Another line of description."
	foreach ($doc->getTags() as $tag) { // Returns and array of Stein197\Doxer\Tag instances
		$tag->getDescription(); // Handles multiple lines of description
		$tag->getName(); // Returns the name of the tag without "@" char
		foreach ($tag->getProperties() as $name => $value) { // Returns an array of properties
			"$name=$value"; // Tag's properties such as "version", "type", etc.
		}
	}
}

$returnTag = (new Stein197\Doxer\Doc('/** @return string A string */'))->getTags()[0];
$returnTag->getDescription(); // "A string"
$returnTag->getProperties(); // ['type' => 'string']

$tag = (new Stein197\Doxer\Doc('/** @nonexistent string A string */'))->getTags()[0];
$tag->getDescription(); // "string A string"
$tag->getProperties(); // null

$tag = (new Stein197\Doxer\Doc('/** @param a b c d */'))->getTags()[0];
$tag->getDescription(); // null
$tag->getProperties(); // null

$doc = new Stein197\Doxer\Doc('/** @param Type $arg1 */');
$doc->getTags()[0]->getProperties(); // ['name' => 'arg1']