PHP code example of jan-swiecki / simple-annotations

1. Go to this page and download the library: Download jan-swiecki/simple-annotations 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/ */

    

jan-swiecki / simple-annotations example snippets


 
 class MyClass
 {
     /**
      * @awesomeVariable "I am a string"
      */
     public function fn()
     {

     }
 }
 

 $reader = new \DocBlockReader\Reader('MyClass', 'fn');
 $reader->getParameter("awesomeVariable")
 



 MyClass
{
	/**
	 * @var0 1.5
	 * @var1 1
	 * @var2 "123"
	 * @var3 abc
	 * @var4 ["a", "b"]
	 * @var5 {"x": "y"}
	 * @var6 {"x": {"y": "z"}}
	 * @var7 {"x": {"y": ["z", "p"]}}
	 *
	 * @var8
	 * @var9 null
	 *
	 * @var10 true
	 * @var11 tRuE
	 * @var12 false
	 * @var13 null
	 * 
	 */
	private function MyMethod()
	{
	}
};

$reader = new DocBlockReader\Reader("MyClass", "MyMethod");

var_dump($reader->getParameters());



 MyClass
{
	/**
	 * @var x
	 * @var2 1024
	 * @param string x
	 * @param integer y
	 * @param array z
	 */
	private function MyMethod()
	{
	}
};

$reader = new DocBlockReader\Reader("MyClass", "MyMethod");

var_dump($reader->getParameters());



 MyClass
{
	/**
	 * @get @post
	 * @ajax
	 * @postParam x @postParam y
	 * @postParam z
	 */
	private function MyMethod()
	{
	}
};

$reader = new DocBlockReader\Reader("MyClass", "MyMethod");

var_dump($reader->getParameters());



 MyClass
{
	/**
	 * @param string var1
	 * @param integer var2
	 */
	private function MyMethod()
	{
	}
};

$reader = new DocBlockReader\Reader("MyClass", "MyMethod");

var_dump($reader->getVariableDeclarations("param"));