@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected function _validate() |
| 31 | 31 | { |
| 32 | - if(in_array($this->value, $this->getArrayOption('values'))) { |
|
| 32 | + if (in_array($this->value, $this->getArrayOption('values'))) { |
|
| 33 | 33 | return $this->value; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | str_replace(' ', '-', $this->type) |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - if($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
| 43 | + if ($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
| 44 | 44 | { |
| 45 | 45 | $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$this->info->getType().'</span> '; |
| 46 | 46 | $converted = $typeLabel.' '.$converted; |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | protected function detectAttributes() |
| 109 | 109 | { |
| 110 | - if(!$this->options['@attributes']) { |
|
| 110 | + if (!$this->options['@attributes']) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $attributes = $this->subject->attributes(); |
| 115 | 115 | |
| 116 | - if(!empty($attributes)) |
|
| 116 | + if (!empty($attributes)) |
|
| 117 | 117 | { |
| 118 | 118 | $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes)); |
| 119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $children = $this->subject; |
| 125 | 125 | $depth = $this->options['depth'] - 1; |
| 126 | 126 | |
| 127 | - if($depth <= 0) |
|
| 127 | + if ($depth <= 0) |
|
| 128 | 128 | { |
| 129 | 129 | $children = []; |
| 130 | 130 | } |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $decorator->options = ['depth' => $depth] + $this->options; |
| 139 | 139 | |
| 140 | - if(isset($this->result[$name])) |
|
| 140 | + if (isset($this->result[$name])) |
|
| 141 | 141 | { |
| 142 | - if(!is_array($this->result[$name])) |
|
| 142 | + if (!is_array($this->result[$name])) |
|
| 143 | 143 | { |
| 144 | 144 | $this->result[$name] = [$this->result[$name]]; |
| 145 | 145 | } |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | // json encode non-whitespace element simplexml text values. |
| 159 | 159 | $text = trim((string)$this->subject); |
| 160 | 160 | |
| 161 | - if(strlen($text)) |
|
| 161 | + if (strlen($text)) |
|
| 162 | 162 | { |
| 163 | - if($this->options['@text']) |
|
| 163 | + if ($this->options['@text']) |
|
| 164 | 164 | { |
| 165 | 165 | $this->result['@text'] = $text; |
| 166 | 166 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function addLimitParam(string $name) : Request_URLComparer |
| 81 | 81 | { |
| 82 | - if(!in_array($name, $this->limitParams)) { |
|
| 82 | + if (!in_array($name, $this->limitParams)) { |
|
| 83 | 83 | $this->limitParams[] = $name; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function addLimitParams(array $names) : Request_URLComparer |
| 90 | 90 | { |
| 91 | - foreach($names as $name) { |
|
| 91 | + foreach ($names as $name) { |
|
| 92 | 92 | $this->addLimitParam($name); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
| 98 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
| 99 | 99 | { |
| 100 | 100 | $this->ignoreFragment = $ignore; |
| 101 | 101 | return $this; |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | 'query' |
| 122 | 122 | ); |
| 123 | 123 | |
| 124 | - if(!$this->ignoreFragment) { |
|
| 124 | + if (!$this->ignoreFragment) { |
|
| 125 | 125 | $keys[] = 'fragment'; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - foreach($keys as $key) |
|
| 128 | + foreach ($keys as $key) |
|
| 129 | 129 | { |
| 130 | - if(!$this->compareKey($key)) { |
|
| 130 | + if (!$this->compareKey($key)) { |
|
| 131 | 131 | return false; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $filter = 'filter_'.$key; |
| 144 | 144 | |
| 145 | - if(method_exists($this, $filter)) |
|
| 145 | + if (method_exists($this, $filter)) |
|
| 146 | 146 | { |
| 147 | 147 | $sVal = $this->$filter($sVal); |
| 148 | 148 | $tVal = $this->$filter($tVal); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function filter_path(string $path) : string |
| 155 | 155 | { |
| 156 | 156 | // fix double slashes in URLs |
| 157 | - while(stristr($path, '//')) { |
|
| 157 | + while (stristr($path, '//')) { |
|
| 158 | 158 | $path = str_replace('//', '/', $path); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | protected function filter_query(string $query) : string |
| 165 | 165 | { |
| 166 | - if(empty($query)) { |
|
| 166 | + if (empty($query)) { |
|
| 167 | 167 | return ''; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | protected function limitParams(array $params) : array |
| 180 | 180 | { |
| 181 | - if(empty($this->limitParams)) { |
|
| 181 | + if (empty($this->limitParams)) { |
|
| 182 | 182 | return $params; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $keep = array(); |
| 186 | 186 | |
| 187 | - foreach($this->limitParams as $name) |
|
| 187 | + foreach ($this->limitParams as $name) |
|
| 188 | 188 | { |
| 189 | - if(isset($params[$name])) { |
|
| 189 | + if (isset($params[$name])) { |
|
| 190 | 190 | $keep[$name] = $params[$name]; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -142,7 +142,7 @@ |
||
| 142 | 142 | |
| 143 | 143 | protected function getInfoKey(string $name) : string |
| 144 | 144 | { |
| 145 | - if(isset($this->info[$name])) { |
|
| 145 | + if (isset($this->info[$name])) { |
|
| 146 | 146 | return (string)$this->info[$name]; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected static function init() : void |
| 46 | 46 | { |
| 47 | - if(!empty(self::$sizes)) { |
|
| 47 | + if (!empty(self::$sizes)) { |
|
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | self::addSize('b', 1, 1, t('B'), t('Byte'), t('Bytes')); |
| 64 | 64 | |
| 65 | - if(class_exists('AppLocalize\Localization')) |
|
| 65 | + if (class_exists('AppLocalize\Localization')) |
|
| 66 | 66 | { |
| 67 | 67 | \AppLocalize\Localization::onLocaleChanged(array(self::class, 'handle_localeChanged')); |
| 68 | 68 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $name = strtolower($name); |
| 133 | 133 | |
| 134 | - if(isset(self::$sizes[$name])) { |
|
| 134 | + if (isset(self::$sizes[$name])) { |
|
| 135 | 135 | return self::$sizes[$name]; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $result = array(); |
| 175 | 175 | |
| 176 | - foreach(self::$sizes as $size) |
|
| 176 | + foreach (self::$sizes as $size) |
|
| 177 | 177 | { |
| 178 | - if($size->getBase() === $base) { |
|
| 178 | + if ($size->getBase() === $base) { |
|
| 179 | 179 | $result[] = $size; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param bool $enable |
| 58 | 58 | * @return ConvertHelper_TabsNormalizer |
| 59 | 59 | */ |
| 60 | - public function convertTabsToSpaces(bool $enable=true) : ConvertHelper_TabsNormalizer |
|
| 60 | + public function convertTabsToSpaces(bool $enable = true) : ConvertHelper_TabsNormalizer |
|
| 61 | 61 | { |
| 62 | 62 | $this->tabs2spaces = $enable; |
| 63 | 63 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $result = $this->_normalize(); |
| 96 | 96 | |
| 97 | - if($this->tabs2spaces) |
|
| 97 | + if ($this->tabs2spaces) |
|
| 98 | 98 | { |
| 99 | 99 | $result = ConvertHelper::tabs2spaces($result, $this->tabSize); |
| 100 | 100 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $eol = ConvertHelper::detectEOLCharacter($string); |
| 110 | 110 | |
| 111 | - if($eol !== null) |
|
| 111 | + if ($eol !== null) |
|
| 112 | 112 | { |
| 113 | 113 | $this->eol = $eol->getCharacter(); |
| 114 | 114 | } |
@@ -126,15 +126,15 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $converted = array(); |
| 128 | 128 | |
| 129 | - foreach($this->lines as $line) |
|
| 129 | + foreach ($this->lines as $line) |
|
| 130 | 130 | { |
| 131 | 131 | $amount = substr_count($line, "\t") - $this->min; |
| 132 | 132 | |
| 133 | 133 | $line = trim($line, "\n\r\t"); |
| 134 | 134 | |
| 135 | - if($amount >= 1) |
|
| 135 | + if ($amount >= 1) |
|
| 136 | 136 | { |
| 137 | - $line = str_repeat("\t", $amount) . $line; |
|
| 137 | + $line = str_repeat("\t", $amount).$line; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $converted[] = $line; |
@@ -149,23 +149,23 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function countOccurrences() : void |
| 151 | 151 | { |
| 152 | - foreach($this->lines as $line) |
|
| 152 | + foreach ($this->lines as $line) |
|
| 153 | 153 | { |
| 154 | 154 | $amount = substr_count($line, "\t"); |
| 155 | 155 | |
| 156 | - if($amount > $this->max) |
|
| 156 | + if ($amount > $this->max) |
|
| 157 | 157 | { |
| 158 | 158 | $this->max = $amount; |
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if($amount > 0 && $amount < $this->min) |
|
| 162 | + if ($amount > 0 && $amount < $this->min) |
|
| 163 | 163 | { |
| 164 | 164 | $this->min = $amount; |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if($this->min === PHP_INT_MAX) { |
|
| 168 | + if ($this->min === PHP_INT_MAX) { |
|
| 169 | 169 | $this->min = 0; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function selectCharacters(string $type) : ConvertHelper_HiddenConverter |
| 95 | 95 | { |
| 96 | - if(!in_array($type, $this->selected)) { |
|
| 96 | + if (!in_array($type, $this->selected)) { |
|
| 97 | 97 | $this->selected[] = $type; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $selected = $this->selected; |
| 111 | 111 | |
| 112 | - if(empty($this->selected)) |
|
| 112 | + if (empty($this->selected)) |
|
| 113 | 113 | { |
| 114 | 114 | $selected = array( |
| 115 | 115 | self::CHARS_WHITESPACE, |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $result = array(); |
| 121 | 121 | |
| 122 | - foreach($selected as $type) |
|
| 122 | + foreach ($selected as $type) |
|
| 123 | 123 | { |
| 124 | - if(isset($this->characters[$type])) |
|
| 124 | + if (isset($this->characters[$type])) |
|
| 125 | 125 | { |
| 126 | 126 | $result = array_merge($result, $this->characters[$type]); |
| 127 | 127 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * @param array $args |
| 127 | 127 | * @return Request_Param |
| 128 | 128 | */ |
| 129 | - public function setCallback($callback, array $args=array()) : Request_Param |
|
| 129 | + public function setCallback($callback, array $args = array()) : Request_Param |
|
| 130 | 130 | { |
| 131 | - if(!is_callable($callback)) { |
|
| 131 | + if (!is_callable($callback)) { |
|
| 132 | 132 | throw new Request_Exception( |
| 133 | 133 | 'Not a valid callback', |
| 134 | 134 | 'The specified callback is not a valid callable entity.', |
@@ -159,22 +159,22 @@ discard block |
||
| 159 | 159 | // first off, apply filtering |
| 160 | 160 | $value = $this->filter($value); |
| 161 | 161 | |
| 162 | - if($this->valueType === self::VALUE_TYPE_LIST) |
|
| 162 | + if ($this->valueType === self::VALUE_TYPE_LIST) |
|
| 163 | 163 | { |
| 164 | - if(!is_array($value)) |
|
| 164 | + if (!is_array($value)) |
|
| 165 | 165 | { |
| 166 | 166 | $value = explode(',', $value); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $keep = array(); |
| 170 | 170 | |
| 171 | - foreach($value as $subval) |
|
| 171 | + foreach ($value as $subval) |
|
| 172 | 172 | { |
| 173 | 173 | $subval = $this->filter($subval); |
| 174 | 174 | |
| 175 | 175 | $subval = $this->applyValidations($subval, true); |
| 176 | 176 | |
| 177 | - if($subval !== null) { |
|
| 177 | + if ($subval !== null) { |
|
| 178 | 178 | $keep[] = $subval; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | * @param mixed $value |
| 196 | 196 | * @return mixed |
| 197 | 197 | */ |
| 198 | - protected function applyValidations($value, bool $subval=false) |
|
| 198 | + protected function applyValidations($value, bool $subval = false) |
|
| 199 | 199 | { |
| 200 | 200 | // go through all enqueued validations in turn, each time |
| 201 | 201 | // replacing the value with the adjusted, validated value. |
| 202 | - foreach($this->validations as $validateDef) |
|
| 202 | + foreach ($this->validations as $validateDef) |
|
| 203 | 203 | { |
| 204 | 204 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval); |
| 205 | 205 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
| 224 | 224 | |
| 225 | - if(!class_exists($class)) |
|
| 225 | + if (!class_exists($class)) |
|
| 226 | 226 | { |
| 227 | 227 | throw new Request_Exception( |
| 228 | 228 | 'Unknown validation type.', |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | { |
| 377 | 377 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
| 378 | 378 | |
| 379 | - if(is_array($args[0])) |
|
| 379 | + if (is_array($args[0])) |
|
| 380 | 380 | { |
| 381 | 381 | $args = $args[0]; |
| 382 | 382 | } |
@@ -521,10 +521,10 @@ discard block |
||
| 521 | 521 | * @param mixed $default |
| 522 | 522 | * @return mixed |
| 523 | 523 | */ |
| 524 | - public function get($default=null) |
|
| 524 | + public function get($default = null) |
|
| 525 | 525 | { |
| 526 | 526 | $value = $this->request->getParam($this->paramName); |
| 527 | - if($value !== null && $value !== '') { |
|
| 527 | + if ($value !== null && $value !== '') { |
|
| 528 | 528 | return $value; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | { |
| 544 | 544 | $total = count($this->filters); |
| 545 | 545 | for ($i = 0; $i < $total; $i++) { |
| 546 | - $method = 'applyFilter_' . $this->filters[$i]['type']; |
|
| 546 | + $method = 'applyFilter_'.$this->filters[$i]['type']; |
|
| 547 | 547 | $value = $this->$method($value, $this->filters[$i]['params']); |
| 548 | 548 | } |
| 549 | 549 | |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
| 701 | 701 | * @return \AppUtils\Request_Param |
| 702 | 702 | */ |
| 703 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
|
| 703 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param |
|
| 704 | 704 | { |
| 705 | 705 | $this->setArray(); |
| 706 | 706 | |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | ); |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - protected function addClassFilter(string $name, array $params=array()) : Request_Param |
|
| 716 | + protected function addClassFilter(string $name, array $params = array()) : Request_Param |
|
| 717 | 717 | { |
| 718 | 718 | return $this->addFilter( |
| 719 | 719 | self::FILTER_TYPE_CLASS, |