@@ -67,7 +67,7 @@ |
||
| 67 | 67 | |
| 68 | 68 | protected function tearDown(): void |
| 69 | 69 | { |
| 70 | - if ((int) \session_status() === PHP_SESSION_ACTIVE) { |
|
| 70 | + if ((int)\session_status() === PHP_SESSION_ACTIVE){ |
|
| 71 | 71 | \session_abort(); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -67,7 +67,8 @@ |
||
| 67 | 67 | |
| 68 | 68 | protected function tearDown(): void |
| 69 | 69 | { |
| 70 | - if ((int) \session_status() === PHP_SESSION_ACTIVE) { |
|
| 70 | + if ((int) \session_status() === PHP_SESSION_ACTIVE) |
|
| 71 | + { |
|
| 71 | 72 | \session_abort(); |
| 72 | 73 | } |
| 73 | 74 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | self::assertSame('default', $section->getName()); |
| 88 | 88 | |
| 89 | 89 | $section->set('key', 'value'); |
| 90 | - foreach ($section as $key => $value) { |
|
| 90 | + foreach ($section as $key => $value){ |
|
| 91 | 91 | self::assertSame('key', $key); |
| 92 | 92 | self::assertSame('value', $value); |
| 93 | 93 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | protected function tearDown(): void |
| 225 | 225 | { |
| 226 | - if ((int) \session_status() === PHP_SESSION_ACTIVE) { |
|
| 226 | + if ((int)\session_status() === PHP_SESSION_ACTIVE){ |
|
| 227 | 227 | \session_abort(); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -87,7 +87,8 @@ discard block |
||
| 87 | 87 | self::assertSame('default', $section->getName()); |
| 88 | 88 | |
| 89 | 89 | $section->set('key', 'value'); |
| 90 | - foreach ($section as $key => $value) { |
|
| 90 | + foreach ($section as $key => $value) |
|
| 91 | + { |
|
| 91 | 92 | self::assertSame('key', $key); |
| 92 | 93 | self::assertSame('value', $value); |
| 93 | 94 | } |
@@ -223,7 +224,8 @@ discard block |
||
| 223 | 224 | |
| 224 | 225 | protected function tearDown(): void |
| 225 | 226 | { |
| 226 | - if ((int) \session_status() === PHP_SESSION_ACTIVE) { |
|
| 227 | + if ((int) \session_status() === PHP_SESSION_ACTIVE) |
|
| 228 | + { |
|
| 227 | 229 | \session_abort(); |
| 228 | 230 | } |
| 229 | 231 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | public function getDirectives(): array |
| 25 | 25 | { |
| 26 | 26 | $directives = []; |
| 27 | - foreach ($this->config['directives'] as $directive) { |
|
| 28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
| 27 | + foreach ($this->config['directives'] as $directive){ |
|
| 28 | + if (\is_object($directive) && !$directive instanceof Autowire){ |
|
| 29 | 29 | $directives[] = $directive; |
| 30 | 30 | continue; |
| 31 | 31 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | public function getProcessors(): array |
| 43 | 43 | { |
| 44 | 44 | $processors = []; |
| 45 | - foreach ($this->config['processors'] as $processor) { |
|
| 46 | - if (\is_object($processor) && !$processor instanceof Autowire) { |
|
| 45 | + foreach ($this->config['processors'] as $processor){ |
|
| 46 | + if (\is_object($processor) && !$processor instanceof Autowire){ |
|
| 47 | 47 | $processors[] = $processor; |
| 48 | 48 | continue; |
| 49 | 49 | } |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | public function getVisitors(int $stage): array |
| 58 | 58 | { |
| 59 | 59 | $visitors = []; |
| 60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
| 61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
| 60 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor){ |
|
| 61 | + if (\is_object($visitor) && !$visitor instanceof Autowire){ |
|
| 62 | 62 | $visitors[] = $visitor; |
| 63 | 63 | continue; |
| 64 | 64 | } |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function wire(mixed $item): Autowire |
| 76 | 76 | { |
| 77 | - if ($item instanceof Autowire) { |
|
| 77 | + if ($item instanceof Autowire){ |
|
| 78 | 78 | return $item; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (\is_string($item)) { |
|
| 81 | + if (\is_string($item)){ |
|
| 82 | 82 | return new Autowire($item); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -24,8 +24,10 @@ discard block |
||
| 24 | 24 | public function getDirectives(): array |
| 25 | 25 | { |
| 26 | 26 | $directives = []; |
| 27 | - foreach ($this->config['directives'] as $directive) { |
|
| 28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
| 27 | + foreach ($this->config['directives'] as $directive) |
|
| 28 | + { |
|
| 29 | + if (\is_object($directive) && !$directive instanceof Autowire) |
|
| 30 | + { |
|
| 29 | 31 | $directives[] = $directive; |
| 30 | 32 | continue; |
| 31 | 33 | } |
@@ -42,8 +44,10 @@ discard block |
||
| 42 | 44 | public function getProcessors(): array |
| 43 | 45 | { |
| 44 | 46 | $processors = []; |
| 45 | - foreach ($this->config['processors'] as $processor) { |
|
| 46 | - if (\is_object($processor) && !$processor instanceof Autowire) { |
|
| 47 | + foreach ($this->config['processors'] as $processor) |
|
| 48 | + { |
|
| 49 | + if (\is_object($processor) && !$processor instanceof Autowire) |
|
| 50 | + { |
|
| 47 | 51 | $processors[] = $processor; |
| 48 | 52 | continue; |
| 49 | 53 | } |
@@ -57,8 +61,10 @@ discard block |
||
| 57 | 61 | public function getVisitors(int $stage): array |
| 58 | 62 | { |
| 59 | 63 | $visitors = []; |
| 60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
| 61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
| 64 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor) |
|
| 65 | + { |
|
| 66 | + if (\is_object($visitor) && !$visitor instanceof Autowire) |
|
| 67 | + { |
|
| 62 | 68 | $visitors[] = $visitor; |
| 63 | 69 | continue; |
| 64 | 70 | } |
@@ -74,11 +80,13 @@ discard block |
||
| 74 | 80 | */ |
| 75 | 81 | private function wire(mixed $item): Autowire |
| 76 | 82 | { |
| 77 | - if ($item instanceof Autowire) { |
|
| 83 | + if ($item instanceof Autowire) |
|
| 84 | + { |
|
| 78 | 85 | return $item; |
| 79 | 86 | } |
| 80 | 87 | |
| 81 | - if (\is_string($item)) { |
|
| 88 | + if (\is_string($item)) |
|
| 89 | + { |
|
| 82 | 90 | return new Autowire($item); |
| 83 | 91 | } |
| 84 | 92 | |
@@ -29,35 +29,35 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
| 31 | 31 | { |
| 32 | - if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) { |
|
| 32 | + if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag){ |
|
| 33 | 33 | return null; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) { |
|
| 36 | + if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)){ |
|
| 37 | 37 | // raw nodes |
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $level = $this->getLevel($ctx); |
| 42 | - if ($level === null) { |
|
| 42 | + if ($level === null){ |
|
| 43 | 43 | // not available in some contexts |
| 44 | 44 | return null; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - foreach ($node->nodes as $i => $child) { |
|
| 48 | - if (!$child instanceof Raw) { |
|
| 47 | + foreach ($node->nodes as $i => $child){ |
|
| 48 | + if (!$child instanceof Raw){ |
|
| 49 | 49 | continue; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $position = self::BETWEEN_TAGS; |
| 53 | - if (!isset($node->nodes[$i + 1])) { |
|
| 53 | + if (!isset($node->nodes[$i + 1])){ |
|
| 54 | 54 | $position = self::BEFORE_CLOSE; |
| 55 | - } elseif ($node->nodes[$i + 1] instanceof PHP) { |
|
| 55 | + } elseif ($node->nodes[$i + 1] instanceof PHP){ |
|
| 56 | 56 | $position = self::BEFORE_PHP; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $child->content = $this->indentContent( |
| 60 | - $this->normalizeEndings((string) $child->content, false), |
|
| 60 | + $this->normalizeEndings((string)$child->content, false), |
|
| 61 | 61 | $level, |
| 62 | 62 | $position, |
| 63 | 63 | ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | private function indentContent(string $content, int $level, int $position = self::BETWEEN_TAGS): string |
| 75 | 75 | { |
| 76 | - if (!\str_contains($content, "\n")) { |
|
| 76 | + if (!\str_contains($content, "\n")){ |
|
| 77 | 77 | // no need to do anything |
| 78 | 78 | return $content; |
| 79 | 79 | } |
@@ -81,40 +81,40 @@ discard block |
||
| 81 | 81 | // we have to apply special rules to the first and the last lines |
| 82 | 82 | $lines = \explode("\n", $content); |
| 83 | 83 | |
| 84 | - foreach ($lines as $i => $line) { |
|
| 85 | - if (\trim($line) === '' && $i !== 0) { |
|
| 84 | + foreach ($lines as $i => $line){ |
|
| 85 | + if (\trim($line) === '' && $i !== 0){ |
|
| 86 | 86 | unset($lines[$i]); |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $lines = \array_values($lines); |
| 91 | - if ($lines === []) { |
|
| 91 | + if ($lines === []){ |
|
| 92 | 92 | $lines[] = ''; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $result = ''; |
| 96 | - foreach ($lines as $i => $line) { |
|
| 97 | - if (\trim($line) !== '') { |
|
| 96 | + foreach ($lines as $i => $line){ |
|
| 97 | + if (\trim($line) !== ''){ |
|
| 98 | 98 | $line = $i === 0 ? \rtrim($line) : \trim($line); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ($i !== (\count($lines) - 1)) { |
|
| 102 | - $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
|
| 101 | + if ($i !== (\count($lines) - 1)){ |
|
| 102 | + $result .= $line."\n".\str_repeat(self::INDENT, $level); |
|
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // working with last line |
| 107 | - if ($position === self::BEFORE_PHP) { |
|
| 108 | - $result .= $line . "\n"; |
|
| 107 | + if ($position === self::BEFORE_PHP){ |
|
| 108 | + $result .= $line."\n"; |
|
| 109 | 109 | break; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ($position === self::BEFORE_CLOSE) { |
|
| 113 | - $result .= $line . "\n" . \str_repeat(self::INDENT, \max($level - 1, 0)); |
|
| 112 | + if ($position === self::BEFORE_CLOSE){ |
|
| 113 | + $result .= $line."\n".\str_repeat(self::INDENT, \max($level - 1, 0)); |
|
| 114 | 114 | break; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
|
| 117 | + $result .= $line."\n".\str_repeat(self::INDENT, $level); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $result; |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | private function getLevel(VisitorContext $ctx): ?int |
| 124 | 124 | { |
| 125 | 125 | $level = 0; |
| 126 | - foreach ($ctx->getScope() as $node) { |
|
| 127 | - if ($node instanceof Attr) { |
|
| 126 | + foreach ($ctx->getScope() as $node){ |
|
| 127 | + if ($node instanceof Attr){ |
|
| 128 | 128 | return null; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ($node instanceof Block || $node instanceof Template) { |
|
| 131 | + if ($node instanceof Block || $node instanceof Template){ |
|
| 132 | 132 | continue; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | private function normalizeEndings(string $string, bool $joinMultiple = true): string |
| 149 | 149 | { |
| 150 | - if (!$joinMultiple) { |
|
| 150 | + if (!$joinMultiple){ |
|
| 151 | 151 | return \str_replace("\r\n", "\n", $string); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -29,30 +29,38 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
| 31 | 31 | { |
| 32 | - if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) { |
|
| 32 | + if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) |
|
| 33 | + { |
|
| 33 | 34 | return null; |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) { |
|
| 37 | + if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) |
|
| 38 | + { |
|
| 37 | 39 | // raw nodes |
| 38 | 40 | return null; |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | 43 | $level = $this->getLevel($ctx); |
| 42 | - if ($level === null) { |
|
| 44 | + if ($level === null) |
|
| 45 | + { |
|
| 43 | 46 | // not available in some contexts |
| 44 | 47 | return null; |
| 45 | 48 | } |
| 46 | 49 | |
| 47 | - foreach ($node->nodes as $i => $child) { |
|
| 48 | - if (!$child instanceof Raw) { |
|
| 50 | + foreach ($node->nodes as $i => $child) |
|
| 51 | + { |
|
| 52 | + if (!$child instanceof Raw) |
|
| 53 | + { |
|
| 49 | 54 | continue; |
| 50 | 55 | } |
| 51 | 56 | |
| 52 | 57 | $position = self::BETWEEN_TAGS; |
| 53 | - if (!isset($node->nodes[$i + 1])) { |
|
| 58 | + if (!isset($node->nodes[$i + 1])) |
|
| 59 | + { |
|
| 54 | 60 | $position = self::BEFORE_CLOSE; |
| 55 | - } elseif ($node->nodes[$i + 1] instanceof PHP) { |
|
| 61 | + } |
|
| 62 | + elseif ($node->nodes[$i + 1] instanceof PHP) |
|
| 63 | + { |
|
| 56 | 64 | $position = self::BEFORE_PHP; |
| 57 | 65 | } |
| 58 | 66 | |
@@ -73,7 +81,8 @@ discard block |
||
| 73 | 81 | |
| 74 | 82 | private function indentContent(string $content, int $level, int $position = self::BETWEEN_TAGS): string |
| 75 | 83 | { |
| 76 | - if (!\str_contains($content, "\n")) { |
|
| 84 | + if (!\str_contains($content, "\n")) |
|
| 85 | + { |
|
| 77 | 86 | // no need to do anything |
| 78 | 87 | return $content; |
| 79 | 88 | } |
@@ -81,35 +90,43 @@ discard block |
||
| 81 | 90 | // we have to apply special rules to the first and the last lines |
| 82 | 91 | $lines = \explode("\n", $content); |
| 83 | 92 | |
| 84 | - foreach ($lines as $i => $line) { |
|
| 85 | - if (\trim($line) === '' && $i !== 0) { |
|
| 93 | + foreach ($lines as $i => $line) |
|
| 94 | + { |
|
| 95 | + if (\trim($line) === '' && $i !== 0) |
|
| 96 | + { |
|
| 86 | 97 | unset($lines[$i]); |
| 87 | 98 | } |
| 88 | 99 | } |
| 89 | 100 | |
| 90 | 101 | $lines = \array_values($lines); |
| 91 | - if ($lines === []) { |
|
| 102 | + if ($lines === []) |
|
| 103 | + { |
|
| 92 | 104 | $lines[] = ''; |
| 93 | 105 | } |
| 94 | 106 | |
| 95 | 107 | $result = ''; |
| 96 | - foreach ($lines as $i => $line) { |
|
| 97 | - if (\trim($line) !== '') { |
|
| 108 | + foreach ($lines as $i => $line) |
|
| 109 | + { |
|
| 110 | + if (\trim($line) !== '') |
|
| 111 | + { |
|
| 98 | 112 | $line = $i === 0 ? \rtrim($line) : \trim($line); |
| 99 | 113 | } |
| 100 | 114 | |
| 101 | - if ($i !== (\count($lines) - 1)) { |
|
| 115 | + if ($i !== (\count($lines) - 1)) |
|
| 116 | + { |
|
| 102 | 117 | $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
| 103 | 118 | continue; |
| 104 | 119 | } |
| 105 | 120 | |
| 106 | 121 | // working with last line |
| 107 | - if ($position === self::BEFORE_PHP) { |
|
| 122 | + if ($position === self::BEFORE_PHP) |
|
| 123 | + { |
|
| 108 | 124 | $result .= $line . "\n"; |
| 109 | 125 | break; |
| 110 | 126 | } |
| 111 | 127 | |
| 112 | - if ($position === self::BEFORE_CLOSE) { |
|
| 128 | + if ($position === self::BEFORE_CLOSE) |
|
| 129 | + { |
|
| 113 | 130 | $result .= $line . "\n" . \str_repeat(self::INDENT, \max($level - 1, 0)); |
| 114 | 131 | break; |
| 115 | 132 | } |
@@ -123,12 +140,15 @@ discard block |
||
| 123 | 140 | private function getLevel(VisitorContext $ctx): ?int |
| 124 | 141 | { |
| 125 | 142 | $level = 0; |
| 126 | - foreach ($ctx->getScope() as $node) { |
|
| 127 | - if ($node instanceof Attr) { |
|
| 143 | + foreach ($ctx->getScope() as $node) |
|
| 144 | + { |
|
| 145 | + if ($node instanceof Attr) |
|
| 146 | + { |
|
| 128 | 147 | return null; |
| 129 | 148 | } |
| 130 | 149 | |
| 131 | - if ($node instanceof Block || $node instanceof Template) { |
|
| 150 | + if ($node instanceof Block || $node instanceof Template) |
|
| 151 | + { |
|
| 132 | 152 | continue; |
| 133 | 153 | } |
| 134 | 154 | |
@@ -147,7 +167,8 @@ discard block |
||
| 147 | 167 | */ |
| 148 | 168 | private function normalizeEndings(string $string, bool $joinMultiple = true): string |
| 149 | 169 | { |
| 150 | - if (!$joinMultiple) { |
|
| 170 | + if (!$joinMultiple) |
|
| 171 | + { |
|
| 151 | 172 | return \str_replace("\r\n", "\n", $string); |
| 152 | 173 | } |
| 153 | 174 | |
@@ -13,10 +13,10 @@ |
||
| 13 | 13 | |
| 14 | 14 | protected static function filter($v) |
| 15 | 15 | { |
| 16 | - if (\is_array($v)) { |
|
| 16 | + if (\is_array($v)){ |
|
| 17 | 17 | throw new RuntimeException("can't be array"); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - return (int) $v; |
|
| 20 | + return (int)$v; |
|
| 21 | 21 | } |
| 22 | 22 | } |
@@ -13,7 +13,8 @@ |
||
| 13 | 13 | |
| 14 | 14 | protected static function filter($v) |
| 15 | 15 | { |
| 16 | - if (\is_array($v)) { |
|
| 16 | + if (\is_array($v)) |
|
| 17 | + { |
|
| 17 | 18 | throw new RuntimeException("can't be array"); |
| 18 | 19 | } |
| 19 | 20 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $response = $this->get($core, '/'); |
| 39 | 39 | self::assertSame(200, $response->getStatusCode()); |
| 40 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 40 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function testSetEncryptedCookie(): void |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $response = $this->get($core, '/'); |
| 53 | 53 | self::assertSame(200, $response->getStatusCode()); |
| 54 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 54 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 55 | 55 | |
| 56 | 56 | $cookies = $this->fetchCookies($response); |
| 57 | 57 | self::assertArrayHasKey('name', $cookies); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $response = $this->get($core, '/'); |
| 71 | 71 | self::assertSame(200, $response->getStatusCode()); |
| 72 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 72 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 73 | 73 | |
| 74 | 74 | $cookies = $this->fetchCookies($response); |
| 75 | 75 | self::assertArrayHasKey('PHPSESSID', $cookies); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
| 87 | 87 | self::assertSame(200, $response->getStatusCode()); |
| 88 | - self::assertSame('cookie-value', (string) $response->getBody()); |
|
| 88 | + self::assertSame('cookie-value', (string)$response->getBody()); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function testDecryptArray(): void |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
| 99 | 99 | self::assertSame(200, $response->getStatusCode()); |
| 100 | - self::assertSame('cookie-value', (string) $response->getBody()); |
|
| 100 | + self::assertSame('cookie-value', (string)$response->getBody()); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function testDecryptBroken(): void |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 106 | 106 | $core->setHandler(static fn(ServerRequestInterface $r) => $r->getCookieParams()['name']); |
| 107 | 107 | |
| 108 | - $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN'; |
|
| 108 | + $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value').'BROKEN'; |
|
| 109 | 109 | |
| 110 | 110 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
| 111 | 111 | self::assertSame(200, $response->getStatusCode()); |
| 112 | - self::assertSame('', (string) $response->getBody()); |
|
| 112 | + self::assertSame('', (string)$response->getBody()); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | public function testDelete(): void |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $response = $this->get($core, '/'); |
| 126 | 126 | self::assertSame(200, $response->getStatusCode()); |
| 127 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 127 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 128 | 128 | |
| 129 | 129 | $cookies = $this->fetchCookies($response); |
| 130 | 130 | self::assertArrayHasKey('name', $cookies); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $response = $this->get($core, '/'); |
| 150 | 150 | self::assertSame(200, $response->getStatusCode()); |
| 151 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 151 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 152 | 152 | |
| 153 | 153 | $cookies = $this->fetchCookies($response); |
| 154 | 154 | self::assertArrayHasKey('name', $cookies); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
| 172 | 172 | self::assertSame(200, $response->getStatusCode()); |
| 173 | - self::assertSame('cookie-value', (string) $response->getBody()); |
|
| 173 | + self::assertSame('cookie-value', (string)$response->getBody()); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function testHMAC(): void |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $response = $this->get($core, '/'); |
| 192 | 192 | self::assertSame(200, $response->getStatusCode()); |
| 193 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 193 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 194 | 194 | |
| 195 | 195 | $cookies = $this->fetchCookies($response); |
| 196 | 196 | self::assertArrayHasKey('name', $cookies); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $response = $this->get($core, '/', [], [], $cookies); |
| 201 | 201 | self::assertSame(200, $response->getStatusCode()); |
| 202 | - self::assertSame('value', (string) $response->getBody()); |
|
| 202 | + self::assertSame('value', (string)$response->getBody()); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | protected function setUp(): void |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | $result = []; |
| 272 | 272 | |
| 273 | - foreach ($response->getHeaders() as $line) { |
|
| 273 | + foreach ($response->getHeaders() as $line){ |
|
| 274 | 274 | $cookie = \explode('=', \implode('', $line)); |
| 275 | 275 | $result[$cookie[0]] = \rawurldecode(\substr( |
| 276 | 276 | $cookie[1], |
| 277 | 277 | 0, |
| 278 | - (int) \strpos($cookie[1], ';'), |
|
| 278 | + (int)\strpos($cookie[1], ';'), |
|
| 279 | 279 | )); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -270,7 +270,8 @@ |
||
| 270 | 270 | { |
| 271 | 271 | $result = []; |
| 272 | 272 | |
| 273 | - foreach ($response->getHeaders() as $line) { |
|
| 273 | + foreach ($response->getHeaders() as $line) |
|
| 274 | + { |
|
| 274 | 275 | $cookie = \explode('=', \implode('', $line)); |
| 275 | 276 | $result[$cookie[0]] = \rawurldecode(\substr( |
| 276 | 277 | $cookie[1], |
@@ -41,22 +41,22 @@ |
||
| 41 | 41 | public function resolveDomain(UriInterface $uri): ?string |
| 42 | 42 | { |
| 43 | 43 | $host = $uri->getHost(); |
| 44 | - if (empty($host)) { |
|
| 44 | + if (empty($host)){ |
|
| 45 | 45 | return null; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $pattern = $this->config['domain']; |
| 49 | - if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) { |
|
| 49 | + if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)){ |
|
| 50 | 50 | // remove port |
| 51 | 51 | $host = $matches[1]; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 54 | + if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)){ |
|
| 55 | 55 | //We can't use sub-domains when website required by IP |
| 56 | - $pattern = \ltrim((string) $pattern, '.'); |
|
| 56 | + $pattern = \ltrim((string)$pattern, '.'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if (!\str_contains((string) $pattern, '%s')) { |
|
| 59 | + if (!\str_contains((string)$pattern, '%s')){ |
|
| 60 | 60 | //Forced domain |
| 61 | 61 | return $pattern; |
| 62 | 62 | } |
@@ -41,22 +41,26 @@ |
||
| 41 | 41 | public function resolveDomain(UriInterface $uri): ?string |
| 42 | 42 | { |
| 43 | 43 | $host = $uri->getHost(); |
| 44 | - if (empty($host)) { |
|
| 44 | + if (empty($host)) |
|
| 45 | + { |
|
| 45 | 46 | return null; |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | $pattern = $this->config['domain']; |
| 49 | - if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) { |
|
| 50 | + if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) |
|
| 51 | + { |
|
| 50 | 52 | // remove port |
| 51 | 53 | $host = $matches[1]; |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | - if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) { |
|
| 56 | + if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) |
|
| 57 | + { |
|
| 55 | 58 | //We can't use sub-domains when website required by IP |
| 56 | 59 | $pattern = \ltrim((string) $pattern, '.'); |
| 57 | 60 | } |
| 58 | 61 | |
| 59 | - if (!\str_contains((string) $pattern, '%s')) { |
|
| 62 | + if (!\str_contains((string) $pattern, '%s')) |
|
| 63 | + { |
|
| 60 | 64 | //Forced domain |
| 61 | 65 | return $pattern; |
| 62 | 66 | } |
@@ -2,4 +2,4 @@ |
||
| 2 | 2 | |
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | -return ; |
|
| 5 | +return; |
|
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | |
| 26 | 26 | protected function getFactory(?string $directory = null, bool $strict = true): ConfigManager |
| 27 | 27 | { |
| 28 | - if (\is_null($directory)) { |
|
| 29 | - $directory = __DIR__ . '/fixtures'; |
|
| 28 | + if (\is_null($directory)){ |
|
| 29 | + $directory = __DIR__.'/fixtures'; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return new ConfigManager( |
@@ -25,7 +25,8 @@ |
||
| 25 | 25 | |
| 26 | 26 | protected function getFactory(?string $directory = null, bool $strict = true): ConfigManager |
| 27 | 27 | { |
| 28 | - if (\is_null($directory)) { |
|
| 28 | + if (\is_null($directory)) |
|
| 29 | + { |
|
| 29 | 30 | $directory = __DIR__ . '/fixtures'; |
| 30 | 31 | } |
| 31 | 32 | |