@@ -63,21 +63,21 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | $namespace = $this->defaultNamespace; |
66 | - if (strpos($filename, '.') === false) { |
|
66 | + if (strpos($filename, '.') === false){ |
|
67 | 67 | //Force default extension |
68 | - $filename .= '.' . $this->extension; |
|
69 | - } elseif (!$this->match($filename)) { |
|
68 | + $filename .= '.'.$this->extension; |
|
69 | + } elseif (!$this->match($filename)){ |
|
70 | 70 | return null; |
71 | 71 | } |
72 | 72 | |
73 | - if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false) { |
|
73 | + if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false){ |
|
74 | 74 | [$namespace, $filename] = explode(LoaderInterface::NS_SEPARATOR, $filename); |
75 | 75 | } |
76 | 76 | |
77 | 77 | //Twig like namespaces |
78 | - if (isset($filename[0]) && $filename[0] == '@') { |
|
78 | + if (isset($filename[0]) && $filename[0] == '@'){ |
|
79 | 79 | $separator = strpos($filename, '/'); |
80 | - if ($separator === false) { |
|
80 | + if ($separator === false){ |
|
81 | 81 | throw new PathException(sprintf('Malformed view path"%s" (expecting "@namespace/name").', $path)); |
82 | 82 | } |
83 | 83 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function validatePath(string $path): void |
109 | 109 | { |
110 | - if (empty($path)) { |
|
110 | + if (empty($path)){ |
|
111 | 111 | throw new PathException('A view path is empty'); |
112 | 112 | } |
113 | 113 | |
114 | - if (false !== strpos($path, "\0")) { |
|
114 | + if (false !== strpos($path, "\0")){ |
|
115 | 115 | throw new PathException('A view path cannot contain NUL bytes'); |
116 | 116 | } |
117 | 117 | |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | $parts = explode('/', $path); |
120 | 120 | $level = 0; |
121 | 121 | |
122 | - foreach ($parts as $part) { |
|
123 | - if ('..' === $part) { |
|
122 | + foreach ($parts as $part){ |
|
123 | + if ('..' === $part){ |
|
124 | 124 | --$level; |
125 | - } elseif ('.' !== $part) { |
|
125 | + } elseif ('.' !== $part){ |
|
126 | 126 | ++$level; |
127 | 127 | } |
128 | 128 | |
129 | - if ($level < 0) { |
|
129 | + if ($level < 0){ |
|
130 | 130 | throw new PathException(sprintf( |
131 | 131 | 'Looks like you try to load a view outside configured directories (%s)', |
132 | 132 | $path |
@@ -63,21 +63,27 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | $namespace = $this->defaultNamespace; |
66 | - if (strpos($filename, '.') === false) { |
|
66 | + if (strpos($filename, '.') === false) |
|
67 | + { |
|
67 | 68 | //Force default extension |
68 | 69 | $filename .= '.' . $this->extension; |
69 | - } elseif (!$this->match($filename)) { |
|
70 | + } |
|
71 | + elseif (!$this->match($filename)) |
|
72 | + { |
|
70 | 73 | return null; |
71 | 74 | } |
72 | 75 | |
73 | - if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false) { |
|
76 | + if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false) |
|
77 | + { |
|
74 | 78 | [$namespace, $filename] = explode(LoaderInterface::NS_SEPARATOR, $filename); |
75 | 79 | } |
76 | 80 | |
77 | 81 | //Twig like namespaces |
78 | - if (isset($filename[0]) && $filename[0] == '@') { |
|
82 | + if (isset($filename[0]) && $filename[0] == '@') |
|
83 | + { |
|
79 | 84 | $separator = strpos($filename, '/'); |
80 | - if ($separator === false) { |
|
85 | + if ($separator === false) |
|
86 | + { |
|
81 | 87 | throw new PathException(sprintf('Malformed view path"%s" (expecting "@namespace/name").', $path)); |
82 | 88 | } |
83 | 89 | |
@@ -107,11 +113,13 @@ discard block |
||
107 | 113 | */ |
108 | 114 | private function validatePath(string $path): void |
109 | 115 | { |
110 | - if (empty($path)) { |
|
116 | + if (empty($path)) |
|
117 | + { |
|
111 | 118 | throw new PathException('A view path is empty'); |
112 | 119 | } |
113 | 120 | |
114 | - if (false !== strpos($path, "\0")) { |
|
121 | + if (false !== strpos($path, "\0")) |
|
122 | + { |
|
115 | 123 | throw new PathException('A view path cannot contain NUL bytes'); |
116 | 124 | } |
117 | 125 | |
@@ -119,14 +127,19 @@ discard block |
||
119 | 127 | $parts = explode('/', $path); |
120 | 128 | $level = 0; |
121 | 129 | |
122 | - foreach ($parts as $part) { |
|
123 | - if ('..' === $part) { |
|
130 | + foreach ($parts as $part) |
|
131 | + { |
|
132 | + if ('..' === $part) |
|
133 | + { |
|
124 | 134 | --$level; |
125 | - } elseif ('.' !== $part) { |
|
135 | + } |
|
136 | + elseif ('.' !== $part) |
|
137 | + { |
|
126 | 138 | ++$level; |
127 | 139 | } |
128 | 140 | |
129 | - if ($level < 0) { |
|
141 | + if ($level < 0) |
|
142 | + { |
|
130 | 143 | throw new PathException(sprintf( |
131 | 144 | 'Looks like you try to load a view outside configured directories (%s)', |
132 | 145 | $path |
@@ -50,22 +50,22 @@ |
||
50 | 50 | */ |
51 | 51 | private function rotate(ContextInterface $context, array $dependencies): array |
52 | 52 | { |
53 | - if (empty($dependencies)) { |
|
53 | + if (empty($dependencies)){ |
|
54 | 54 | return []; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $top = \array_shift($dependencies); |
58 | 58 | |
59 | 59 | $variants = []; |
60 | - foreach ($top->getVariants() as $value) { |
|
60 | + foreach ($top->getVariants() as $value){ |
|
61 | 61 | $variant = $context->withDependency(new ValueDependency($top->getName(), $value)); |
62 | 62 | |
63 | - if (empty($dependencies)) { |
|
63 | + if (empty($dependencies)){ |
|
64 | 64 | $variants[] = $variant; |
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | |
68 | - foreach ($this->rotate($variant, $dependencies) as $inner) { |
|
68 | + foreach ($this->rotate($variant, $dependencies) as $inner){ |
|
69 | 69 | $variants[] = $inner; |
70 | 70 | } |
71 | 71 | } |
@@ -50,22 +50,26 @@ |
||
50 | 50 | */ |
51 | 51 | private function rotate(ContextInterface $context, array $dependencies): array |
52 | 52 | { |
53 | - if (empty($dependencies)) { |
|
53 | + if (empty($dependencies)) |
|
54 | + { |
|
54 | 55 | return []; |
55 | 56 | } |
56 | 57 | |
57 | 58 | $top = \array_shift($dependencies); |
58 | 59 | |
59 | 60 | $variants = []; |
60 | - foreach ($top->getVariants() as $value) { |
|
61 | + foreach ($top->getVariants() as $value) |
|
62 | + { |
|
61 | 63 | $variant = $context->withDependency(new ValueDependency($top->getName(), $value)); |
62 | 64 | |
63 | - if (empty($dependencies)) { |
|
65 | + if (empty($dependencies)) |
|
66 | + { |
|
64 | 67 | $variants[] = $variant; |
65 | 68 | continue; |
66 | 69 | } |
67 | 70 | |
68 | - foreach ($this->rotate($variant, $dependencies) as $inner) { |
|
71 | + foreach ($this->rotate($variant, $dependencies) as $inner) |
|
72 | + { |
|
69 | 73 | $variants[] = $inner; |
70 | 74 | } |
71 | 75 | } |
@@ -57,7 +57,8 @@ discard block |
||
57 | 57 | |
58 | 58 | public function getExtension(): ?string |
59 | 59 | { |
60 | - if ($this->parser !== null) { |
|
60 | + if ($this->parser !== null) |
|
61 | + { |
|
61 | 62 | return $this->parser->getExtension(); |
62 | 63 | } |
63 | 64 | |
@@ -69,22 +70,27 @@ discard block |
||
69 | 70 | */ |
70 | 71 | public function exists(string $path, string &$filename = null, ViewPath &$parsed = null): bool |
71 | 72 | { |
72 | - if (empty($this->parser)) { |
|
73 | + if (empty($this->parser)) |
|
74 | + { |
|
73 | 75 | throw new LoaderException('Unable to locate view source, no extension has been associated.'); |
74 | 76 | } |
75 | 77 | |
76 | 78 | $parsed = $this->parser->parse($path); |
77 | - if (empty($parsed)) { |
|
79 | + if (empty($parsed)) |
|
80 | + { |
|
78 | 81 | return false; |
79 | 82 | } |
80 | 83 | |
81 | - if (!isset($this->namespaces[$parsed->getNamespace()])) { |
|
84 | + if (!isset($this->namespaces[$parsed->getNamespace()])) |
|
85 | + { |
|
82 | 86 | return false; |
83 | 87 | } |
84 | 88 | |
85 | - foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) { |
|
89 | + foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) |
|
90 | + { |
|
86 | 91 | $directory = $this->files->normalizePath($directory, true); |
87 | - if ($this->files->exists(sprintf('%s%s', $directory, $parsed->getBasename()))) { |
|
92 | + if ($this->files->exists(sprintf('%s%s', $directory, $parsed->getBasename()))) |
|
93 | + { |
|
88 | 94 | $filename = sprintf('%s%s', $directory, $parsed->getBasename()); |
89 | 95 | |
90 | 96 | return true; |
@@ -99,7 +105,8 @@ discard block |
||
99 | 105 | */ |
100 | 106 | public function load(string $path): ViewSource |
101 | 107 | { |
102 | - if (!$this->exists($path, $filename, $parsed)) { |
|
108 | + if (!$this->exists($path, $filename, $parsed)) |
|
109 | + { |
|
103 | 110 | throw new LoaderException("Unable to load view `$path`, file does not exists."); |
104 | 111 | } |
105 | 112 | |
@@ -112,21 +119,27 @@ discard block |
||
112 | 119 | */ |
113 | 120 | public function list(string $namespace = null): array |
114 | 121 | { |
115 | - if (empty($this->parser)) { |
|
122 | + if (empty($this->parser)) |
|
123 | + { |
|
116 | 124 | throw new LoaderException('Unable to list view sources, no extension has been associated.'); |
117 | 125 | } |
118 | 126 | |
119 | 127 | $result = []; |
120 | - foreach ($this->namespaces as $ns => $directories) { |
|
121 | - if (!empty($namespace) && $namespace != $ns) { |
|
128 | + foreach ($this->namespaces as $ns => $directories) |
|
129 | + { |
|
130 | + if (!empty($namespace) && $namespace != $ns) |
|
131 | + { |
|
122 | 132 | continue; |
123 | 133 | } |
124 | 134 | |
125 | - foreach ((array)$directories as $directory) { |
|
135 | + foreach ((array)$directories as $directory) |
|
136 | + { |
|
126 | 137 | $files = $this->files->getFiles($directory); |
127 | 138 | |
128 | - foreach ($files as $filename) { |
|
129 | - if (!$this->parser->match($filename)) { |
|
139 | + foreach ($files as $filename) |
|
140 | + { |
|
141 | + if (!$this->parser->match($filename)) |
|
142 | + { |
|
130 | 143 | // does not belong to this loader |
131 | 144 | continue; |
132 | 145 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | array $namespaces, |
39 | 39 | FilesInterface $files = null, |
40 | 40 | string $defaultNamespace = self::DEFAULT_NAMESPACE |
41 | - ) { |
|
41 | + ){ |
|
42 | 42 | $this->namespaces = $namespaces; |
43 | 43 | $this->files = $files ?? new Files(); |
44 | 44 | $this->defaultNamespace = $defaultNamespace; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function getExtension(): ?string |
59 | 59 | { |
60 | - if ($this->parser !== null) { |
|
60 | + if ($this->parser !== null){ |
|
61 | 61 | return $this->parser->getExtension(); |
62 | 62 | } |
63 | 63 | |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * {@inheritdoc} |
69 | 69 | */ |
70 | - public function exists(string $path, string &$filename = null, ViewPath &$parsed = null): bool |
|
70 | + public function exists(string $path, string &$filename = null, ViewPath & $parsed = null): bool |
|
71 | 71 | { |
72 | - if (empty($this->parser)) { |
|
72 | + if (empty($this->parser)){ |
|
73 | 73 | throw new LoaderException('Unable to locate view source, no extension has been associated.'); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $parsed = $this->parser->parse($path); |
77 | - if (empty($parsed)) { |
|
77 | + if (empty($parsed)){ |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if (!isset($this->namespaces[$parsed->getNamespace()])) { |
|
81 | + if (!isset($this->namespaces[$parsed->getNamespace()])){ |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | - foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) { |
|
85 | + foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory){ |
|
86 | 86 | $directory = $this->files->normalizePath($directory, true); |
87 | - if ($this->files->exists(sprintf('%s%s', $directory, $parsed->getBasename()))) { |
|
87 | + if ($this->files->exists(sprintf('%s%s', $directory, $parsed->getBasename()))){ |
|
88 | 88 | $filename = sprintf('%s%s', $directory, $parsed->getBasename()); |
89 | 89 | |
90 | 90 | return true; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function load(string $path): ViewSource |
101 | 101 | { |
102 | - if (!$this->exists($path, $filename, $parsed)) { |
|
102 | + if (!$this->exists($path, $filename, $parsed)){ |
|
103 | 103 | throw new LoaderException("Unable to load view `$path`, file does not exists."); |
104 | 104 | } |
105 | 105 | |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function list(string $namespace = null): array |
114 | 114 | { |
115 | - if (empty($this->parser)) { |
|
115 | + if (empty($this->parser)){ |
|
116 | 116 | throw new LoaderException('Unable to list view sources, no extension has been associated.'); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $result = []; |
120 | - foreach ($this->namespaces as $ns => $directories) { |
|
121 | - if (!empty($namespace) && $namespace != $ns) { |
|
120 | + foreach ($this->namespaces as $ns => $directories){ |
|
121 | + if (!empty($namespace) && $namespace != $ns){ |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | - foreach ((array)$directories as $directory) { |
|
125 | + foreach ((array)$directories as $directory){ |
|
126 | 126 | $files = $this->files->getFiles($directory); |
127 | 127 | |
128 | - foreach ($files as $filename) { |
|
129 | - if (!$this->parser->match($filename)) { |
|
128 | + foreach ($files as $filename){ |
|
129 | + if (!$this->parser->match($filename)){ |
|
130 | 130 | // does not belong to this loader |
131 | 131 | continue; |
132 | 132 | } |
@@ -79,35 +79,35 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function configureExtensions(ConsoleBootloader $console, Container $container): void |
81 | 81 | { |
82 | - if ($container->has(DatabaseProviderInterface::class)) { |
|
82 | + if ($container->has(DatabaseProviderInterface::class)){ |
|
83 | 83 | $this->configureDatabase($console); |
84 | 84 | } |
85 | 85 | |
86 | - if ($container->has(ORMInterface::class)) { |
|
86 | + if ($container->has(ORMInterface::class)){ |
|
87 | 87 | $this->configureCycle($console, $container); |
88 | 88 | } |
89 | 89 | |
90 | - if ($container->has(TranslatorInterface::class)) { |
|
90 | + if ($container->has(TranslatorInterface::class)){ |
|
91 | 91 | $this->configureTranslator($console); |
92 | 92 | } |
93 | 93 | |
94 | - if ($container->has(ViewsInterface::class)) { |
|
94 | + if ($container->has(ViewsInterface::class)){ |
|
95 | 95 | $this->configureViews($console); |
96 | 96 | } |
97 | 97 | |
98 | - if ($container->has(Migrator::class)) { |
|
98 | + if ($container->has(Migrator::class)){ |
|
99 | 99 | $this->configureMigrations($console); |
100 | 100 | } |
101 | 101 | |
102 | - if ($container->has(InvokerInterface::class)) { |
|
102 | + if ($container->has(InvokerInterface::class)){ |
|
103 | 103 | $this->configureGRPC($console); |
104 | 104 | } |
105 | 105 | |
106 | - if ($container->has(EncryptionInterface::class)) { |
|
106 | + if ($container->has(EncryptionInterface::class)){ |
|
107 | 107 | $this->configureEncrypter($console); |
108 | 108 | } |
109 | 109 | |
110 | - if ($container->has(RouterInterface::class)) { |
|
110 | + if ($container->has(RouterInterface::class)){ |
|
111 | 111 | $console->addCommand(Router\ListCommand::class); |
112 | 112 | } |
113 | 113 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $console->addCommand(Cycle\SyncCommand::class, true); |
139 | 139 | |
140 | - if ($container->has(Migrator::class)) { |
|
140 | + if ($container->has(Migrator::class)){ |
|
141 | 141 | $console->addCommand(Cycle\MigrateCommand::class, true); |
142 | 142 | } |
143 | 143 | } |
@@ -79,35 +79,43 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function configureExtensions(ConsoleBootloader $console, Container $container): void |
81 | 81 | { |
82 | - if ($container->has(DatabaseProviderInterface::class)) { |
|
82 | + if ($container->has(DatabaseProviderInterface::class)) |
|
83 | + { |
|
83 | 84 | $this->configureDatabase($console); |
84 | 85 | } |
85 | 86 | |
86 | - if ($container->has(ORMInterface::class)) { |
|
87 | + if ($container->has(ORMInterface::class)) |
|
88 | + { |
|
87 | 89 | $this->configureCycle($console, $container); |
88 | 90 | } |
89 | 91 | |
90 | - if ($container->has(TranslatorInterface::class)) { |
|
92 | + if ($container->has(TranslatorInterface::class)) |
|
93 | + { |
|
91 | 94 | $this->configureTranslator($console); |
92 | 95 | } |
93 | 96 | |
94 | - if ($container->has(ViewsInterface::class)) { |
|
97 | + if ($container->has(ViewsInterface::class)) |
|
98 | + { |
|
95 | 99 | $this->configureViews($console); |
96 | 100 | } |
97 | 101 | |
98 | - if ($container->has(Migrator::class)) { |
|
102 | + if ($container->has(Migrator::class)) |
|
103 | + { |
|
99 | 104 | $this->configureMigrations($console); |
100 | 105 | } |
101 | 106 | |
102 | - if ($container->has(InvokerInterface::class)) { |
|
107 | + if ($container->has(InvokerInterface::class)) |
|
108 | + { |
|
103 | 109 | $this->configureGRPC($console); |
104 | 110 | } |
105 | 111 | |
106 | - if ($container->has(EncryptionInterface::class)) { |
|
112 | + if ($container->has(EncryptionInterface::class)) |
|
113 | + { |
|
107 | 114 | $this->configureEncrypter($console); |
108 | 115 | } |
109 | 116 | |
110 | - if ($container->has(RouterInterface::class)) { |
|
117 | + if ($container->has(RouterInterface::class)) |
|
118 | + { |
|
111 | 119 | $console->addCommand(Router\ListCommand::class); |
112 | 120 | } |
113 | 121 | } |
@@ -137,7 +145,8 @@ discard block |
||
137 | 145 | |
138 | 146 | $console->addCommand(Cycle\SyncCommand::class, true); |
139 | 147 | |
140 | - if ($container->has(Migrator::class)) { |
|
148 | + if ($container->has(Migrator::class)) |
|
149 | + { |
|
141 | 150 | $console->addCommand(Cycle\MigrateCommand::class, true); |
142 | 151 | } |
143 | 152 | } |
@@ -43,10 +43,10 @@ |
||
43 | 43 | $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll(); |
44 | 44 | |
45 | 45 | $response = $this->responseFactory->createResponse($code); |
46 | - if ($acceptItems && $acceptItems[0]->getValue() === 'application/json') { |
|
46 | + if ($acceptItems && $acceptItems[0]->getValue() === 'application/json'){ |
|
47 | 47 | $response = $response->withHeader('Content-Type', 'application/json; charset=UTF-8'); |
48 | 48 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
49 | - } else { |
|
49 | + }else{ |
|
50 | 50 | $response->getBody()->write("Error code: {$code}"); |
51 | 51 | } |
52 | 52 |
@@ -43,10 +43,13 @@ |
||
43 | 43 | $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll(); |
44 | 44 | |
45 | 45 | $response = $this->responseFactory->createResponse($code); |
46 | - if ($acceptItems && $acceptItems[0]->getValue() === 'application/json') { |
|
46 | + if ($acceptItems && $acceptItems[0]->getValue() === 'application/json') |
|
47 | + { |
|
47 | 48 | $response = $response->withHeader('Content-Type', 'application/json; charset=UTF-8'); |
48 | 49 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
49 | - } else { |
|
50 | + } |
|
51 | + else |
|
52 | + { |
|
50 | 53 | $response->getBody()->write("Error code: {$code}"); |
51 | 54 | } |
52 | 55 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | EnvironmentInterface $env, |
52 | 52 | ContainerInterface $container, |
53 | 53 | FinalizerInterface $finalizer |
54 | - ) { |
|
54 | + ){ |
|
55 | 55 | $this->env = $env; |
56 | 56 | $this->container = $container; |
57 | 57 | $this->finalizer = $finalizer; |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | 78 | |
79 | - while ($request = $worker->waitRequest()) { |
|
80 | - try { |
|
79 | + while ($request = $worker->waitRequest()){ |
|
80 | + try{ |
|
81 | 81 | $response = $http->handle($request); |
82 | 82 | |
83 | 83 | $worker->respond($response); |
84 | - } catch (\Throwable $e) { |
|
84 | + }catch (\Throwable $e){ |
|
85 | 85 | $worker->respond($this->errorToResponse($e)); |
86 | - } finally { |
|
86 | + }finally{ |
|
87 | 87 | $this->finalizer->finalize(false); |
88 | 88 | } |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | $handler = new HtmlHandler(); |
99 | 99 | |
100 | - try { |
|
100 | + try{ |
|
101 | 101 | /** @var SnapshotInterface $snapshot */ |
102 | 102 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
103 | 103 | \file_put_contents('php://stderr', $snapshot->getMessage()); |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | // on demand |
106 | 106 | $state = $this->container->get(StateInterface::class); |
107 | 107 | |
108 | - if ($state !== null) { |
|
108 | + if ($state !== null){ |
|
109 | 109 | $handler = $handler->withState($state); |
110 | 110 | } |
111 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
111 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
112 | 112 | \file_put_contents('php://stderr', (string)$e); |
113 | 113 | } |
114 | 114 |
@@ -76,14 +76,20 @@ discard block |
||
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | 78 | |
79 | - while ($request = $worker->waitRequest()) { |
|
80 | - try { |
|
79 | + while ($request = $worker->waitRequest()) |
|
80 | + { |
|
81 | + try |
|
82 | + { |
|
81 | 83 | $response = $http->handle($request); |
82 | 84 | |
83 | 85 | $worker->respond($response); |
84 | - } catch (\Throwable $e) { |
|
86 | + } |
|
87 | + catch (\Throwable $e) |
|
88 | + { |
|
85 | 89 | $worker->respond($this->errorToResponse($e)); |
86 | - } finally { |
|
90 | + } |
|
91 | + finally |
|
92 | + { |
|
87 | 93 | $this->finalizer->finalize(false); |
88 | 94 | } |
89 | 95 | } |
@@ -97,7 +103,8 @@ discard block |
||
97 | 103 | { |
98 | 104 | $handler = new HtmlHandler(); |
99 | 105 | |
100 | - try { |
|
106 | + try |
|
107 | + { |
|
101 | 108 | /** @var SnapshotInterface $snapshot */ |
102 | 109 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
103 | 110 | \file_put_contents('php://stderr', $snapshot->getMessage()); |
@@ -105,10 +112,13 @@ discard block |
||
105 | 112 | // on demand |
106 | 113 | $state = $this->container->get(StateInterface::class); |
107 | 114 | |
108 | - if ($state !== null) { |
|
115 | + if ($state !== null) |
|
116 | + { |
|
109 | 117 | $handler = $handler->withState($state); |
110 | 118 | } |
111 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
119 | + } |
|
120 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
121 | + { |
|
112 | 122 | \file_put_contents('php://stderr', (string)$e); |
113 | 123 | } |
114 | 124 |
@@ -17,10 +17,10 @@ |
||
17 | 17 | { |
18 | 18 | protected function concat(string $file, ?string $prefix): string |
19 | 19 | { |
20 | - if ($prefix === null) { |
|
20 | + if ($prefix === null){ |
|
21 | 21 | return $file; |
22 | 22 | } |
23 | 23 | |
24 | - return \trim($prefix, '/') . '/' . \trim($file, '/'); |
|
24 | + return \trim($prefix, '/').'/'.\trim($file, '/'); |
|
25 | 25 | } |
26 | 26 | } |
@@ -17,7 +17,8 @@ |
||
17 | 17 | { |
18 | 18 | protected function concat(string $file, ?string $prefix): string |
19 | 19 | { |
20 | - if ($prefix === null) { |
|
20 | + if ($prefix === null) |
|
21 | + { |
|
21 | 22 | return $file; |
22 | 23 | } |
23 | 24 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | protected function assertCloudFrontAvailable(): void |
75 | 75 | { |
76 | - if (\class_exists(UrlSigner::class)) { |
|
76 | + if (\class_exists(UrlSigner::class)){ |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 |
@@ -73,7 +73,8 @@ |
||
73 | 73 | |
74 | 74 | protected function assertCloudFrontAvailable(): void |
75 | 75 | { |
76 | - if (\class_exists(UrlSigner::class)) { |
|
76 | + if (\class_exists(UrlSigner::class)) |
|
77 | + { |
|
77 | 78 | return; |
78 | 79 | } |
79 | 80 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @var string |
22 | 22 | */ |
23 | 23 | private const ERROR_NOT_AVAILABLE = |
24 | - 'The "aws/aws-sdk-php" package is supplied with the Guzzle PSR-7 ' . |
|
25 | - 'implementation, but it is not available. Please install the ' . |
|
24 | + 'The "aws/aws-sdk-php" package is supplied with the Guzzle PSR-7 '. |
|
25 | + 'implementation, but it is not available. Please install the '. |
|
26 | 26 | '"aws/aws-sdk-php" package or use any other implementation of PSR-17 factories.' |
27 | 27 | ; |
28 | 28 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | private function assertAvailable(): void |
43 | 43 | { |
44 | - if (\class_exists(Uri::class)) { |
|
44 | + if (\class_exists(Uri::class)){ |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 |
@@ -41,7 +41,8 @@ |
||
41 | 41 | |
42 | 42 | private function assertAvailable(): void |
43 | 43 | { |
44 | - if (\class_exists(Uri::class)) { |
|
44 | + if (\class_exists(Uri::class)) |
|
45 | + { |
|
45 | 46 | return; |
46 | 47 | } |
47 | 48 |