@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $parsed = $this->tokens($source); |
| 29 | 29 | |
| 30 | - if (count($tokens) !== count($parsed)) { |
|
| 30 | + if (count($tokens) !== count($parsed)){ |
|
| 31 | 31 | $this->fail('Token count mismatch'); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - foreach ($tokens as $index => $token) { |
|
| 34 | + foreach ($tokens as $index => $token){ |
|
| 35 | 35 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
| 36 | 36 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
| 37 | 37 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | protected function tokens(string $source): array |
| 42 | 42 | { |
| 43 | 43 | $lexer = new Lexer(); |
| 44 | - foreach (static::GRAMMARS as $grammar) { |
|
| 44 | + foreach (static::GRAMMARS as $grammar){ |
|
| 45 | 45 | $lexer->addGrammar(new $grammar()); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $tokens = []; |
| 49 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
| 49 | + foreach ($lexer->parse(new StringStream($source)) as $t){ |
|
| 50 | 50 | $tokens[] = $t; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -27,11 +27,13 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $parsed = $this->tokens($source); |
| 29 | 29 | |
| 30 | - if (count($tokens) !== count($parsed)) { |
|
| 30 | + if (count($tokens) !== count($parsed)) |
|
| 31 | + { |
|
| 31 | 32 | $this->fail('Token count mismatch'); |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | - foreach ($tokens as $index => $token) { |
|
| 35 | + foreach ($tokens as $index => $token) |
|
| 36 | + { |
|
| 35 | 37 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
| 36 | 38 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
| 37 | 39 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -41,12 +43,14 @@ discard block |
||
| 41 | 43 | protected function tokens(string $source): array |
| 42 | 44 | { |
| 43 | 45 | $lexer = new Lexer(); |
| 44 | - foreach (static::GRAMMARS as $grammar) { |
|
| 46 | + foreach (static::GRAMMARS as $grammar) |
|
| 47 | + { |
|
| 45 | 48 | $lexer->addGrammar(new $grammar()); |
| 46 | 49 | } |
| 47 | 50 | |
| 48 | 51 | $tokens = []; |
| 49 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
| 52 | + foreach ($lexer->parse(new StringStream($source)) as $t) |
|
| 53 | + { |
|
| 50 | 54 | $tokens[] = $t; |
| 51 | 55 | } |
| 52 | 56 | |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $parsed = $this->tokens($source); |
| 35 | 35 | |
| 36 | - if (count($tokens) !== count($parsed)) { |
|
| 36 | + if (count($tokens) !== count($parsed)){ |
|
| 37 | 37 | $this->fail('Token count mismatch'); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - foreach ($tokens as $index => $token) { |
|
| 40 | + foreach ($tokens as $index => $token){ |
|
| 41 | 41 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
| 42 | 42 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
| 43 | 43 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $lexer = new Lexer(); |
| 50 | 50 | |
| 51 | 51 | $tokens = []; |
| 52 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
| 52 | + foreach ($lexer->parse(new StringStream($source)) as $t){ |
|
| 53 | 53 | $tokens[] = $t; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -33,11 +33,13 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $parsed = $this->tokens($source); |
| 35 | 35 | |
| 36 | - if (count($tokens) !== count($parsed)) { |
|
| 36 | + if (count($tokens) !== count($parsed)) |
|
| 37 | + { |
|
| 37 | 38 | $this->fail('Token count mismatch'); |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | - foreach ($tokens as $index => $token) { |
|
| 41 | + foreach ($tokens as $index => $token) |
|
| 42 | + { |
|
| 41 | 43 | $this->assertSame($token->type, $parsed[$index]->type, 'Token type mismatch'); |
| 42 | 44 | $this->assertSame($token->offset, $parsed[$index]->offset, 'Token offset mismatch'); |
| 43 | 45 | $this->assertSame($token->content, $parsed[$index]->content, 'Token content mismatch'); |
@@ -49,7 +51,8 @@ discard block |
||
| 49 | 51 | $lexer = new Lexer(); |
| 50 | 52 | |
| 51 | 53 | $tokens = []; |
| 52 | - foreach ($lexer->parse(new StringStream($source)) as $t) { |
|
| 54 | + foreach ($lexer->parse(new StringStream($source)) as $t) |
|
| 55 | + { |
|
| 53 | 56 | $tokens[] = $t; |
| 54 | 57 | } |
| 55 | 58 | |
@@ -36,9 +36,9 @@ |
||
| 36 | 36 | protected const DIRECTIVES = []; |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * @param Template $document |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 39 | + * @param Template $document |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | 42 | protected function compile(Template $document): string |
| 43 | 43 | { |
| 44 | 44 | $compiler = new Compiler(); |
@@ -42,12 +42,12 @@ |
||
| 42 | 42 | protected function compile(Template $document): string |
| 43 | 43 | { |
| 44 | 44 | $compiler = new Compiler(); |
| 45 | - foreach (static::RENDERS as $renderer) { |
|
| 45 | + foreach (static::RENDERS as $renderer){ |
|
| 46 | 46 | $compiler->addRenderer(new $renderer()); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $directiveGroup = new DirectiveGroup(); |
| 50 | - foreach (static::DIRECTIVES as $directive) { |
|
| 50 | + foreach (static::DIRECTIVES as $directive){ |
|
| 51 | 51 | $directiveGroup->addDirective(new $directive()); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -42,12 +42,14 @@ |
||
| 42 | 42 | protected function compile(Template $document): string |
| 43 | 43 | { |
| 44 | 44 | $compiler = new Compiler(); |
| 45 | - foreach (static::RENDERS as $renderer) { |
|
| 45 | + foreach (static::RENDERS as $renderer) |
|
| 46 | + { |
|
| 46 | 47 | $compiler->addRenderer(new $renderer()); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | $directiveGroup = new DirectiveGroup(); |
| 50 | - foreach (static::DIRECTIVES as $directive) { |
|
| 51 | + foreach (static::DIRECTIVES as $directive) |
|
| 52 | + { |
|
| 51 | 53 | $directiveGroup->addDirective(new $directive()); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $parser = new Parser(); |
| 32 | 32 | |
| 33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
| 33 | + foreach (static::GRAMMARS as $grammar => $syntax){ |
|
| 34 | 34 | $parser->addSyntax(new $grammar(), new $syntax()); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -30,7 +30,8 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $parser = new Parser(); |
| 32 | 32 | |
| 33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
| 33 | + foreach (static::GRAMMARS as $grammar => $syntax) |
|
| 34 | + { |
|
| 34 | 35 | $parser->addSyntax(new $grammar(), new $syntax()); |
| 35 | 36 | } |
| 36 | 37 | |
@@ -24,19 +24,19 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function leaveNode(Node $node): void |
| 26 | 26 | { |
| 27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
| 28 | - foreach ($node->params as $param) { |
|
| 29 | - if ($param->type instanceof Node\NullableType) { |
|
| 30 | - if ($param->type->type instanceof Node\Identifier) { |
|
| 27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct'){ |
|
| 28 | + foreach ($node->params as $param){ |
|
| 29 | + if ($param->type instanceof Node\NullableType){ |
|
| 30 | + if ($param->type->type instanceof Node\Identifier){ |
|
| 31 | 31 | $type = $param->type->type->name; |
| 32 | - } else { |
|
| 32 | + }else{ |
|
| 33 | 33 | $type = implode('\\', $param->type->type->parts); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $type = "?$type"; |
| 37 | - } elseif ($param->type instanceof Node\Name) { |
|
| 37 | + } elseif ($param->type instanceof Node\Name){ |
|
| 38 | 38 | $type = implode('\\', $param->type->parts); |
| 39 | - } else { |
|
| 39 | + }else{ |
|
| 40 | 40 | $type = $param->type->name ?? null; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -24,19 +24,29 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function leaveNode(Node $node): void |
| 26 | 26 | { |
| 27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
| 28 | - foreach ($node->params as $param) { |
|
| 29 | - if ($param->type instanceof Node\NullableType) { |
|
| 30 | - if ($param->type->type instanceof Node\Identifier) { |
|
| 27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') |
|
| 28 | + { |
|
| 29 | + foreach ($node->params as $param) |
|
| 30 | + { |
|
| 31 | + if ($param->type instanceof Node\NullableType) |
|
| 32 | + { |
|
| 33 | + if ($param->type->type instanceof Node\Identifier) |
|
| 34 | + { |
|
| 31 | 35 | $type = $param->type->type->name; |
| 32 | - } else { |
|
| 36 | + } |
|
| 37 | + else |
|
| 38 | + { |
|
| 33 | 39 | $type = implode('\\', $param->type->type->parts); |
| 34 | 40 | } |
| 35 | 41 | |
| 36 | 42 | $type = "?$type"; |
| 37 | - } elseif ($param->type instanceof Node\Name) { |
|
| 43 | + } |
|
| 44 | + elseif ($param->type instanceof Node\Name) |
|
| 45 | + { |
|
| 38 | 46 | $type = implode('\\', $param->type->parts); |
| 39 | - } else { |
|
| 47 | + } |
|
| 48 | + else |
|
| 49 | + { |
|
| 40 | 50 | $type = $param->type->name ?? null; |
| 41 | 51 | } |
| 42 | 52 | |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * @see https://github.com/symplify/symplify/issues/2061 |
| 12 | 12 | */ |
| 13 | -\register_shutdown_function(static function () { |
|
| 14 | - $dest = \json_decode(\file_get_contents(__DIR__ . '/composer.json'), true); |
|
| 13 | +\register_shutdown_function(static function (){ |
|
| 14 | + $dest = \json_decode(\file_get_contents(__DIR__.'/composer.json'), true); |
|
| 15 | 15 | |
| 16 | 16 | $result = [ |
| 17 | 17 | 'name' => 'spiral/framework', |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $json = \json_encode($result, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES); |
| 48 | 48 | |
| 49 | - \file_put_contents(__DIR__ . '/composer.json', $json . "\n"); |
|
| 49 | + \file_put_contents(__DIR__.'/composer.json', $json."\n"); |
|
| 50 | 50 | }); |
| 51 | 51 | |
| 52 | 52 | |
@@ -10,7 +10,8 @@ |
||
| 10 | 10 | * |
| 11 | 11 | * @see https://github.com/symplify/symplify/issues/2061 |
| 12 | 12 | */ |
| 13 | -\register_shutdown_function(static function () { |
|
| 13 | +\register_shutdown_function(static function () |
|
| 14 | +{ |
|
| 14 | 15 | $dest = \json_decode(\file_get_contents(__DIR__ . '/composer.json'), true); |
| 15 | 16 | |
| 16 | 17 | $result = [ |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | class StreamsTest extends TestCase |
| 19 | 19 | { |
| 20 | - private const FIXTURE_DIRECTORY = __DIR__ . '/fixtures'; |
|
| 20 | + private const FIXTURE_DIRECTORY = __DIR__.'/fixtures'; |
|
| 21 | 21 | |
| 22 | 22 | public function setUp(): void |
| 23 | 23 | { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $this->assertSame(strlen('sample text'), filesize($filename)); |
| 43 | 43 | $this->assertSame(md5('sample text'), md5_file($filename)); |
| 44 | 44 | |
| 45 | - $newFilename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 45 | + $newFilename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 46 | 46 | copy($filename, $newFilename); |
| 47 | 47 | |
| 48 | 48 | $this->assertFileExists($newFilename); |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function testException() |
| 85 | 85 | { |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | fopen('spiral://non-exists', 'rb'); |
| 88 | - } catch (\Throwable $e) { |
|
| 88 | + }catch (\Throwable $e){ |
|
| 89 | 89 | $this->assertStringContainsString('failed to open stream', $e->getMessage()); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - try { |
|
| 92 | + try{ |
|
| 93 | 93 | filemtime('spiral://non-exists'); |
| 94 | - } catch (\Throwable $e) { |
|
| 94 | + }catch (\Throwable $e){ |
|
| 95 | 95 | $this->assertStringContainsString('stat failed', $e->getMessage()); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function testExceptionPHP8() |
| 103 | 103 | { |
| 104 | - try { |
|
| 104 | + try{ |
|
| 105 | 105 | fopen('spiral://non-exists', 'rb'); |
| 106 | - } catch (\Throwable $e) { |
|
| 106 | + }catch (\Throwable $e){ |
|
| 107 | 107 | $this->assertStringContainsString('Failed to open stream', $e->getMessage()); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - try { |
|
| 110 | + try{ |
|
| 111 | 111 | filemtime('spiral://non-exists'); |
| 112 | - } catch (\Throwable $e) { |
|
| 112 | + }catch (\Throwable $e){ |
|
| 113 | 113 | $this->assertStringContainsString('stat failed', $e->getMessage()); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -83,15 +83,21 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function testException() |
| 85 | 85 | { |
| 86 | - try { |
|
| 86 | + try |
|
| 87 | + { |
|
| 87 | 88 | fopen('spiral://non-exists', 'rb'); |
| 88 | - } catch (\Throwable $e) { |
|
| 89 | + } |
|
| 90 | + catch (\Throwable $e) |
|
| 91 | + { |
|
| 89 | 92 | $this->assertStringContainsString('failed to open stream', $e->getMessage()); |
| 90 | 93 | } |
| 91 | 94 | |
| 92 | - try { |
|
| 95 | + try |
|
| 96 | + { |
|
| 93 | 97 | filemtime('spiral://non-exists'); |
| 94 | - } catch (\Throwable $e) { |
|
| 98 | + } |
|
| 99 | + catch (\Throwable $e) |
|
| 100 | + { |
|
| 95 | 101 | $this->assertStringContainsString('stat failed', $e->getMessage()); |
| 96 | 102 | } |
| 97 | 103 | } |
@@ -101,15 +107,21 @@ discard block |
||
| 101 | 107 | */ |
| 102 | 108 | public function testExceptionPHP8() |
| 103 | 109 | { |
| 104 | - try { |
|
| 110 | + try |
|
| 111 | + { |
|
| 105 | 112 | fopen('spiral://non-exists', 'rb'); |
| 106 | - } catch (\Throwable $e) { |
|
| 113 | + } |
|
| 114 | + catch (\Throwable $e) |
|
| 115 | + { |
|
| 107 | 116 | $this->assertStringContainsString('Failed to open stream', $e->getMessage()); |
| 108 | 117 | } |
| 109 | 118 | |
| 110 | - try { |
|
| 119 | + try |
|
| 120 | + { |
|
| 111 | 121 | filemtime('spiral://non-exists'); |
| 112 | - } catch (\Throwable $e) { |
|
| 122 | + } |
|
| 123 | + catch (\Throwable $e) |
|
| 124 | + { |
|
| 113 | 125 | $this->assertStringContainsString('stat failed', $e->getMessage()); |
| 114 | 126 | } |
| 115 | 127 | } |
@@ -51,11 +51,11 @@ |
||
| 51 | 51 | public static function unpack(array $payload): MessageInterface |
| 52 | 52 | { |
| 53 | 53 | $message = new Message($payload['subject'], $payload['to'], $payload['data']); |
| 54 | - if ($payload['from'] !== null) { |
|
| 54 | + if ($payload['from'] !== null){ |
|
| 55 | 55 | $message->setFrom($payload['from']); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($payload['replyTo'] !== null) { |
|
| 58 | + if ($payload['replyTo'] !== null){ |
|
| 59 | 59 | $message->setReplyTo($payload['replyTo']); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -51,11 +51,13 @@ |
||
| 51 | 51 | public static function unpack(array $payload): MessageInterface |
| 52 | 52 | { |
| 53 | 53 | $message = new Message($payload['subject'], $payload['to'], $payload['data']); |
| 54 | - if ($payload['from'] !== null) { |
|
| 54 | + if ($payload['from'] !== null) |
|
| 55 | + { |
|
| 55 | 56 | $message->setFrom($payload['from']); |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | - if ($payload['replyTo'] !== null) { |
|
| 59 | + if ($payload['replyTo'] !== null) |
|
| 60 | + { |
|
| 59 | 61 | $message->setReplyTo($payload['replyTo']); |
| 60 | 62 | } |
| 61 | 63 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $source = file_get_contents($filename); |
| 30 | 30 | $this->assertStringContainsString('use PrototypeTrait;', $source); |
| 31 | 31 | |
| 32 | - try { |
|
| 32 | + try{ |
|
| 33 | 33 | $this->app->bindApp(); |
| 34 | 34 | |
| 35 | 35 | $inp = new ArrayInput(['--remove' => true]); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $this->app->get(Console::class)->run('prototype:inject', $inp, $out); |
| 38 | 38 | |
| 39 | 39 | $this->assertStringNotContainsString('use PrototypeTrait;', file_get_contents($filename)); |
| 40 | - } finally { |
|
| 40 | + }finally{ |
|
| 41 | 41 | file_put_contents($filename, $source); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -29,7 +29,8 @@ discard block |
||
| 29 | 29 | $source = file_get_contents($filename); |
| 30 | 30 | $this->assertStringContainsString('use PrototypeTrait;', $source); |
| 31 | 31 | |
| 32 | - try { |
|
| 32 | + try |
|
| 33 | + { |
|
| 33 | 34 | $this->app->bindApp(); |
| 34 | 35 | |
| 35 | 36 | $inp = new ArrayInput(['--remove' => true]); |
@@ -37,7 +38,9 @@ discard block |
||
| 37 | 38 | $this->app->get(Console::class)->run('prototype:inject', $inp, $out); |
| 38 | 39 | |
| 39 | 40 | $this->assertStringNotContainsString('use PrototypeTrait;', file_get_contents($filename)); |
| 40 | - } finally { |
|
| 41 | + } |
|
| 42 | + finally |
|
| 43 | + { |
|
| 41 | 44 | file_put_contents($filename, $source); |
| 42 | 45 | } |
| 43 | 46 | } |