@@ -122,38 +122,38 @@ discard block |
||
| 122 | 122 | $value = $this->properties['__value__']; |
| 123 | 123 | $aParams = preg_split('/[\s]+/', $value, 3); |
| 124 | 124 | $nParamCount = count($aParams); |
| 125 | - if($nParamCount === 1) |
|
| 125 | + if ($nParamCount === 1) |
|
| 126 | 126 | { |
| 127 | 127 | // For a property, the only parameter is the class. Otherwise, it is the attribute. |
| 128 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 128 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 129 | 129 | { |
| 130 | - if(substr($aParams[0], 0, 1) === '$') |
|
| 130 | + if (substr($aParams[0], 0, 1) === '$') |
|
| 131 | 131 | { |
| 132 | 132 | throw new AnnotationException('The only property of the @di annotation must be a class name'); |
| 133 | 133 | } |
| 134 | 134 | $this->sClass = $this->getFullClassName($aParams[0]); |
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 137 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 138 | 138 | { |
| 139 | 139 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 140 | 140 | } |
| 141 | 141 | $this->sAttr = substr($aParams[0], 1); |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | - if($nParamCount === 2) |
|
| 144 | + if ($nParamCount === 2) |
|
| 145 | 145 | { |
| 146 | 146 | // For a property, having 2 parameters is not allowed. |
| 147 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 147 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 148 | 148 | { |
| 149 | 149 | throw new AnnotationException('The @di annotation accepts only one property on a class attribute'); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if(substr($aParams[0], 0, 1) !== '$') |
|
| 152 | + if (substr($aParams[0], 0, 1) !== '$') |
|
| 153 | 153 | { |
| 154 | 154 | throw new AnnotationException('The only property of the @di annotation must be a var name'); |
| 155 | 155 | } |
| 156 | - if(substr($aParams[1], 0, 1) === '$') |
|
| 156 | + if (substr($aParams[1], 0, 1) === '$') |
|
| 157 | 157 | { |
| 158 | 158 | throw new AnnotationException('The first property of the @di annotation must be a class name'); |
| 159 | 159 | } |
@@ -185,26 +185,26 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | private function parseProperties() |
| 187 | 187 | { |
| 188 | - if(!$this->checkPropertiesNames()) |
|
| 188 | + if (!$this->checkPropertiesNames()) |
|
| 189 | 189 | { |
| 190 | 190 | throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties'); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if(isset($this->properties['attr'])) |
|
| 193 | + if (isset($this->properties['attr'])) |
|
| 194 | 194 | { |
| 195 | - if(self::$xReader->annotationIsOnProperty()) |
|
| 195 | + if (self::$xReader->annotationIsOnProperty()) |
|
| 196 | 196 | { |
| 197 | 197 | throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes'); |
| 198 | 198 | } |
| 199 | - if(!is_string($this->properties['attr'])) |
|
| 199 | + if (!is_string($this->properties['attr'])) |
|
| 200 | 200 | { |
| 201 | 201 | throw new AnnotationException('The @di annotation requires a property "attr" of type string'); |
| 202 | 202 | } |
| 203 | 203 | $this->sAttr = $this->properties['attr']; |
| 204 | 204 | } |
| 205 | - if(isset($this->properties['class'])) |
|
| 205 | + if (isset($this->properties['class'])) |
|
| 206 | 206 | { |
| 207 | - if(!is_string($this->properties['class'])) |
|
| 207 | + if (!is_string($this->properties['class'])) |
|
| 208 | 208 | { |
| 209 | 209 | throw new AnnotationException('The @di annotation requires a property "class" of type string'); |
| 210 | 210 | } |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | // The type in the @di annotations can be set from the values in the @var annotations |
| 223 | 223 | $aPropTypes = self::$xReader->getPropTypes(); |
| 224 | - if($this->sClass === '') |
|
| 224 | + if ($this->sClass === '') |
|
| 225 | 225 | { |
| 226 | - if(!isset($aPropTypes[$this->sAttr])) |
|
| 226 | + if (!isset($aPropTypes[$this->sAttr])) |
|
| 227 | 227 | { |
| 228 | 228 | throw new AnnotationException('No class defined for @di on attribute "' . |
| 229 | 229 | $this->sAttr . '".'); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function initAnnotation(array $properties) |
| 52 | 52 | { |
| 53 | - if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 53 | + if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name'])) |
|
| 54 | 54 | { |
| 55 | 55 | throw new AnnotationException('the @callback annotation requires a single string as property'); |
| 56 | 56 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function initAnnotation(array $properties) |
| 48 | 48 | { |
| 49 | - if(count($properties) !== 0 && (count($properties) !== 1 |
|
| 49 | + if (count($properties) !== 0 && (count($properties) !== 1 |
|
| 50 | 50 | || !isset($properties[0]) || !is_bool($properties[0]))) |
| 51 | 51 | { |
| 52 | 52 | throw new AnnotationException('the @exclude annotation requires a single boolean or no property'); |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | public static function parseAnnotation($value) |
| 42 | 42 | { |
| 43 | 43 | $aParams = preg_split('/[\s]+/', $value, 2); |
| 44 | - return count($aParams) === 1 ? ['field' => $aParams[0]] : |
|
| 45 | - ['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 44 | + return count($aParams) === 1 ? ['field' => $aParams[0]] : ['field' => $aParams[0], 'extra' => $aParams[1]]; |
|
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | /** |
@@ -51,7 +50,7 @@ discard block |
||
| 51 | 50 | */ |
| 52 | 51 | public function initAnnotation(array $properties) |
| 53 | 52 | { |
| 54 | - if(count($properties) != 1 || !isset($properties['field']) || |
|
| 53 | + if (count($properties) != 1 || !isset($properties['field']) || |
|
| 55 | 54 | !is_string($properties['field'])) |
| 56 | 55 | { |
| 57 | 56 | throw new AnnotationException('The @upload annotation requires a property "field" of type string'); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public static function parseAnnotation($value) |
| 49 | 49 | { |
| 50 | 50 | $aParams = preg_split('/[\s]+/', $value, 2); |
| 51 | - if(count($aParams) === 1) |
|
| 51 | + if (count($aParams) === 1) |
|
| 52 | 52 | { |
| 53 | 53 | return ['call' => rtrim($aParams[0])]; |
| 54 | 54 | } |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function initAnnotation(array $properties) |
| 64 | 64 | { |
| 65 | - if(!isset($properties['call']) || !is_string($properties['call'])) |
|
| 65 | + if (!isset($properties['call']) || !is_string($properties['call'])) |
|
| 66 | 66 | { |
| 67 | 67 | throw new AnnotationException('The @' . $this->getType() . |
| 68 | 68 | ' annotation requires a property "call" of type string'); |
| 69 | 69 | } |
| 70 | - foreach(array_keys($properties) as $propName) |
|
| 70 | + foreach (array_keys($properties) as $propName) |
|
| 71 | 71 | { |
| 72 | - if($propName !== 'call' && $propName !== 'with') |
|
| 72 | + if ($propName !== 'call' && $propName !== 'with') |
|
| 73 | 73 | { |
| 74 | 74 | throw new AnnotationException('Unknown property "' . $propName . |
| 75 | 75 | '" in the @' . $this->getType() . ' annotation'); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | // Cannot use isset here, because it will return false in case $properties['with'] === null |
| 79 | - if(array_key_exists('with', $properties)) |
|
| 79 | + if (array_key_exists('with', $properties)) |
|
| 80 | 80 | { |
| 81 | - if(!is_array($properties['with'])) |
|
| 81 | + if (!is_array($properties['with'])) |
|
| 82 | 82 | { |
| 83 | 83 | throw new AnnotationException('The "with" property of the @' . |
| 84 | 84 | $this->getType() . ' annotation must be of type array'); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $jaxon = jaxon(); |
| 26 | 26 | $di = $jaxon->di(); |
| 27 | - if($di->h(UploadHandler::class)) |
|
| 27 | + if ($di->h(UploadHandler::class)) |
|
| 28 | 28 | { |
| 29 | 29 | return; |
| 30 | 30 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $xUploadHandler = $di->g(UploadHandler::class); |
| 77 | 77 | // The HTTP request |
| 78 | 78 | $xRequest = $di->getRequest(); |
| 79 | - if($xUploadHandler->canProcessRequest($xRequest)) |
|
| 79 | + if ($xUploadHandler->canProcessRequest($xRequest)) |
|
| 80 | 80 | { |
| 81 | 81 | $xUploadHandler->processRequest($xRequest); |
| 82 | 82 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $jaxon = jaxon(); |
| 94 | 94 | $jaxon->callback()->boot(function() use($jaxon) { |
| 95 | - if($jaxon->getOption('core.upload.enabled')) |
|
| 95 | + if ($jaxon->getOption('core.upload.enabled')) |
|
| 96 | 96 | { |
| 97 | 97 | registerUpload(); |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | function register() |
| 103 | 103 | { |
| 104 | 104 | // Do nothing if running in cli. |
| 105 | - if(php_sapi_name() !== 'cli') |
|
| 105 | + if (php_sapi_name() !== 'cli') |
|
| 106 | 106 | { |
| 107 | 107 | _register(); |
| 108 | 108 | }; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | {
|
| 98 | 98 | $xDefault = $this->xConfigManager->getOption('upload.default.' . $sProperty);
|
| 99 | 99 | $aAllowed = $this->xConfigManager->getOption('upload.files.' . $sVarName . '.' . $sProperty, $xDefault);
|
| 100 | - if(is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
| 100 | + if (is_array($aAllowed) && !in_array($sValue, $aAllowed)) |
|
| 101 | 101 | {
|
| 102 | 102 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.' . $sField, [$sField => $sValue]);
|
| 103 | 103 | return false; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | {
|
| 119 | 119 | $xDefault = $this->xConfigManager->getOption('upload.default.' . $sProperty, 0);
|
| 120 | 120 | $nSize = $this->xConfigManager->getOption('upload.files.' . $sVarName . '.' . $sProperty, $xDefault);
|
| 121 | - if($nSize > 0 && ( |
|
| 121 | + if ($nSize > 0 && ( |
|
| 122 | 122 | ($sProperty == 'max-size' && $nFileSize > $nSize) || |
| 123 | 123 | ($sProperty == 'min-size' && $nFileSize < $nSize))) |
| 124 | 124 | {
|
@@ -140,25 +140,25 @@ discard block |
||
| 140 | 140 | {
|
| 141 | 141 | $this->sErrorMessage = ''; |
| 142 | 142 | // Verify the file extension |
| 143 | - if(!$this->validateFileProperty($sVarName, $xFile->type(), 'types', 'type')) |
|
| 143 | + if (!$this->validateFileProperty($sVarName, $xFile->type(), 'types', 'type')) |
|
| 144 | 144 | {
|
| 145 | 145 | return false; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Verify the file extension |
| 149 | - if(!$this->validateFileProperty($sVarName, $xFile->extension(), 'extensions', 'extension')) |
|
| 149 | + if (!$this->validateFileProperty($sVarName, $xFile->extension(), 'extensions', 'extension')) |
|
| 150 | 150 | {
|
| 151 | 151 | return false; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Verify the max size |
| 155 | - if(!$this->validateFileSize($sVarName, $xFile->size(), 'max-size')) |
|
| 155 | + if (!$this->validateFileSize($sVarName, $xFile->size(), 'max-size')) |
|
| 156 | 156 | {
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Verify the min size |
| 161 | - if(!$this->validateFileSize($sVarName, $xFile->size(), 'min-size')) |
|
| 161 | + if (!$this->validateFileSize($sVarName, $xFile->size(), 'min-size')) |
|
| 162 | 162 | {
|
| 163 | 163 | return false; |
| 164 | 164 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | protected function validateName(string $sName): void |
| 52 | 52 | { |
| 53 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0) |
|
| 53 | + if (preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $sName) > 0) |
|
| 54 | 54 | { |
| 55 | 55 | return; |
| 56 | 56 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $aFiles = scandir($this->sCacheDir); |
| 46 | 46 | foreach ($aFiles as $sFile) |
| 47 | 47 | { |
| 48 | - if($sFile !== '.' && $sFile !== '..') |
|
| 48 | + if ($sFile !== '.' && $sFile !== '..') |
|
| 49 | 49 | { |
| 50 | 50 | @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
| 51 | 51 | } |