Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1

(^98) CHAPTER 7 ■ REFLECTION API
The code in Listing 7-21 demonstrates how to use the getMethods() method as well and
the processing of the in-line link tag.
Listing 7-21. Using getMethods() and Processing the In-Line Link Tag (test3.php)
require_once('DocumentingReflection.php');
class demo {
/**



  • This is the first test method



  • @param mixed $param1 The first comment {@link

  • http://www.apress.com See the website}

  • @param string $param2 The second comment.
    */
    public function demoMethod($param1, $param2) {}
    /**

  • This is the second test method



  • @param mixed $param1 The first comment of the second method

  • @param string $param2 The second comment of the second method
    */
    public function demoMethod2($param1, $param2) {}
    }
    $reflector = new DocumentingReflectionClass('demo');
    foreach($reflector->getMethods() as $method) {
    echo $method->getName(). "\n";
    echo print_r($method->getParsedComments(),1);
    foreach($method->getParameters() as $param) {
    echo "\t". $param->getName(). ' ';
    echo $param->getType(). ' ';
    echo $param->getComment();
    echo "\n";
    }
    echo "\n\n";
    }
    McArthur_819-9C07.fm Page 98 Friday, February 22, 2008 8:59 AM

Free download pdf