@@ -22,8 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | private FooEvent $ev; |
| 24 | 24 | private AutowireListenerFactory $factory; |
| 25 | - private ContainerInterface|MockInterface $container; |
|
| 26 | - private ClassAndMethodAttribute|MockInterface $listener; |
|
| 25 | + private ContainerInterface | MockInterface $container; |
|
| 26 | + private ClassAndMethodAttribute | MockInterface $listener; |
|
| 27 | 27 | |
| 28 | 28 | protected function setUp(): void |
| 29 | 29 | { |
@@ -60,7 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public function testMiddlewareProcessingEventShouldBeDispatched(): void |
| 62 | 62 | { |
| 63 | - $middleware = new class implements MiddlewareInterface { |
|
| 63 | + $middleware = new class implements MiddlewareInterface |
|
| 64 | + { |
|
| 64 | 65 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 65 | 66 | { |
| 66 | 67 | return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200); |
@@ -89,7 +90,8 @@ discard block |
||
| 89 | 90 | $this->container->getBinder('http') |
| 90 | 91 | ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr) => $cr->get()); |
| 91 | 92 | |
| 92 | - $middleware = new class implements MiddlewareInterface { |
|
| 93 | + $middleware = new class implements MiddlewareInterface |
|
| 94 | + { |
|
| 93 | 95 | public function process( |
| 94 | 96 | ServerRequestInterface $request, |
| 95 | 97 | RequestHandlerInterface $handler, |
@@ -33,11 +33,11 @@ |
||
| 33 | 33 | SampleBootWithMethodBoot::class, |
| 34 | 34 | SampleBoot::class, |
| 35 | 35 | ], [ |
| 36 | - static function(Container $container, SampleBoot $boot): void { |
|
| 36 | + static function (Container $container, SampleBoot $boot): void { |
|
| 37 | 37 | $container->bind('efg', $boot); |
| 38 | 38 | } |
| 39 | 39 | ], [ |
| 40 | - static function(Container $container, SampleBoot $boot): void { |
|
| 40 | + static function (Container $container, SampleBoot $boot): void { |
|
| 41 | 41 | $container->bind('ghi', $boot); |
| 42 | 42 | } |
| 43 | 43 | ]); |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | SampleBootWithMethodBoot::class, |
| 27 | 27 | SampleBoot::class, |
| 28 | 28 | ], [ |
| 29 | - static function(Container $container, SampleBoot $boot): void { |
|
| 29 | + static function (Container $container, SampleBoot $boot): void { |
|
| 30 | 30 | $container->bind('efg', $boot); |
| 31 | 31 | } |
| 32 | 32 | ], [ |
| 33 | - static function(Container $container, SampleBoot $boot): void { |
|
| 33 | + static function (Container $container, SampleBoot $boot): void { |
|
| 34 | 34 | $container->bind('ghi', $boot); |
| 35 | 35 | } |
| 36 | 36 | ]); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $bootloader = $this->getBootloadManager(); |
| 82 | 82 | |
| 83 | 83 | $bootloader->bootload([ |
| 84 | - new class () extends Bootloader { |
|
| 84 | + new class () extends Bootloader{ |
|
| 85 | 85 | public const BINDINGS = ['abc' => self::class]; |
| 86 | 86 | public const SINGLETONS = ['single' => self::class]; |
| 87 | 87 | |
@@ -81,7 +81,8 @@ |
||
| 81 | 81 | $bootloader = $this->getBootloadManager(); |
| 82 | 82 | |
| 83 | 83 | $bootloader->bootload([ |
| 84 | - new class () extends Bootloader { |
|
| 84 | + new class () extends Bootloader |
|
| 85 | + { |
|
| 85 | 86 | public const BINDINGS = ['abc' => self::class]; |
| 86 | 87 | public const SINGLETONS = ['single' => self::class]; |
| 87 | 88 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 49 | 49 | |
| 50 | - $d = new class() implements DispatcherInterface { |
|
| 50 | + $d = new class() implements DispatcherInterface{ |
|
| 51 | 51 | public static function canServe(EnvironmentInterface $env): bool |
| 52 | 52 | { |
| 53 | 53 | return true; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 69 | 69 | |
| 70 | - $d = new class() implements DispatcherInterface { |
|
| 70 | + $d = new class() implements DispatcherInterface{ |
|
| 71 | 71 | public function canServe(): bool |
| 72 | 72 | { |
| 73 | 73 | return true; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 92 | 92 | |
| 93 | - $d = new class() implements DispatcherInterface { |
|
| 93 | + $d = new class() implements DispatcherInterface{ |
|
| 94 | 94 | public static function canServe(EnvironmentInterface $env): bool |
| 95 | 95 | { |
| 96 | 96 | return true; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $core->getContainer()->bind('bcd', 'foo'); |
| 133 | 133 | }); |
| 134 | 134 | |
| 135 | - $kernel->booted( static function (TestCore $core): void { |
|
| 135 | + $kernel->booted(static function (TestCore $core): void { |
|
| 136 | 136 | $core->getContainer()->bind('cde', 'foo'); |
| 137 | 137 | }); |
| 138 | 138 | |
| 139 | - $kernel->booted( static function (TestCore $core): void { |
|
| 139 | + $kernel->booted(static function (TestCore $core): void { |
|
| 140 | 140 | $core->getContainer()->bind('def', 'foo'); |
| 141 | 141 | }); |
| 142 | 142 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | public function testEventsShouldBeDispatched(): void |
| 161 | 161 | { |
| 162 | - $testDispatcher = new class implements DispatcherInterface { |
|
| 162 | + $testDispatcher = new class implements DispatcherInterface{ |
|
| 163 | 163 | public static function canServe(EnvironmentInterface $env): bool |
| 164 | 164 | { |
| 165 | 165 | return true; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | }; |
| 172 | 172 | |
| 173 | 173 | $container = new Container(); |
| 174 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container) |
|
| 174 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container) |
|
| 175 | 175 | ->addDispatcher($testDispatcher); |
| 176 | 176 | |
| 177 | 177 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | public function testDispatcherNotFoundEventShouldBeDispatched(): void |
| 193 | 193 | { |
| 194 | 194 | $container = new Container(); |
| 195 | - $kernel = TestCore::create(directories: ['root' => __DIR__,], container: $container); |
|
| 195 | + $kernel = TestCore::create(directories: ['root' => __DIR__, ], container: $container); |
|
| 196 | 196 | |
| 197 | 197 | $dispatcher = $this->createMock(EventDispatcherInterface::class); |
| 198 | 198 | $dispatcher |
@@ -47,7 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 49 | 49 | |
| 50 | - $d = new class() implements DispatcherInterface { |
|
| 50 | + $d = new class() implements DispatcherInterface |
|
| 51 | + { |
|
| 51 | 52 | public static function canServe(EnvironmentInterface $env): bool |
| 52 | 53 | { |
| 53 | 54 | return true; |
@@ -67,7 +68,8 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 69 | 70 | |
| 70 | - $d = new class() implements DispatcherInterface { |
|
| 71 | + $d = new class() implements DispatcherInterface |
|
| 72 | + { |
|
| 71 | 73 | public function canServe(): bool |
| 72 | 74 | { |
| 73 | 75 | return true; |
@@ -90,7 +92,8 @@ discard block |
||
| 90 | 92 | { |
| 91 | 93 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
| 92 | 94 | |
| 93 | - $d = new class() implements DispatcherInterface { |
|
| 95 | + $d = new class() implements DispatcherInterface |
|
| 96 | + { |
|
| 94 | 97 | public static function canServe(EnvironmentInterface $env): bool |
| 95 | 98 | { |
| 96 | 99 | return true; |
@@ -159,7 +162,8 @@ discard block |
||
| 159 | 162 | |
| 160 | 163 | public function testEventsShouldBeDispatched(): void |
| 161 | 164 | { |
| 162 | - $testDispatcher = new class implements DispatcherInterface { |
|
| 165 | + $testDispatcher = new class implements DispatcherInterface |
|
| 166 | + { |
|
| 163 | 167 | public static function canServe(EnvironmentInterface $env): bool |
| 164 | 168 | { |
| 165 | 169 | return true; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function testInjection(): void |
| 50 | 50 | { |
| 51 | - $factory = new class () implements LogsInterface { |
|
| 51 | + $factory = new class () implements LogsInterface{ |
|
| 52 | 52 | public function getLogger(string $channel): LoggerInterface |
| 53 | 53 | { |
| 54 | 54 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function testInjectionNullableChannel(): void |
| 67 | 67 | { |
| 68 | - $factory = new class () implements LogsInterface { |
|
| 68 | + $factory = new class () implements LogsInterface{ |
|
| 69 | 69 | public function getLogger(?string $channel): LoggerInterface |
| 70 | 70 | { |
| 71 | 71 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public function testInjectionWithAttribute(): void |
| 84 | 84 | { |
| 85 | - $factory = new class () implements LogsInterface { |
|
| 85 | + $factory = new class () implements LogsInterface{ |
|
| 86 | 86 | public function getLogger(?string $channel): LoggerInterface |
| 87 | 87 | { |
| 88 | 88 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -48,7 +48,8 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function testInjection(): void |
| 50 | 50 | { |
| 51 | - $factory = new class () implements LogsInterface { |
|
| 51 | + $factory = new class () implements LogsInterface |
|
| 52 | + { |
|
| 52 | 53 | public function getLogger(string $channel): LoggerInterface |
| 53 | 54 | { |
| 54 | 55 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -65,7 +66,8 @@ discard block |
||
| 65 | 66 | |
| 66 | 67 | public function testInjectionNullableChannel(): void |
| 67 | 68 | { |
| 68 | - $factory = new class () implements LogsInterface { |
|
| 69 | + $factory = new class () implements LogsInterface |
|
| 70 | + { |
|
| 69 | 71 | public function getLogger(?string $channel): LoggerInterface |
| 70 | 72 | { |
| 71 | 73 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -82,7 +84,8 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | public function testInjectionWithAttribute(): void |
| 84 | 86 | { |
| 85 | - $factory = new class () implements LogsInterface { |
|
| 87 | + $factory = new class () implements LogsInterface |
|
| 88 | + { |
|
| 86 | 89 | public function getLogger(?string $channel): LoggerInterface |
| 87 | 90 | { |
| 88 | 91 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $queue = m::mock(QueueInterface::class) |
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - if (!\is_array($payload)) { |
|
| 27 | + if (!\is_array($payload)){ |
|
| 28 | 28 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 29 | 29 | return; |
| 30 | 30 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $queue = m::mock(QueueInterface::class) |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if (!\is_array($payload)) { |
|
| 52 | + if (!\is_array($payload)){ |
|
| 53 | 53 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 54 | 54 | return; |
| 55 | 55 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | && $payload === ['baz' => 'baf'] |
| 85 | 85 | && $options->getHeader('foo') === ['bar']); |
| 86 | 86 | |
| 87 | - ContainerScope::runScope($container, function() use($core): void { |
|
| 87 | + ContainerScope::runScope($container, function () use($core): void { |
|
| 88 | 88 | $core->callAction('foo', 'bar', [ |
| 89 | 89 | 'id' => 'job-id', |
| 90 | 90 | 'payload' => ['baz' => 'baf'], |
@@ -24,7 +24,8 @@ discard block |
||
| 24 | 24 | $queue = m::mock(QueueInterface::class) |
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - if (!\is_array($payload)) { |
|
| 27 | + if (!\is_array($payload)) |
|
| 28 | + { |
|
| 28 | 29 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 29 | 30 | return; |
| 30 | 31 | } |
@@ -49,7 +50,8 @@ discard block |
||
| 49 | 50 | $queue = m::mock(QueueInterface::class) |
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | - if (!\is_array($payload)) { |
|
| 53 | + if (!\is_array($payload)) |
|
| 54 | + { |
|
| 53 | 55 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 54 | 56 | return; |
| 55 | 57 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | protected Finder $finder, |
| 27 | 27 | protected readonly bool $debug = false, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function availableReflections(): \Generator |
| 39 | 39 | { |
| 40 | - foreach ($this->finder->getIterator() as $file) { |
|
| 40 | + foreach ($this->finder->getIterator() as $file){ |
|
| 41 | 41 | $reflection = new ReflectionFile((string)$file); |
| 42 | 42 | |
| 43 | - if ($reflection->hasIncludes()) { |
|
| 43 | + if ($reflection->hasIncludes()){ |
|
| 44 | 44 | // We are not analyzing files which has includes, it's not safe to require such reflections |
| 45 | - if ($this->debug) { |
|
| 45 | + if ($this->debug){ |
|
| 46 | 46 | $this->getLogger()->warning( |
| 47 | - \sprintf('File `%s` has includes and excluded from analysis', (string) $file), |
|
| 47 | + \sprintf('File `%s` has includes and excluded from analysis', (string)$file), |
|
| 48 | 48 | ['file' => $file] |
| 49 | 49 | ); |
| 50 | 50 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | protected function classReflection(string $class): \ReflectionClass |
| 70 | 70 | { |
| 71 | 71 | $loader = static function ($class): void { |
| 72 | - if ($class === LocatorException::class) { |
|
| 72 | + if ($class === LocatorException::class){ |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,24 +79,24 @@ discard block |
||
| 79 | 79 | //To suspend class dependency exception |
| 80 | 80 | \spl_autoload_register($loader); |
| 81 | 81 | |
| 82 | - try { |
|
| 82 | + try{ |
|
| 83 | 83 | //In some cases reflection can thrown an exception if class invalid or can not be loaded, |
| 84 | 84 | //we are going to handle such exception and convert it soft exception |
| 85 | 85 | return new \ReflectionClass($class); |
| 86 | - } catch (\Throwable $e) { |
|
| 87 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 86 | + }catch (\Throwable $e){ |
|
| 87 | + if ($e instanceof LocatorException && $e->getPrevious() != null){ |
|
| 88 | 88 | $e = $e->getPrevious(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ($this->debug) { |
|
| 91 | + if ($this->debug){ |
|
| 92 | 92 | $this->getLogger()->error( |
| 93 | 93 | \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 94 | 94 | ['error' => $e] |
| 95 | 95 | ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 99 | - } finally { |
|
| 98 | + throw new LocatorException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 99 | + }finally{ |
|
| 100 | 100 | \spl_autoload_unregister($loader); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | protected function enumReflection(string $enum): \ReflectionEnum |
| 113 | 113 | { |
| 114 | 114 | $loader = static function (string $enum): void { |
| 115 | - if ($enum === LocatorException::class) { |
|
| 115 | + if ($enum === LocatorException::class){ |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -122,24 +122,24 @@ discard block |
||
| 122 | 122 | //To suspend class dependency exception |
| 123 | 123 | \spl_autoload_register($loader); |
| 124 | 124 | |
| 125 | - try { |
|
| 125 | + try{ |
|
| 126 | 126 | //In some enum reflection can thrown an exception if enum invalid or can not be loaded, |
| 127 | 127 | //we are going to handle such exception and convert it soft exception |
| 128 | 128 | return new \ReflectionEnum($enum); |
| 129 | - } catch (\Throwable $e) { |
|
| 130 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 129 | + }catch (\Throwable $e){ |
|
| 130 | + if ($e instanceof LocatorException && $e->getPrevious() != null){ |
|
| 131 | 131 | $e = $e->getPrevious(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ($this->debug) { |
|
| 134 | + if ($this->debug){ |
|
| 135 | 135 | $this->getLogger()->error( |
| 136 | 136 | \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 137 | 137 | ['error' => $e] |
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 142 | - } finally { |
|
| 141 | + throw new LocatorException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 142 | + }finally{ |
|
| 143 | 143 | \spl_autoload_unregister($loader); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -37,12 +37,15 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function availableReflections(): \Generator |
| 39 | 39 | { |
| 40 | - foreach ($this->finder->getIterator() as $file) { |
|
| 40 | + foreach ($this->finder->getIterator() as $file) |
|
| 41 | + { |
|
| 41 | 42 | $reflection = new ReflectionFile((string)$file); |
| 42 | 43 | |
| 43 | - if ($reflection->hasIncludes()) { |
|
| 44 | + if ($reflection->hasIncludes()) |
|
| 45 | + { |
|
| 44 | 46 | // We are not analyzing files which has includes, it's not safe to require such reflections |
| 45 | - if ($this->debug) { |
|
| 47 | + if ($this->debug) |
|
| 48 | + { |
|
| 46 | 49 | $this->getLogger()->warning( |
| 47 | 50 | \sprintf('File `%s` has includes and excluded from analysis', (string) $file), |
| 48 | 51 | ['file' => $file] |
@@ -69,7 +72,8 @@ discard block |
||
| 69 | 72 | protected function classReflection(string $class): \ReflectionClass |
| 70 | 73 | { |
| 71 | 74 | $loader = static function ($class): void { |
| 72 | - if ($class === LocatorException::class) { |
|
| 75 | + if ($class === LocatorException::class) |
|
| 76 | + { |
|
| 73 | 77 | return; |
| 74 | 78 | } |
| 75 | 79 | |
@@ -79,16 +83,21 @@ discard block |
||
| 79 | 83 | //To suspend class dependency exception |
| 80 | 84 | \spl_autoload_register($loader); |
| 81 | 85 | |
| 82 | - try { |
|
| 86 | + try |
|
| 87 | + { |
|
| 83 | 88 | //In some cases reflection can thrown an exception if class invalid or can not be loaded, |
| 84 | 89 | //we are going to handle such exception and convert it soft exception |
| 85 | 90 | return new \ReflectionClass($class); |
| 86 | - } catch (\Throwable $e) { |
|
| 87 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 91 | + } |
|
| 92 | + catch (\Throwable $e) |
|
| 93 | + { |
|
| 94 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
| 95 | + { |
|
| 88 | 96 | $e = $e->getPrevious(); |
| 89 | 97 | } |
| 90 | 98 | |
| 91 | - if ($this->debug) { |
|
| 99 | + if ($this->debug) |
|
| 100 | + { |
|
| 92 | 101 | $this->getLogger()->error( |
| 93 | 102 | \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 94 | 103 | ['error' => $e] |
@@ -96,7 +105,9 @@ discard block |
||
| 96 | 105 | } |
| 97 | 106 | |
| 98 | 107 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
| 99 | - } finally { |
|
| 108 | + } |
|
| 109 | + finally |
|
| 110 | + { |
|
| 100 | 111 | \spl_autoload_unregister($loader); |
| 101 | 112 | } |
| 102 | 113 | } |
@@ -112,7 +123,8 @@ discard block |
||
| 112 | 123 | protected function enumReflection(string $enum): \ReflectionEnum |
| 113 | 124 | { |
| 114 | 125 | $loader = static function (string $enum): void { |
| 115 | - if ($enum === LocatorException::class) { |
|
| 126 | + if ($enum === LocatorException::class) |
|
| 127 | + { |
|
| 116 | 128 | return; |
| 117 | 129 | } |
| 118 | 130 | |
@@ -122,16 +134,21 @@ discard block |
||
| 122 | 134 | //To suspend class dependency exception |
| 123 | 135 | \spl_autoload_register($loader); |
| 124 | 136 | |
| 125 | - try { |
|
| 137 | + try |
|
| 138 | + { |
|
| 126 | 139 | //In some enum reflection can thrown an exception if enum invalid or can not be loaded, |
| 127 | 140 | //we are going to handle such exception and convert it soft exception |
| 128 | 141 | return new \ReflectionEnum($enum); |
| 129 | - } catch (\Throwable $e) { |
|
| 130 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 142 | + } |
|
| 143 | + catch (\Throwable $e) |
|
| 144 | + { |
|
| 145 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
| 146 | + { |
|
| 131 | 147 | $e = $e->getPrevious(); |
| 132 | 148 | } |
| 133 | 149 | |
| 134 | - if ($this->debug) { |
|
| 150 | + if ($this->debug) |
|
| 151 | + { |
|
| 135 | 152 | $this->getLogger()->error( |
| 136 | 153 | \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 137 | 154 | ['error' => $e] |
@@ -139,7 +156,9 @@ discard block |
||
| 139 | 156 | } |
| 140 | 157 | |
| 141 | 158 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
| 142 | - } finally { |
|
| 159 | + } |
|
| 160 | + finally |
|
| 161 | + { |
|
| 143 | 162 | \spl_autoload_unregister($loader); |
| 144 | 163 | } |
| 145 | 164 | } |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $root = self::makeContainer(); |
| 23 | 23 | |
| 24 | - $obj = $root->runScoped(static function (Container $c1) { |
|
| 25 | - $obj = $c1->runScoped(static function (Container $c2) { |
|
| 24 | + $obj = $root->runScoped(static function (Container $c1){ |
|
| 25 | + $obj = $c1->runScoped(static function (Container $c2){ |
|
| 26 | 26 | $obj = $c2->get(AttrScopeFooFinalize::class); |
| 27 | 27 | |
| 28 | 28 | self::assertFalse($obj->finalized); |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | self::expectException(FinalizersException::class); |
| 125 | 125 | self::expectExceptionMessage('An exception has been thrown during finalization of the scope `foo`'); |
| 126 | 126 | |
| 127 | - try { |
|
| 127 | + try{ |
|
| 128 | 128 | $root->runScoped(static function (Container $c1): void { |
| 129 | 129 | $obj = $c1->get(AttrScopeFooFinalize::class); |
| 130 | 130 | $obj->throwException = true; |
| 131 | 131 | }, name: 'foo'); |
| 132 | - } catch (FinalizersException $e) { |
|
| 132 | + }catch (FinalizersException $e){ |
|
| 133 | 133 | self::assertSame('foo', $e->getScope()); |
| 134 | 134 | self::assertCount(1, $e->getExceptions()); |
| 135 | 135 | // Contains the message from the inner exception. |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | self::expectException(FinalizersException::class); |
| 154 | 154 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
| 155 | 155 | |
| 156 | - try { |
|
| 156 | + try{ |
|
| 157 | 157 | $root->runScoped(static function (Container $c1): void { |
| 158 | 158 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 159 | 159 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 160 | 160 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 161 | 161 | }, name: 'foo'); |
| 162 | - } catch (FinalizersException $e) { |
|
| 162 | + }catch (FinalizersException $e){ |
|
| 163 | 163 | self::assertSame('foo', $e->getScope()); |
| 164 | 164 | self::assertCount(3, $e->getExceptions()); |
| 165 | 165 | // Contains the message from the inner exception. |
@@ -21,8 +21,10 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $root = self::makeContainer(); |
| 23 | 23 | |
| 24 | - $obj = $root->runScoped(static function (Container $c1) { |
|
| 25 | - $obj = $c1->runScoped(static function (Container $c2) { |
|
| 24 | + $obj = $root->runScoped(static function (Container $c1) |
|
| 25 | + { |
|
| 26 | + $obj = $c1->runScoped(static function (Container $c2) |
|
| 27 | + { |
|
| 26 | 28 | $obj = $c2->get(AttrScopeFooFinalize::class); |
| 27 | 29 | |
| 28 | 30 | self::assertFalse($obj->finalized); |
@@ -46,8 +48,10 @@ discard block |
||
| 46 | 48 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
| 47 | 49 | |
| 48 | 50 | $obj2 = null; |
| 49 | - $obj = $root->runScoped(static function (Container $c1) use (&$obj2) { |
|
| 50 | - $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) { |
|
| 51 | + $obj = $root->runScoped(static function (Container $c1) use (&$obj2) |
|
| 52 | + { |
|
| 53 | + $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) |
|
| 54 | + { |
|
| 51 | 55 | $obj = $c2->get(AttrScopeFooFinalize::class); |
| 52 | 56 | $obj2 = $c2->get(AttrScopeFooFinalize::class); |
| 53 | 57 | |
@@ -77,8 +81,10 @@ discard block |
||
| 77 | 81 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
| 78 | 82 | |
| 79 | 83 | $obj2 = null; |
| 80 | - $obj = $root->runScoped(static function (Container $c1) use (&$obj2) { |
|
| 81 | - $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) { |
|
| 84 | + $obj = $root->runScoped(static function (Container $c1) use (&$obj2) |
|
| 85 | + { |
|
| 86 | + $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) |
|
| 87 | + { |
|
| 82 | 88 | $obj = $c2->get(AttrFinalize::class); |
| 83 | 89 | $obj2 = $c2->get(AttrFinalize::class); |
| 84 | 90 | |
@@ -124,12 +130,15 @@ discard block |
||
| 124 | 130 | self::expectException(FinalizersException::class); |
| 125 | 131 | self::expectExceptionMessage('An exception has been thrown during finalization of the scope `foo`'); |
| 126 | 132 | |
| 127 | - try { |
|
| 133 | + try |
|
| 134 | + { |
|
| 128 | 135 | $root->runScoped(static function (Container $c1): void { |
| 129 | 136 | $obj = $c1->get(AttrScopeFooFinalize::class); |
| 130 | 137 | $obj->throwException = true; |
| 131 | 138 | }, name: 'foo'); |
| 132 | - } catch (FinalizersException $e) { |
|
| 139 | + } |
|
| 140 | + catch (FinalizersException $e) |
|
| 141 | + { |
|
| 133 | 142 | self::assertSame('foo', $e->getScope()); |
| 134 | 143 | self::assertCount(1, $e->getExceptions()); |
| 135 | 144 | // Contains the message from the inner exception. |
@@ -153,13 +162,16 @@ discard block |
||
| 153 | 162 | self::expectException(FinalizersException::class); |
| 154 | 163 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
| 155 | 164 | |
| 156 | - try { |
|
| 165 | + try |
|
| 166 | + { |
|
| 157 | 167 | $root->runScoped(static function (Container $c1): void { |
| 158 | 168 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 159 | 169 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 160 | 170 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 161 | 171 | }, name: 'foo'); |
| 162 | - } catch (FinalizersException $e) { |
|
| 172 | + } |
|
| 173 | + catch (FinalizersException $e) |
|
| 174 | + { |
|
| 163 | 175 | self::assertSame('foo', $e->getScope()); |
| 164 | 176 | self::assertCount(3, $e->getExceptions()); |
| 165 | 177 | // Contains the message from the inner exception. |