19 extension_loaded(
'Zend Optimizer+') &&
20 (ini_get(
'zend_optimizerplus.save_comments') ===
"0" || ini_get(
'opcache.save_comments') ===
"0"))
22 throw new SystemException(
"You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.");
25 if (extension_loaded(
'Zend OPcache') && ini_get(
'opcache.save_comments') == 0)
27 throw new SystemException(
"You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.");
33 $doc = $method->getDocComment();
35 preg_match_all(
"/@(?=(.*)[ ]*(?:@|\r\n|\n))/U", $doc, $matches);
42 $annotations = array();
43 foreach ($matches[1] as $match)
45 if ($this->collectRules & self::RULE_FIRST_CAPITAL_LETTER)
47 if ($match !== ucfirst($match))
53 $annotations[] = $match;
56 $parameters = array();
57 foreach ($annotations as $annotation)
59 preg_match(
"/(\w+)(?:\((.*)\))?/", $annotation, $matches);
62 $parameters[$matches[1]] = $this->extractParameters($matches[2]);
69 private function extractParameters($string)
76 $parameters = array();
78 $parts = preg_split(
"/(\w+)\=([.^\=]*)/", $string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
80 for ($i = 0; $i < count($parts); $i++)
85 $rawValue = trim($parts[$i + 1],
', ');
87 $parameters[$parts[$i]] = $rawValue;
91 foreach ($parameters as $name => &$rawValue)
93 $rawValue = trim($rawValue);
94 $rawValue = $this->extractParameter($rawValue);
100 private function extractParameter($valueInString)
109 if ($valueInString ===
'false')
113 elseif ($valueInString ===
'true')
117 elseif (is_numeric($valueInString))
119 if ($valueInString === (
string)(
int)$valueInString)
121 $value = (int)$valueInString;
125 $value = (float)$valueInString;
128 elseif (mb_substr($valueInString, 0, 1) ===
'[' && mb_substr($valueInString, -1, 1) ===
']')
131 $valueInString = mb_substr($valueInString, 1, -1);
132 foreach (explode(
',', $valueInString) as $listValue)
134 $listValue = trim($listValue);
140 $list[] = $this->extractParameter($listValue);
147 $value = trim($valueInString,
'"');
getMethodAnnotations(\ReflectionMethod $method)
const RULE_FIRST_CAPITAL_LETTER