@@ -136,15 +136,13 @@ |
||
| 136 | 136 | if(isset($aMethodAttrs['protected'])) |
| 137 | 137 | { |
| 138 | 138 | $aProtected[] = $sMethod; // The method is not to be exported. |
| 139 | - } |
|
| 140 | - elseif(count($aMethodAttrs) > 0) |
|
| 139 | + } elseif(count($aMethodAttrs) > 0) |
|
| 141 | 140 | { |
| 142 | 141 | $aAttributes[$sMethod] = $aMethodAttrs; |
| 143 | 142 | } |
| 144 | 143 | } |
| 145 | 144 | return [false, $aAttributes, $aProtected]; |
| 146 | - } |
|
| 147 | - catch(AnnotationException $e) |
|
| 145 | + } catch(AnnotationException $e) |
|
| 148 | 146 | { |
| 149 | 147 | throw new SetupException($e->getMessage()); |
| 150 | 148 | } |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | }); |
| 106 | 106 | |
| 107 | 107 | $aAttributes = []; |
| 108 | - foreach($aAnnotations as $xAnnotation) |
|
| 108 | + foreach ($aAnnotations as $xAnnotation) |
|
| 109 | 109 | { |
| 110 | 110 | $xAnnotation->setReader($this); |
| 111 | 111 | $sName = $xAnnotation->getName(); |
| 112 | 112 | $xAnnotation->setPrevValue($aAttributes[$sName] ?? null); |
| 113 | 113 | $xValue = $xAnnotation->getValue(); |
| 114 | - if($sName === 'protected' && !$xValue) |
|
| 114 | + if ($sName === 'protected' && !$xValue) |
|
| 115 | 115 | { |
| 116 | 116 | // Ignore annotation @exclude with value false |
| 117 | 117 | continue; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // Only keep the annotations declared in this package. |
| 159 | 159 | $aAnnotations = array_filter($aAnnotations, function($xAnnotation) use($sProperty) { |
| 160 | 160 | // Save the property type |
| 161 | - if(is_a($xAnnotation, VarAnnotation::class)) |
|
| 161 | + if (is_a($xAnnotation, VarAnnotation::class)) |
|
| 162 | 162 | { |
| 163 | 163 | $this->aPropTypes[$sProperty] = $xAnnotation->type; |
| 164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | }); |
| 168 | 168 | |
| 169 | 169 | $aAttributes = []; |
| 170 | - foreach($aAnnotations as $xAnnotation) |
|
| 170 | + foreach ($aAnnotations as $xAnnotation) |
|
| 171 | 171 | { |
| 172 | 172 | $xAnnotation->setReader($this); |
| 173 | 173 | $xAnnotation->setAttr($sProperty); |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | $this->aPropTypes = []; |
| 199 | 199 | $aPropAttrs = []; |
| 200 | 200 | // Properties annotations |
| 201 | - foreach($aProperties as $sProperty) |
|
| 201 | + foreach ($aProperties as $sProperty) |
|
| 202 | 202 | { |
| 203 | 203 | $aPropertyAttrs = $this->getPropertyAttrs($sClass, $sProperty); |
| 204 | - foreach($aPropertyAttrs as $sName => $xValue) |
|
| 204 | + foreach ($aPropertyAttrs as $sName => $xValue) |
|
| 205 | 205 | { |
| 206 | 206 | $aPropAttrs[$sName] = array_merge($aPropAttrs[$sName] ?? [], $xValue); |
| 207 | 207 | } |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS; |
| 212 | 212 | |
| 213 | 213 | $aClassAttrs = $this->getClassAttrs($sClass); |
| 214 | - if(isset($aClassAttrs['protected'])) |
|
| 214 | + if (isset($aClassAttrs['protected'])) |
|
| 215 | 215 | { |
| 216 | 216 | return [true, [], []]; // The entire class is not to be exported. |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Merge attributes and class annotations |
| 220 | - foreach($aPropAttrs as $sName => $xValue) |
|
| 220 | + foreach ($aPropAttrs as $sName => $xValue) |
|
| 221 | 221 | { |
| 222 | 222 | $aClassAttrs[$sName] = array_merge($aClassAttrs[$sName] ?? [], $xValue); |
| 223 | 223 | } |
@@ -227,21 +227,21 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $aAttributes = count($aClassAttrs) > 0 ? ['*' => $aClassAttrs] : []; |
| 229 | 229 | $aProtected = []; |
| 230 | - foreach($aMethods as $sMethod) |
|
| 230 | + foreach ($aMethods as $sMethod) |
|
| 231 | 231 | { |
| 232 | 232 | $aMethodAttrs = $this->getMethodAttrs($sClass, $sMethod); |
| 233 | - if(isset($aMethodAttrs['protected'])) |
|
| 233 | + if (isset($aMethodAttrs['protected'])) |
|
| 234 | 234 | { |
| 235 | 235 | $aProtected[] = $sMethod; // The method is not to be exported. |
| 236 | 236 | } |
| 237 | - elseif(count($aMethodAttrs) > 0) |
|
| 237 | + elseif (count($aMethodAttrs) > 0) |
|
| 238 | 238 | { |
| 239 | 239 | $aAttributes[$sMethod] = $aMethodAttrs; |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | return [false, $aAttributes, $aProtected]; |
| 243 | 243 | } |
| 244 | - catch(AnnotationException $e) |
|
| 244 | + catch (AnnotationException $e) |
|
| 245 | 245 | { |
| 246 | 246 | throw new SetupException($e->getMessage()); |
| 247 | 247 | } |
@@ -197,14 +197,14 @@ |
||
| 197 | 197 | $nCount = count($this->properties); |
| 198 | 198 | switch($nCount) |
| 199 | 199 | { |
| 200 | - case 0: |
|
| 201 | - return true; |
|
| 202 | - case 1: |
|
| 203 | - return isset($this->properties['attr']) || isset($this->properties['class']); |
|
| 204 | - case 2: |
|
| 205 | - return isset($this->properties['attr']) && isset($this->properties['class']); |
|
| 206 | - default: |
|
| 207 | - return false; |
|
| 200 | + case 0: |
|
| 201 | + return true; |
|
| 202 | + case 1: |
|
| 203 | + return isset($this->properties['attr']) || isset($this->properties['class']); |
|
| 204 | + case 2: |
|
| 205 | + return isset($this->properties['attr']) && isset($this->properties['class']); |
|
| 206 | + default: |
|
| 207 | + return false; |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function getFullClassName(string $sClassName): string |
| 136 | 136 | { |
| 137 | - return ltrim($this->xClassFile->resolveType($sClassName), '\\');; |
|
| 137 | + return ltrim($this->xClassFile->resolveType($sClassName), '\\'); ; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -146,38 +146,38 @@ discard block |
||
| 146 | 146 | $value = $this->properties['__value__']; |
| 147 | 147 | $aParams = preg_split('/[\s]+/', $value, 3); |
| 148 | 148 | $nParamCount = count($aParams); |
| 149 | - if($nParamCount === 1) |
|
| 149 | + if ($nParamCount === 1) |
|
| 150 | 150 | { |
| 151 | 151 | // For a property, the only parameter is the class. Otherwise, it is the attribute. |
| 152 | - if($this->xReader->annotationIsOnProperty()) |
|
| 152 | + if ($this->xReader->annotationIsOnProperty()) |
|
| 153 | 153 | { |
| 154 | - if(substr($aParams[0], 0, 1) === '$') |
|
| 154 | + if (substr($aParams[0], 0, 1) === '$') |
|
| 155 | 155 | { |
| 156 | 156 | throw new AnnotationException('The only property of the @di annotation must be a class name'); |
| 157 | 157 | } |
| 158 | 158 | $this->sClass = $this->getFullClassName($aParams[0]); |
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 161 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 162 | 162 | { |
| 163 | 163 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 164 | 164 | } |
| 165 | 165 | $this->sAttr = substr($aParams[0], 1); |
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | - if($nParamCount === 2) |
|
| 168 | + if ($nParamCount === 2) |
|
| 169 | 169 | { |
| 170 | 170 | // For a property, having 2 parameters is not allowed. |
| 171 | - if($this->xReader->annotationIsOnProperty()) |
|
| 171 | + if ($this->xReader->annotationIsOnProperty()) |
|
| 172 | 172 | { |
| 173 | 173 | throw new AnnotationException('The @di annotation accepts only one property on a class attribute'); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 176 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 177 | 177 | { |
| 178 | 178 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 179 | 179 | } |
| 180 | - if(substr($aParams[1], 0, 1) === '$') |
|
| 180 | + if (substr($aParams[1], 0, 1) === '$') |
|
| 181 | 181 | { |
| 182 | 182 | throw new AnnotationException('The first property of the @di annotation must be a class name'); |
| 183 | 183 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | private function checkPropertiesNames(): bool |
| 196 | 196 | { |
| 197 | 197 | $nCount = count($this->properties); |
| 198 | - switch($nCount) |
|
| 198 | + switch ($nCount) |
|
| 199 | 199 | { |
| 200 | 200 | case 0: |
| 201 | 201 | return true; |
@@ -214,26 +214,26 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | private function parseProperties() |
| 216 | 216 | { |
| 217 | - if(!$this->checkPropertiesNames()) |
|
| 217 | + if (!$this->checkPropertiesNames()) |
|
| 218 | 218 | { |
| 219 | 219 | throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties'); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if(isset($this->properties['attr'])) |
|
| 222 | + if (isset($this->properties['attr'])) |
|
| 223 | 223 | { |
| 224 | - if($this->xReader->annotationIsOnProperty()) |
|
| 224 | + if ($this->xReader->annotationIsOnProperty()) |
|
| 225 | 225 | { |
| 226 | 226 | throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes'); |
| 227 | 227 | } |
| 228 | - if(!is_string($this->properties['attr'])) |
|
| 228 | + if (!is_string($this->properties['attr'])) |
|
| 229 | 229 | { |
| 230 | 230 | throw new AnnotationException('The @di annotation requires a property "attr" of type string'); |
| 231 | 231 | } |
| 232 | 232 | $this->sAttr = $this->properties['attr']; |
| 233 | 233 | } |
| 234 | - if(isset($this->properties['class'])) |
|
| 234 | + if (isset($this->properties['class'])) |
|
| 235 | 235 | { |
| 236 | - if(!is_string($this->properties['class'])) |
|
| 236 | + if (!is_string($this->properties['class'])) |
|
| 237 | 237 | { |
| 238 | 238 | throw new AnnotationException('The @di annotation requires a property "class" of type string'); |
| 239 | 239 | } |
@@ -251,25 +251,25 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | // The type in the @di annotations can be set from the values in the @var annotations |
| 253 | 253 | $aPropTypes = $this->xReader->getPropTypes(); |
| 254 | - if($this->sClass === '' && isset($aPropTypes[$this->sAttr])) |
|
| 254 | + if ($this->sClass === '' && isset($aPropTypes[$this->sAttr])) |
|
| 255 | 255 | { |
| 256 | 256 | $this->sClass = ltrim($aPropTypes[$this->sAttr], '\\'); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null) |
|
| 259 | + if ($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null) |
|
| 260 | 260 | { |
| 261 | 261 | throw new AnnotationException('Only one @di annotation is allowed on a property'); |
| 262 | 262 | } |
| 263 | - if(!$this->validateAttrName($this->sAttr)) |
|
| 263 | + if (!$this->validateAttrName($this->sAttr)) |
|
| 264 | 264 | { |
| 265 | 265 | throw new AnnotationException($this->sAttr . ' is not a valid "attr" value for the @di annotation'); |
| 266 | 266 | } |
| 267 | - if(!$this->validateClassName($this->sClass)) |
|
| 267 | + if (!$this->validateClassName($this->sClass)) |
|
| 268 | 268 | { |
| 269 | 269 | throw new AnnotationException($this->sClass . ' is not a valid "class" value for the @di annotation'); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if(is_array($this->xPrevValue)) |
|
| 272 | + if (is_array($this->xPrevValue)) |
|
| 273 | 273 | { |
| 274 | 274 | $this->xPrevValue[$this->sAttr] = $this->sClass; // Append the current value to the array |
| 275 | 275 | return $this->xPrevValue; |
@@ -62,11 +62,11 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | public function initAnnotation(array $properties) |
| 64 | 64 | { |
| 65 | - if(count($properties) !== 1 || !is_string($properties['name'])) |
|
| 65 | + if (count($properties) !== 1 || !is_string($properties['name'])) |
|
| 66 | 66 | { |
| 67 | 67 | throw new AnnotationException('the @callback annotation requires a single string as property'); |
| 68 | 68 | } |
| 69 | - if(!$this->validateObjectName($properties['name'])) |
|
| 69 | + if (!$this->validateObjectName($properties['name'])) |
|
| 70 | 70 | { |
| 71 | 71 | throw new AnnotationException($properties['name'] . ' is not a valid "name" value for the @callback annotation'); |
| 72 | 72 | } |