| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 require_once (AK_LIB_DIR.DS.'AkReflection.php'); 3 require_once (AK_LIB_DIR.DS.'AkReflection'.DS.'AkReflectionMethod.php'); 4 require_once (AK_LIB_DIR.DS.'AkReflection'.DS.'AkReflectionDocBlock.php'); 5 class AkReflectionClass extends AkReflection 6 { 7 var $_definition; 8 var $_docBlock; 9 var $methods = array(); 10 var $properties = array(); 11 12 13 14 function AkReflectionClass($class_definition) 15 { 16 if (is_array($class_definition)) { 17 if (@$class_definition['type'] == 'class') { 18 $this->_definition = $class_definition; 19 } else { 20 return; 21 } 22 } else if (is_string($class_definition)) { 23 $this->_parse($class_definition); 24 foreach ($this->definitions as $def) { 25 if ($def['type'] == 'class') { 26 $this->_definition = $def; 27 break; 28 } 29 } 30 $this->definitions = array(); 31 $this->tokens = array(); 32 } else { 33 return; 34 } 35 $this->_docBlock = &new AkReflectionDocBlock($this->_definition['docBlock']); 36 $this->_parse($this->_definition['code']); 37 $this->_parseDefinitions(); 38 39 } 40 function toString() 41 { 42 $docBlock = $this->_docBlock; 43 if ($docBlock->changed) { 44 $string = $this->_definition['toString']; 45 $orgDocBlock = $docBlock->original; 46 $string = str_replace($orgDocBlock,$docBlock->toString(),$string); 47 return $string; 48 } else { 49 return isset($this->_definition['toString'])?$this->_definition['toString']:null; 50 } 51 } 52 function setTag($tag,$value) 53 { 54 $this->_docBlock->setTag($tag,$value); 55 } 56 function getTag($tag) 57 { 58 return $this->_docBlock->getTag($tag); 59 } 60 function getName() 61 { 62 return isset($this->_definition['name'])?$this->_definition['name']:false; 63 } 64 function getVisibility() 65 { 66 return isset($this->_definition['visibility'])?$this->_definition['visibility']:false; 67 } 68 69 function isStatic() 70 { 71 return isset($this->_definition['static'])?$this->_definition['static']:false; 72 } 73 function &getDocBlock() 74 { 75 return $this->_docBlock; 76 } 77 function _parseDefinitions() 78 { 79 foreach($this->definitions as $definition) { 80 switch ($definition['type']) { 81 case 'function': 82 $this->methods[] = new AkReflectionMethod($definition); 83 break; 84 } 85 } 86 } 87 function &getMethod($name) 88 { 89 $false = false; 90 foreach($this->methods as $method) { 91 if ($method->getName()==$name) return $method; 92 } 93 return $false; 94 } 95 function getMethods($options = null) 96 { 97 if ($options == null) { 98 return $this->methods; 99 } else if (is_array($options)) { 100 $default_options = array(); 101 $available_options = array('visibility','static','tags','returnByReference'); 102 $parameters = array('available_options'=>$available_options); 103 Ak::parseOptions(&$options,$default_options,$parameters); 104 $returnMethods = array(); 105 foreach ($this->methods as $method) { 106 if (isset($options['visibility']) && $method->getVisibility()!=$options['visibility']) { 107 continue; 108 } 109 if (isset($options['returnByReference']) && $method->returnByReference()!=$options['returnByReference']) { 110 continue; 111 } 112 if (isset($options['static']) && $method->isStatic()!=$options['static']) { 113 continue; 114 } 115 if (isset($options['tags'])) { 116 $options['tags']=!is_array($options['tags'])?array($options['tags']):$options['tags']; 117 $docBlock = $method->getDocBlock(); 118 $broke = false; 119 foreach($options['tags'] as $tag=>$value) { 120 $res = $docBlock->getTag($tag); 121 122 if (!@preg_match('/'.$value.'/',$res) || ($value!==false && $res===false)) { 123 $broke = true; 124 break; 125 } 126 } 127 if ($broke) { 128 continue; 129 } 130 } 131 $returnMethods[] = $method; 132 133 } 134 //echo "Return methods:\n"; 135 //var_dump($returnMethods); 136 return $returnMethods; 137 } 138 139 } 140 } 141 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |