| 96 | | $params = substr($annotation, $annoLength); |
|---|
| 97 | | |
|---|
| 98 | | // check, whether annotation needs casting |
|---|
| 99 | | if ($params{0} === '[') { |
|---|
| 100 | | $end = strpos($params, ']'); |
|---|
| 101 | | if (false == $end) { |
|---|
| 102 | | throw new ReflectionException('Could not parse annotation'); |
|---|
| 103 | | } |
|---|
| 104 | | $annotationClass = substr($params, 1, $end-1); |
|---|
| 105 | | $params = substr($params, $end+1); |
|---|
| 106 | | } else { |
|---|
| 107 | | $annotationClass = $annotationName; |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | |
|---|
| 111 | | // check for empty annotation |
|---|
| 112 | | $params = trim(str_replace('*', '', $params)); |
|---|
| 113 | | if ($params{0} === '(') { |
|---|
| 114 | | $params = substr($params, 1, strlen($params)-2); |
|---|
| 115 | | } |
|---|
| 116 | | if ($params === '') { |
|---|
| 117 | | return array($annotationClass, array()); |
|---|
| 118 | | } |
|---|
| 119 | | |
|---|
| 120 | | $tmpParams = explode(',', $params); |
|---|
| 121 | | if (count($tmpParams) === 1 && false === strchr($tmpParams[0], '=')) { |
|---|
| 122 | | return array($annotationClass, array('value' => trim($tmpParams[0]))); |
|---|
| 123 | | } |
|---|
| 124 | | |
|---|
| 125 | | $params = array(); |
|---|
| 126 | | foreach ($tmpParams as $param) { |
|---|
| 127 | | $param = trim($param); |
|---|
| 128 | | if (false === strchr($param, '=')) { |
|---|
| 129 | | throw new ReflectionException('Unable to parse the annotation.'); |
|---|
| 130 | | } |
|---|
| 131 | | $tmp = explode('=', $param); |
|---|
| 132 | | if (count($tmp) != 2) { |
|---|
| 133 | | throw new ReflectionException('Unable to parse the annotation.'); |
|---|
| 134 | | } |
|---|
| 135 | | list($paramName,$paramValue) = $tmp; |
|---|
| 136 | | $params[trim($paramName)] = trim($paramValue); |
|---|
| 137 | | } |
|---|
| 138 | | return array($annotationClass, $params); |
|---|
| | 96 | $params = substr($annotation, $annoLength); |
|---|
| | 97 | |
|---|
| | 98 | // check, whether annotation needs casting |
|---|
| | 99 | if ($params{0} === '[') { |
|---|
| | 100 | $end = strpos($params, ']'); |
|---|
| | 101 | if (false == $end) { |
|---|
| | 102 | throw new ReflectionException('Could not parse annotation'); |
|---|
| | 103 | } |
|---|
| | 104 | |
|---|
| | 105 | $annotationClass = substr($params, 1, $end-1); |
|---|
| | 106 | $params = substr($params, $end+1); |
|---|
| | 107 | } else { |
|---|
| | 108 | $annotationClass = $annotationName; |
|---|
| | 109 | } |
|---|
| | 110 | |
|---|
| | 111 | // check for empty annotation |
|---|
| | 112 | $params = trim(str_replace('*', '', $params)); |
|---|
| | 113 | if ('' === $params) { |
|---|
| | 114 | return array($annotationClass, array()); |
|---|
| | 115 | } |
|---|
| | 116 | |
|---|
| | 117 | if ('(' === $params{0}) { |
|---|
| | 118 | $params = substr($params, 1, strlen($params) - 2); |
|---|
| | 119 | } |
|---|
| | 120 | |
|---|
| | 121 | $tmpParams = explode(',', $params); |
|---|
| | 122 | if (count($tmpParams) === 1 && false === strchr($tmpParams[0], '=')) { |
|---|
| | 123 | return array($annotationClass, array('value' => trim($tmpParams[0]))); |
|---|
| | 124 | } |
|---|
| | 125 | |
|---|
| | 126 | $params = array(); |
|---|
| | 127 | foreach ($tmpParams as $param) { |
|---|
| | 128 | $param = trim($param); |
|---|
| | 129 | if (false === strchr($param, '=')) { |
|---|
| | 130 | throw new ReflectionException('Unable to parse the annotation.'); |
|---|
| | 131 | } |
|---|
| | 132 | |
|---|
| | 133 | $tmp = explode('=', $param); |
|---|
| | 134 | if (count($tmp) != 2) { |
|---|
| | 135 | throw new ReflectionException('Unable to parse the annotation.'); |
|---|
| | 136 | } |
|---|
| | 137 | |
|---|
| | 138 | list($paramName,$paramValue) = $tmp; |
|---|
| | 139 | $params[trim($paramName)] = trim($paramValue); |
|---|
| | 140 | } |
|---|
| | 141 | |
|---|
| | 142 | return array($annotationClass, $params); |
|---|