@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | $this->container = new Container(); |
| 25 | 25 | $this->container->bind(Tokenizer::class, $this->getTokenizer(['scopes' => [ |
| 26 | - 'foo' => ['directories' => [__DIR__ . '/Classes/Inner'], 'exclude' => []], |
|
| 26 | + 'foo' => ['directories' => [__DIR__.'/Classes/Inner'], 'exclude' => []], |
|
| 27 | 27 | ]])); |
| 28 | 28 | $this->container->bindSingleton(ScopedClassesInterface::class, ScopedClassLocator::class); |
| 29 | 29 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | protected function setUp(): void |
| 17 | 17 | { |
| 18 | 18 | $this->finder = new Finder(); |
| 19 | - $this->finder->files()->in([__DIR__ . '/Classes'])->name('*.php'); |
|
| 19 | + $this->finder->files()->in([__DIR__.'/Classes'])->name('*.php'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function testHasIncludesMessage(): void |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | ); |
| 57 | 57 | $class->setLogger($logger); |
| 58 | 58 | |
| 59 | - try { |
|
| 59 | + try{ |
|
| 60 | 60 | $ref->invoke($class, 'foo'); |
| 61 | - } catch (LocatorException) { |
|
| 61 | + }catch (LocatorException){ |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $logger->expects($this->never())->method('error'); |
| 72 | 72 | $class->setLogger($logger); |
| 73 | 73 | |
| 74 | - try { |
|
| 74 | + try{ |
|
| 75 | 75 | $ref->invoke($class, 'foo'); |
| 76 | - } catch (LocatorException) { |
|
| 76 | + }catch (LocatorException){ |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | $class->setLogger($logger); |
| 91 | 91 | |
| 92 | - try { |
|
| 92 | + try{ |
|
| 93 | 93 | $ref->invoke($class, 'foo'); |
| 94 | - } catch (LocatorException) { |
|
| 94 | + }catch (LocatorException){ |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | $logger->expects($this->never())->method('error'); |
| 105 | 105 | $class->setLogger($logger); |
| 106 | 106 | |
| 107 | - try { |
|
| 107 | + try{ |
|
| 108 | 108 | $ref->invoke($class, 'foo'); |
| 109 | - } catch (LocatorException) { |
|
| 109 | + }catch (LocatorException){ |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | private function getLocator(bool $debug = false): AbstractLocator |
| 114 | 114 | { |
| 115 | - return new class($this->finder, $debug) extends AbstractLocator {}; |
|
| 115 | + return new class($this->finder, $debug) extends AbstractLocator{}; |
|
| 116 | 116 | } |
| 117 | 117 | } |
@@ -56,9 +56,12 @@ discard block |
||
| 56 | 56 | ); |
| 57 | 57 | $class->setLogger($logger); |
| 58 | 58 | |
| 59 | - try { |
|
| 59 | + try |
|
| 60 | + { |
|
| 60 | 61 | $ref->invoke($class, 'foo'); |
| 61 | - } catch (LocatorException) { |
|
| 62 | + } |
|
| 63 | + catch (LocatorException) |
|
| 64 | + { |
|
| 62 | 65 | } |
| 63 | 66 | } |
| 64 | 67 | |
@@ -71,9 +74,12 @@ discard block |
||
| 71 | 74 | $logger->expects($this->never())->method('error'); |
| 72 | 75 | $class->setLogger($logger); |
| 73 | 76 | |
| 74 | - try { |
|
| 77 | + try |
|
| 78 | + { |
|
| 75 | 79 | $ref->invoke($class, 'foo'); |
| 76 | - } catch (LocatorException) { |
|
| 80 | + } |
|
| 81 | + catch (LocatorException) |
|
| 82 | + { |
|
| 77 | 83 | } |
| 78 | 84 | } |
| 79 | 85 | |
@@ -89,9 +95,12 @@ discard block |
||
| 89 | 95 | ); |
| 90 | 96 | $class->setLogger($logger); |
| 91 | 97 | |
| 92 | - try { |
|
| 98 | + try |
|
| 99 | + { |
|
| 93 | 100 | $ref->invoke($class, 'foo'); |
| 94 | - } catch (LocatorException) { |
|
| 101 | + } |
|
| 102 | + catch (LocatorException) |
|
| 103 | + { |
|
| 95 | 104 | } |
| 96 | 105 | } |
| 97 | 106 | |
@@ -104,14 +113,19 @@ discard block |
||
| 104 | 113 | $logger->expects($this->never())->method('error'); |
| 105 | 114 | $class->setLogger($logger); |
| 106 | 115 | |
| 107 | - try { |
|
| 116 | + try |
|
| 117 | + { |
|
| 108 | 118 | $ref->invoke($class, 'foo'); |
| 109 | - } catch (LocatorException) { |
|
| 119 | + } |
|
| 120 | + catch (LocatorException) |
|
| 121 | + { |
|
| 110 | 122 | } |
| 111 | 123 | } |
| 112 | 124 | |
| 113 | 125 | private function getLocator(bool $debug = false): AbstractLocator |
| 114 | 126 | { |
| 115 | - return new class($this->finder, $debug) extends AbstractLocator {}; |
|
| 127 | + return new class($this->finder, $debug) extends AbstractLocator |
|
| 128 | + { |
|
| 129 | +}; |
|
| 116 | 130 | } |
| 117 | 131 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | $this->container = new Container(); |
| 27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer([ |
| 28 | - 'scopes' => ['foo' => ['directories' => [__DIR__ . '/Enums/Inner'], 'exclude' => []]], |
|
| 28 | + 'scopes' => ['foo' => ['directories' => [__DIR__.'/Enums/Inner'], 'exclude' => []]], |
|
| 29 | 29 | ])); |
| 30 | 30 | $this->container->bindSingleton(ScopedEnumsInterface::class, ScopedEnumLocator::class); |
| 31 | 31 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | $this->container = new Container(); |
| 27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer(['scopes' => [ |
| 28 | - 'foo' => ['directories' => [__DIR__ . '/Interfaces/Inner'], 'exclude' => []], |
|
| 28 | + 'foo' => ['directories' => [__DIR__.'/Interfaces/Inner'], 'exclude' => []], |
|
| 29 | 29 | ]])); |
| 30 | 30 | $this->container->bindSingleton(ScopedInterfacesInterface::class, ScopedInterfaceLocator::class); |
| 31 | 31 | } |
@@ -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 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected function classReflection(string $class): \ReflectionClass |
| 70 | 70 | { |
| 71 | - $loader = static function ($class) { |
|
| 72 | - if ($class === LocatorException::class) { |
|
| 71 | + $loader = static function ($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] |
@@ -68,8 +71,10 @@ discard block |
||
| 68 | 71 | */ |
| 69 | 72 | protected function classReflection(string $class): \ReflectionClass |
| 70 | 73 | { |
| 71 | - $loader = static function ($class) { |
|
| 72 | - if ($class === LocatorException::class) { |
|
| 74 | + $loader = static function ($class) |
|
| 75 | + { |
|
| 76 | + if ($class === LocatorException::class) |
|
| 77 | + { |
|
| 73 | 78 | return; |
| 74 | 79 | } |
| 75 | 80 | |
@@ -79,16 +84,21 @@ discard block |
||
| 79 | 84 | //To suspend class dependency exception |
| 80 | 85 | \spl_autoload_register($loader); |
| 81 | 86 | |
| 82 | - try { |
|
| 87 | + try |
|
| 88 | + { |
|
| 83 | 89 | //In some cases reflection can thrown an exception if class invalid or can not be loaded, |
| 84 | 90 | //we are going to handle such exception and convert it soft exception |
| 85 | 91 | return new \ReflectionClass($class); |
| 86 | - } catch (\Throwable $e) { |
|
| 87 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 92 | + } |
|
| 93 | + catch (\Throwable $e) |
|
| 94 | + { |
|
| 95 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
| 96 | + { |
|
| 88 | 97 | $e = $e->getPrevious(); |
| 89 | 98 | } |
| 90 | 99 | |
| 91 | - if ($this->debug) { |
|
| 100 | + if ($this->debug) |
|
| 101 | + { |
|
| 92 | 102 | $this->getLogger()->error( |
| 93 | 103 | \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 94 | 104 | ['error' => $e] |
@@ -96,7 +106,9 @@ discard block |
||
| 96 | 106 | } |
| 97 | 107 | |
| 98 | 108 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
| 99 | - } finally { |
|
| 109 | + } |
|
| 110 | + finally |
|
| 111 | + { |
|
| 100 | 112 | \spl_autoload_unregister($loader); |
| 101 | 113 | } |
| 102 | 114 | } |
@@ -112,7 +124,8 @@ discard block |
||
| 112 | 124 | protected function enumReflection(string $enum): \ReflectionEnum |
| 113 | 125 | { |
| 114 | 126 | $loader = static function (string $enum): void { |
| 115 | - if ($enum === LocatorException::class) { |
|
| 127 | + if ($enum === LocatorException::class) |
|
| 128 | + { |
|
| 116 | 129 | return; |
| 117 | 130 | } |
| 118 | 131 | |
@@ -122,16 +135,21 @@ discard block |
||
| 122 | 135 | //To suspend class dependency exception |
| 123 | 136 | \spl_autoload_register($loader); |
| 124 | 137 | |
| 125 | - try { |
|
| 138 | + try |
|
| 139 | + { |
|
| 126 | 140 | //In some enum reflection can thrown an exception if enum invalid or can not be loaded, |
| 127 | 141 | //we are going to handle such exception and convert it soft exception |
| 128 | 142 | return new \ReflectionEnum($enum); |
| 129 | - } catch (\Throwable $e) { |
|
| 130 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 143 | + } |
|
| 144 | + catch (\Throwable $e) |
|
| 145 | + { |
|
| 146 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
| 147 | + { |
|
| 131 | 148 | $e = $e->getPrevious(); |
| 132 | 149 | } |
| 133 | 150 | |
| 134 | - if ($this->debug) { |
|
| 151 | + if ($this->debug) |
|
| 152 | + { |
|
| 135 | 153 | $this->getLogger()->error( |
| 136 | 154 | \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()), |
| 137 | 155 | ['error' => $e] |
@@ -139,7 +157,9 @@ discard block |
||
| 139 | 157 | } |
| 140 | 158 | |
| 141 | 159 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
| 142 | - } finally { |
|
| 160 | + } |
|
| 161 | + finally |
|
| 162 | + { |
|
| 143 | 163 | \spl_autoload_unregister($loader); |
| 144 | 164 | } |
| 145 | 165 | } |