PHP code example of kamermans / docblock-reflection

1. Go to this page and download the library: Download kamermans/docblock-reflection 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/ */

    

kamermans / docblock-reflection example snippets


/**
 * A Foo class
 * 
 * @deprecated
 * @version      v1.1
 * @see          Foo::bar()
 * @see          google.com
 */
class Foo {
	/**
	 * Does something that is really
	 * cool and makes your life easy
	 * 
	 * @param string $name Your name
	 * @return string
	 */
	public function bar($name) {
		return "FooBar $name";
	}
}

$reflect = new RelflectionClass("Foo");
echo $reflect->getDocComment(); // spits out the raw block

use kamermans\Reflection\DocBlock;

$reflect = new ReflectionClass("Foo");
$doc = new DocBlock($reflect);

// Check if the @deprecated tag exists
$doc->tagExists("deprecated");

// Get the comment "A Foo class"
$doc->getComment();

echo $doc->version; // v1.1

// The same tag can be set multiple times
echo implode("|", $doc->see); // Foo::bar()|google.com

// It works on methods too
$doc = new DocBlock($reflect->getMethod("bar"));
echo "Foo returns a $doc->return\n"; // Foo returns a string

// Multiline comments work too
$doc->getComment();