@@ -61,7 +61,7 @@ |
||
| 61 | 61 | $this->line += substr_count($matches[0], "\n"); |
| 62 | 62 | } else { |
| 63 | 63 | $i = 0; |
| 64 | - $matches = [ '' ]; |
|
| 64 | + $matches = ['']; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ($this->tokenMaps[$this->state][$i - 1]) { |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | private mixed $value = null; |
| 28 | 28 | private ObjectNode $options; |
| 29 | 29 | |
| 30 | - public function __construct(string|Node $path, string $file, int $line, ObjectNode $options) |
|
| 30 | + public function __construct(string | Node $path, string $file, int $line, ObjectNode $options) |
|
| 31 | 31 | { |
| 32 | 32 | $this->path = $path; |
| 33 | 33 | $this->file = $file; |
@@ -27,16 +27,16 @@ |
||
| 27 | 27 | public const T_END_STR = 263; |
| 28 | 28 | public const T_EOF = -1; |
| 29 | 29 | |
| 30 | - public int|string $type; |
|
| 30 | + public int | string $type; |
|
| 31 | 31 | public mixed $value; |
| 32 | 32 | |
| 33 | - public function __construct(int|string $type, mixed $value) |
|
| 33 | + public function __construct(int | string $type, mixed $value) |
|
| 34 | 34 | { |
| 35 | 35 | $this->type = $type; |
| 36 | 36 | $this->value = $value; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function getLiteral(int|string $type): string |
|
| 39 | + public static function getLiteral(int | string $type): string |
|
| 40 | 40 | { |
| 41 | 41 | $refClass = new \ReflectionClass(self::class); |
| 42 | 42 | $names = array_flip($refClass->getConstants()); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | throw new Exception('Macro with the same name already registered.'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $this->macro[$macro->getName()] = [ $macro, 'execute' ]; |
|
| 39 | + $this->macro[$macro->getName()] = [$macro, 'execute']; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function setVariable(string $name, mixed $value): void |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $required = $this->consumeOptionalAssignementOperator(); |
| 243 | 243 | $realValue = $this->parseValue($required, $valueIsKey); |
| 244 | 244 | if ($valueIsKey) { |
| 245 | - return new ObjectNode([ (string) $value => $realValue ]); |
|
| 245 | + return new ObjectNode([(string) $value => $realValue]); |
|
| 246 | 246 | } |
| 247 | 247 | break; |
| 248 | 248 | case Token::T_BOOL: |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | /** |
| 282 | 282 | * Scalar ::= T_END_STR | T_NAME | T_BOOL | T_NUM | T_NULL |
| 283 | 283 | */ |
| 284 | - private function parseScalar(): null|bool|int|float|string |
|
| 284 | + private function parseScalar(): null | bool | int | float | string |
|
| 285 | 285 | { |
| 286 | 286 | $value = $this->token->value; |
| 287 | 287 | $this->nextToken(); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | /** |
| 293 | 293 | * String ::= { T_ENCAPSED_VAR | T_STRING }* T_END_STR |
| 294 | 294 | */ |
| 295 | - private function parseString(): string|OperationNode |
|
| 295 | + private function parseString(): string | OperationNode |
|
| 296 | 296 | { |
| 297 | 297 | $value = ''; |
| 298 | 298 | $continue = true; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $this->error("Unable to read file '{$fileName}'"); |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - private function doInclude(Node|string $fileName, ObjectNode $options): mixed |
|
| 403 | + private function doInclude(Node | string $fileName, ObjectNode $options): mixed |
|
| 404 | 404 | { |
| 405 | 405 | $includeValue = new ObjectNode(); |
| 406 | 406 | |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | return $includeValue; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - $files = [ $path ]; |
|
| 419 | + $files = [$path]; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $token = $this->token; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | return $includeValue; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - public function resolvePath(string $file): string|false |
|
| 442 | + public function resolvePath(string $file): string | false |
|
| 443 | 443 | { |
| 444 | 444 | return $this->relativeToCurrentFile(fn() => realpath($file)); |
| 445 | 445 | } |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | return $value; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - private function consume(int|string $type): void |
|
| 618 | + private function consume(int | string $type): void |
|
| 619 | 619 | { |
| 620 | 620 | if ($type !== $this->token->type) { |
| 621 | 621 | $this->syntaxError(); |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | return true; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - private function consumeOptional(int|string $type): bool |
|
| 655 | + private function consumeOptional(int | string $type): bool |
|
| 656 | 656 | { |
| 657 | 657 | if ($type !== $this->token->type) { |
| 658 | 658 | return false; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | return $this->cast($val, $options['type']); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private function cast(string $value, string $type): bool|string|int|float |
|
| 43 | + private function cast(string $value, string $type): bool | string | int | float |
|
| 44 | 44 | { |
| 45 | 45 | return match ($type) { |
| 46 | 46 | 'bool', 'boolean' => TypeCaster::toBool($value), |
@@ -162,14 +162,14 @@ |
||
| 162 | 162 | return match (true) { |
| 163 | 163 | (0x7F & $bytes) == $bytes => chr($bytes), |
| 164 | 164 | (0x07FF & $bytes) == $bytes => chr(0xc0 | ($bytes >> 6)) |
| 165 | - . chr(0x80 | ($bytes & 0x3F)), |
|
| 165 | + . chr(0x80 | ($bytes & 0x3F)), |
|
| 166 | 166 | (0xFFFF & $bytes) == $bytes => chr(0xe0 | ($bytes >> 12)) |
| 167 | - . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
| 168 | - . chr(0x80 | ($bytes & 0x3F)), |
|
| 167 | + . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
| 168 | + . chr(0x80 | ($bytes & 0x3F)), |
|
| 169 | 169 | default => chr(0xF0 | ($bytes >> 18)) |
| 170 | - . chr(0x80 | (($bytes >> 12) & 0x3F)) |
|
| 171 | - . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
| 172 | - . chr(0x80 | ($bytes & 0x3F)), |
|
| 170 | + . chr(0x80 | (($bytes >> 12) & 0x3F)) |
|
| 171 | + . chr(0x80 | (($bytes >> 6) & 0x3F)) |
|
| 172 | + . chr(0x80 | ($bytes & 0x3F)), |
|
| 173 | 173 | }; |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | self::STATE_INITIAL => [ |
| 42 | 42 | self::REGEX_SPACE => false, |
| 43 | 43 | self::REGEX_COMMENT => false, |
| 44 | - self::REGEX_COMMENT_ML => function () { |
|
| 44 | + self::REGEX_COMMENT_ML => function() { |
|
| 45 | 45 | $pos = strpos($this->content, '*/', $this->count); |
| 46 | 46 | if (false === $pos) { |
| 47 | 47 | $this->line += substr_count(substr($this->content, $this->count), "\n"); |
@@ -50,27 +50,27 @@ discard block |
||
| 50 | 50 | $this->line += substr_count(substr($this->content, $this->count, (int) $pos - $this->count + 2), "\n"); |
| 51 | 51 | $this->count = (int) $pos + 2; |
| 52 | 52 | }, |
| 53 | - self::REGEX_DQUOTE => function (): void { |
|
| 53 | + self::REGEX_DQUOTE => function(): void { |
|
| 54 | 54 | $this->begin(self::STATE_INSTRING); |
| 55 | 55 | $this->textBuffer = ''; |
| 56 | 56 | }, |
| 57 | - self::REGEX_BOOL => function (mixed &$yylval): int { |
|
| 57 | + self::REGEX_BOOL => function(mixed &$yylval): int { |
|
| 58 | 58 | $yylval = TypeCaster::toBool($yylval); |
| 59 | 59 | |
| 60 | 60 | return Token::T_BOOL; |
| 61 | 61 | }, |
| 62 | - self::REGEX_NULL => function (mixed &$yylval): int { |
|
| 62 | + self::REGEX_NULL => function(mixed &$yylval): int { |
|
| 63 | 63 | $yylval = null; |
| 64 | 64 | |
| 65 | 65 | return Token::T_NULL; |
| 66 | 66 | }, |
| 67 | - self::REGEX_NUM => function (mixed &$yylval): int { |
|
| 67 | + self::REGEX_NUM => function(mixed &$yylval): int { |
|
| 68 | 68 | $yylval = TypeCaster::toNum($yylval); |
| 69 | 69 | |
| 70 | 70 | return Token::T_NUM; |
| 71 | 71 | }, |
| 72 | 72 | self::REGEX_NAME => fn() => Token::T_NAME, |
| 73 | - self::REGEX_HEREDOC => function (mixed &$yylval): int { |
|
| 73 | + self::REGEX_HEREDOC => function(mixed &$yylval): int { |
|
| 74 | 74 | $needle = "\n" . $yylval; |
| 75 | 75 | $pos = strpos($this->content, $needle, $this->count); |
| 76 | 76 | if (false === $pos) { |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | }, |
| 87 | 87 | self::REGEX_TOKEN => fn(mixed $yylval): string => $yylval, |
| 88 | 88 | self::REGEX_VAR => fn(): int => Token::T_VAR, |
| 89 | - self::REGEX_ANY => function (mixed $yylval): void { |
|
| 89 | + self::REGEX_ANY => function(mixed $yylval): void { |
|
| 90 | 90 | $this->error('Unexpected char \'' . $yylval . '\''); |
| 91 | 91 | }, |
| 92 | 92 | self::EOF => fn(): int => Token::T_EOF, |
| 93 | 93 | ], |
| 94 | 94 | self::STATE_INSTRING => [ |
| 95 | - '[^\\\"$]+' => function (mixed &$yylval) { |
|
| 95 | + '[^\\\"$]+' => function(mixed &$yylval) { |
|
| 96 | 96 | $this->textBuffer .= $yylval; |
| 97 | 97 | if ('$' == substr($this->content, $this->count, 1)) { |
| 98 | 98 | $yylval = $this->textBuffer; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | return Token::T_STRING; |
| 102 | 102 | } |
| 103 | 103 | }, |
| 104 | - '?:\\\(.)' => function (mixed $yylval) { |
|
| 104 | + '?:\\\(.)' => function(mixed $yylval) { |
|
| 105 | 105 | switch ($yylval) { |
| 106 | 106 | case 'n': |
| 107 | 107 | $this->textBuffer .= "\n"; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | }, |
| 137 | - '\$' => function (mixed &$yylval) { |
|
| 137 | + '\$' => function(mixed &$yylval) { |
|
| 138 | 138 | if (preg_match('/^{([A-Za-z0-9_]+)}/', substr($this->content, $this->count), $matches)) { |
| 139 | 139 | $this->count += strlen($matches[0]); |
| 140 | 140 | $yylval = $matches[1]; |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $this->textBuffer .= $yylval; |
| 146 | 146 | }, |
| 147 | - self::REGEX_DQUOTE => function (mixed &$yylval) { |
|
| 147 | + self::REGEX_DQUOTE => function(mixed &$yylval) { |
|
| 148 | 148 | $yylval = $this->textBuffer; |
| 149 | 149 | $this->begin(self::STATE_INITIAL); |
| 150 | 150 | |
| 151 | 151 | return Token::T_END_STR; |
| 152 | 152 | }, |
| 153 | - self::EOF => function () { |
|
| 153 | + self::EOF => function() { |
|
| 154 | 154 | $this->error('Unterminated string'); |
| 155 | 155 | }, |
| 156 | 156 | ], |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class ObjectNode extends Node implements \IteratorAggregate, \ArrayAccess, \Countable |
| 23 | 23 | { |
| 24 | - private array $value = []; |
|
| 24 | + private array $value = []; |
|
| 25 | 25 | private bool $isNative = true; |
| 26 | 26 | |
| 27 | 27 | public function __construct(array $values = []) |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | class TypeCaster |
| 19 | 19 | { |
| 20 | - public static function toNum(string $val): float|int |
|
| 20 | + public static function toNum(string $val): float | int |
|
| 21 | 21 | { |
| 22 | 22 | $f = (float) $val; |
| 23 | 23 | $i = (int) $val; |