@@ -24,7 +24,7 @@ discard block  | 
                                                    ||
| 24 | 24 | /**  | 
                                                        
| 25 | 25 | * Section constructor.  | 
                                                        
| 26 | 26 | *  | 
                                                        
| 27 | - * @param $name  | 
                                                        |
| 27 | + * @param string $name  | 
                                                        |
| 28 | 28 | * @param IniSection $parent  | 
                                                        
| 29 | 29 | */  | 
                                                        
| 30 | 30 | public function __construct($name, IniSection $parent = null)  | 
                                                        
@@ -149,7 +149,7 @@ discard block  | 
                                                    ||
| 149 | 149 | |
| 150 | 150 | /**  | 
                                                        
| 151 | 151 | * @param string $itemName  | 
                                                        
| 152 | - * @param string|array|bool|null $itemValue  | 
                                                        |
| 152 | + * @param string $itemValue  | 
                                                        |
| 153 | 153 | *  | 
                                                        
| 154 | 154 | * @return $this  | 
                                                        
| 155 | 155 | * @throws InvalidDataException  | 
                                                        
@@ -200,7 +200,7 @@ discard block  | 
                                                    ||
| 200 | 200 | }  | 
                                                        
| 201 | 201 | |
| 202 | 202 | /**  | 
                                                        
| 203 | - * @return array  | 
                                                        |
| 203 | + * @return string[]  | 
                                                        |
| 204 | 204 | */  | 
                                                        
| 205 | 205 | protected function renderName()  | 
                                                        
| 206 | 206 |      { | 
                                                        
@@ -240,7 +240,7 @@ discard block  | 
                                                    ||
| 240 | 240 | * @param string $name  | 
                                                        
| 241 | 241 | * @param string $value  | 
                                                        
| 242 | 242 | *  | 
                                                        
| 243 | - * @return array  | 
                                                        |
| 243 | + * @return string[]  | 
                                                        |
| 244 | 244 | */  | 
                                                        
| 245 | 245 | protected function renderStringItem($name, $value)  | 
                                                        
| 246 | 246 |      { | 
                                                        
@@ -57,7 +57,7 @@  | 
                                                    ||
| 57 | 57 | if (!is_array($data))  | 
                                                        
| 58 | 58 |          { | 
                                                        
| 59 | 59 |              throw new InvalidDataException('Invalid section contents! ' . | 
                                                        
| 60 | - 'Section contents must be an array.');  | 
                                                        |
| 60 | + 'Section contents must be an array.');  | 
                                                        |
| 61 | 61 | }  | 
                                                        
| 62 | 62 | $this->contents = IniParser::i()->itemValuetoStringRepresentation($data);  | 
                                                        
| 63 | 63 | |
@@ -142,7 +142,7 @@  | 
                                                    ||
| 142 | 142 | public function get($itemName, $defaultValue = null)  | 
                                                        
| 143 | 143 |      { | 
                                                        
| 144 | 144 | $contents = $this->composeContents();  | 
                                                        
| 145 | - $value = isset($contents[$itemName]) ? $contents[$itemName] : $defaultValue;  | 
                                                        |
| 145 | + $value = isset($contents[$itemName]) ? $contents[$itemName] : $defaultValue;  | 
                                                        |
| 146 | 146 | |
| 147 | 147 | return IniParser::i()->castItemValueToProperType($value);  | 
                                                        
| 148 | 148 | }  | 
                                                        
@@ -208,8 +208,7 @@ discard block  | 
                                                    ||
| 208 | 208 | if ($this->hasParent())  | 
                                                        
| 209 | 209 |          { | 
                                                        
| 210 | 210 |              $line = [sprintf('[%s : %s]', $this->getName(), $this->getParent()->getName())]; | 
                                                        
| 211 | - }  | 
                                                        |
| 212 | - else  | 
                                                        |
| 211 | + } else  | 
                                                        |
| 213 | 212 |          { | 
                                                        
| 214 | 213 |              $line = [sprintf('[%s]', $this->getName())]; | 
                                                        
| 215 | 214 | }  | 
                                                        
@@ -227,8 +226,7 @@ discard block  | 
                                                    ||
| 227 | 226 | if (is_array($value))  | 
                                                        
| 228 | 227 |          { | 
                                                        
| 229 | 228 | $lines = $this->renderArrayItem($name, $value);  | 
                                                        
| 230 | - }  | 
                                                        |
| 231 | - else  | 
                                                        |
| 229 | + } else  | 
                                                        |
| 232 | 230 |          { | 
                                                        
| 233 | 231 | $lines = $this->renderStringItem($name, $value);  | 
                                                        
| 234 | 232 | }  | 
                                                        
@@ -175,14 +175,14 @@ discard block  | 
                                                    ||
| 175 | 175 |          { | 
                                                        
| 176 | 176 | $valid = false;  | 
                                                        
| 177 | 177 |              $message = sprintf('Item name is not allowed! Not allowed item names: %s', | 
                                                        
| 178 | -                               implode(', ', $this->invalidItemNames)); | 
                                                        |
| 178 | +                                implode(', ', $this->invalidItemNames)); | 
                                                        |
| 179 | 179 | }  | 
                                                        
| 180 | 180 | |
| 181 | 181 |          if (preg_match(sprintf('/[%s]/', $this->invalidCharsForItemNames), $name) > 0) | 
                                                        
| 182 | 182 |          { | 
                                                        
| 183 | 183 | $valid = false;  | 
                                                        
| 184 | 184 |              $message = sprintf('Invalid name for ini item! Provided item name contains not ' . | 
                                                        
| 185 | - 'allowed chars (%s).', $this->invalidCharsForItemNames);  | 
                                                        |
| 185 | + 'allowed chars (%s).', $this->invalidCharsForItemNames);  | 
                                                        |
| 186 | 186 | }  | 
                                                        
| 187 | 187 | |
| 188 | 188 | return [$valid, $message];  | 
                                                        
@@ -205,8 +205,8 @@ discard block  | 
                                                    ||
| 205 | 205 | if (!is_array($sectionContents))  | 
                                                        
| 206 | 206 |              { | 
                                                        
| 207 | 207 |                  throw new InvalidDataException(sprintf('Orphan fields are not allowed! ' . | 
                                                        
| 208 | - 'Please define a section for field "%s".',  | 
                                                        |
| 209 | - $sectionName));  | 
                                                        |
| 208 | + 'Please define a section for field "%s".',  | 
                                                        |
| 209 | + $sectionName));  | 
                                                        |
| 210 | 210 | }  | 
                                                        
| 211 | 211 | $parsedContents[$sectionName] = new IniSection($sectionName);  | 
                                                        
| 212 | 212 | $parsedContents[$sectionName]->setContents($sectionContents);  | 
                                                        
@@ -216,8 +216,8 @@ discard block  | 
                                                    ||
| 216 | 216 | if (!isset($parsedContents[$parentName]))  | 
                                                        
| 217 | 217 |                  { | 
                                                        
| 218 | 218 |                      throw new InvalidDataException(sprintf('Parent section not found! ' . | 
                                                        
| 219 | - 'Define "%s" section before "%s" section.',  | 
                                                        |
| 220 | - $parentName, $sectionName));  | 
                                                        |
| 219 | + 'Define "%s" section before "%s" section.',  | 
                                                        |
| 220 | + $parentName, $sectionName));  | 
                                                        |
| 221 | 221 | }  | 
                                                        
| 222 | 222 | $parsedContents[$sectionName]->setParent($parsedContents[$parentName]);  | 
                                                        
| 223 | 223 | }  | 
                                                        
@@ -89,23 +89,19 @@ discard block  | 
                                                    ||
| 89 | 89 | if (in_array($value, ['true', 'on', 'yes']))  | 
                                                        
| 90 | 90 |          { | 
                                                        
| 91 | 91 | $normalized = true;  | 
                                                        
| 92 | - }  | 
                                                        |
| 93 | - elseif (in_array($value, ['false', 'off', 'no', 'none']))  | 
                                                        |
| 92 | + } elseif (in_array($value, ['false', 'off', 'no', 'none']))  | 
                                                        |
| 94 | 93 |          { | 
                                                        
| 95 | 94 | $normalized = false;  | 
                                                        
| 96 | - }  | 
                                                        |
| 97 | -        elseif ('null' == $value) | 
                                                        |
| 95 | +        } elseif ('null' == $value) | 
                                                        |
| 98 | 96 |          { | 
                                                        
| 99 | 97 | $normalized = null;  | 
                                                        
| 100 | - }  | 
                                                        |
| 101 | - elseif (is_numeric($value))  | 
                                                        |
| 98 | + } elseif (is_numeric($value))  | 
                                                        |
| 102 | 99 |          { | 
                                                        
| 103 | 100 | $number = $value + 0;  | 
                                                        
| 104 | 101 | if (intval($number) == $number)  | 
                                                        
| 105 | 102 |              { | 
                                                        
| 106 | 103 | $normalized = (int)$number;  | 
                                                        
| 107 | - }  | 
                                                        |
| 108 | - elseif (floatval($number) == $number)  | 
                                                        |
| 104 | + } elseif (floatval($number) == $number)  | 
                                                        |
| 109 | 105 |              { | 
                                                        
| 110 | 106 | $normalized = (float)$number;  | 
                                                        
| 111 | 107 | }  | 
                                                        
@@ -127,28 +123,23 @@ discard block  | 
                                                    ||
| 127 | 123 | if (is_bool($value))  | 
                                                        
| 128 | 124 |          { | 
                                                        
| 129 | 125 | $castedValue = (true == $value) ? 'true' : 'false';  | 
                                                        
| 130 | - }  | 
                                                        |
| 131 | - elseif (is_null($value))  | 
                                                        |
| 126 | + } elseif (is_null($value))  | 
                                                        |
| 132 | 127 |          { | 
                                                        
| 133 | 128 | $castedValue = 'null';  | 
                                                        
| 134 | - }  | 
                                                        |
| 135 | - elseif (is_array($value))  | 
                                                        |
| 129 | + } elseif (is_array($value))  | 
                                                        |
| 136 | 130 |          { | 
                                                        
| 137 | 131 | $castedValue = [];  | 
                                                        
| 138 | 132 | foreach ($value as $k => $v)  | 
                                                        
| 139 | 133 |              { | 
                                                        
| 140 | 134 | $castedValue[$k] = $this->itemValuetoStringRepresentation($v);  | 
                                                        
| 141 | 135 | }  | 
                                                        
| 142 | - }  | 
                                                        |
| 143 | - elseif (is_numeric($value))  | 
                                                        |
| 136 | + } elseif (is_numeric($value))  | 
                                                        |
| 144 | 137 |          { | 
                                                        
| 145 | 138 | $castedValue = (string)$value;  | 
                                                        
| 146 | - }  | 
                                                        |
| 147 | - elseif (is_string($value))  | 
                                                        |
| 139 | + } elseif (is_string($value))  | 
                                                        |
| 148 | 140 |          { | 
                                                        
| 149 | 141 | $castedValue = $value;  | 
                                                        
| 150 | - }  | 
                                                        |
| 151 | - else  | 
                                                        |
| 142 | + } else  | 
                                                        |
| 152 | 143 |          { | 
                                                        
| 153 | 144 |              throw new InvalidDataException('Invalid item value type!'); | 
                                                        
| 154 | 145 | }  | 
                                                        
@@ -98,7 +98,7 @@ discard block  | 
                                                    ||
| 98 | 98 | if ($this->hasSection($section->getName()))  | 
                                                        
| 99 | 99 |          { | 
                                                        
| 100 | 100 |              throw new InvalidDataException(sprintf('Section "%s" already exists!', | 
                                                        
| 101 | - $section->getName()));  | 
                                                        |
| 101 | + $section->getName()));  | 
                                                        |
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
| 104 | 104 | if ($section->hasParent())  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | if (!isset($this->sections[$section->getParent()->getName()]))  | 
                                                        
| 107 | 107 |              { | 
                                                        
| 108 | 108 |                  throw new InvalidDataException(sprintf('Parent section "%s" does not exists!', | 
                                                        
| 109 | - $section->getParent()->getName()));  | 
                                                        |
| 109 | + $section->getParent()->getName()));  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | |
@@ -75,7 +75,7 @@  | 
                                                    ||
| 75 | 75 | $outputFile = $this->file;  | 
                                                        
| 76 | 76 | }  | 
                                                        
| 77 | 77 | |
| 78 | - if(is_file($outputFile) && !is_writable($outputFile))  | 
                                                        |
| 78 | + if (is_file($outputFile) && !is_writable($outputFile))  | 
                                                        |
| 79 | 79 |          { | 
                                                        
| 80 | 80 |              throw new FileException(sprintf('Output file "%s" is not writable!', $outputFile)); | 
                                                        
| 81 | 81 | }  |