Pro PHP- Patterns, Frameworks, Testing and More
CHAPTER 7 ■ REFLECTION API^75 foreach(get_declared_classes() as $class) { $reflectionClass = new ReflectionClass($class); if($re ...
(^76) CHAPTER 7 ■ REFLECTION API /** This is soft metadata and its structure is not parsed by PHP @see http://example.com/ */ fu ...
CHAPTER 7 ■ REFLECTION API^77 This doesn’t make a lot of sense, because you’ve added function bodies for a bunch of methods you ...
(^78) CHAPTER 7 ■ REFLECTION API Chapter 1), this method does not require an instance of the class to operate and is thus much m ...
CHAPTER 7 ■ REFLECTION API^79 Now that you have a ReflectionMethod instance, you need to determine if your API method should be ...
(^80) CHAPTER 7 ■ REFLECTION API $sidebars = array_merge($sidebars, $items); } } return $sidebars; } Next, create a class that i ...
CHAPTER 7 ■ REFLECTION API^81 In Listing 7-8, you may replace the print_r calls with whatever way you wish to render the result ...
(^82) CHAPTER 7 ■ REFLECTION API If you do not get this output, it is likely that you need to enable the extension in your php.i ...
CHAPTER 7 ■ REFLECTION API^83 When executed, the code in Listing 7-9 results in the following: /** * This is a doccomment * * Th ...
(^84) CHAPTER 7 ■ REFLECTION API The result of this code is as follows: 1=DOCBLOCK_NEWLINE= 2=DOCBLOCK_WHITESPACE= 36=DOCBLOCK_T ...
CHAPTER 7 ■ REFLECTION API^85 foreach($tokens as $token) { //Switch on the token's code switch( $token[0] ) { case DOCBLOCK_TEXT ...
(^86) CHAPTER 7 ■ REFLECTION API When run, this parser outputs the following: Array ( [0] => This is a doccomment comment [1] ...
CHAPTER 7 ■ REFLECTION API^87 Listing 7-12. Integrating the Doccomment Parser (DocumentingReflection.php) class DocumentingRefle ...
(^88) CHAPTER 7 ■ REFLECTION API } else { $tags[$tagName] = $data; } } $returnData['comments'] = $comments; $returnData['tags'] ...
CHAPTER 7 ■ REFLECTION API^89 public function printDocTokens() { foreach($this->_tokens as $token) { echo $token[0]. '='; ech ...
(^90) CHAPTER 7 ■ REFLECTION API } $reflector = new DocumentingReflectionMethod('demo', 'demoMethod'); $reflector->printDocTo ...
CHAPTER 7 ■ REFLECTION API^91 Next, you need to create an extension class for ReflectionParameter. Since there is no doccomment ...
(^92) CHAPTER 7 ■ REFLECTION API public function getDeclaringFunction() { return $this->_reflectionMethod; } public function ...
CHAPTER 7 ■ REFLECTION API^93 Listing 7-16. Experimenting with DocumentingReflection (Experiment.php) require_once('DocumentingR ...
(^94) CHAPTER 7 ■ REFLECTION API foreach(parent::getParameters() as $parameter) { $parameters[] = new DocumentingReflectionParam ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf