@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | private readonly MemoryInterface $memory, |
| 15 | 15 | private readonly ClassLocatorByDefinition $cacheBuilder, |
| 16 | 16 | private readonly ListenerInvoker $invoker, |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function loadClasses(TokenizationListenerInterface $listener): bool |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $definitions = \iterator_to_array($this->parser->parse($listener)); |
| 23 | 23 | |
| 24 | 24 | // If there are no definitions, then listener can't be cached. |
| 25 | - if ($definitions === []) { |
|
| 25 | + if ($definitions === []){ |
|
| 26 | 26 | return false; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | // We decided to load classes for each definition separately. |
| 32 | 32 | // It allows us to cache classes for each definition separately and if we reuse the |
| 33 | 33 | // same target in multiple listeners, we will not have to load classes for the same target. |
| 34 | - foreach ($definitions as $definition) { |
|
| 34 | + foreach ($definitions as $definition){ |
|
| 35 | 35 | $cacheKey = $definition->getCacheKey(); |
| 36 | 36 | |
| 37 | 37 | $classes = $this->memory->loadData($cacheKey); |
| 38 | - if ($classes === null) { |
|
| 38 | + if ($classes === null){ |
|
| 39 | 39 | $this->memory->saveData( |
| 40 | 40 | $cacheKey, |
| 41 | 41 | $classes = $this->cacheBuilder->getClasses($definition), |
@@ -22,7 +22,8 @@ discard block |
||
| 22 | 22 | $definitions = \iterator_to_array($this->parser->parse($listener)); |
| 23 | 23 | |
| 24 | 24 | // If there are no definitions, then listener can't be cached. |
| 25 | - if ($definitions === []) { |
|
| 25 | + if ($definitions === []) |
|
| 26 | + { |
|
| 26 | 27 | return false; |
| 27 | 28 | } |
| 28 | 29 | |
@@ -31,11 +32,13 @@ discard block |
||
| 31 | 32 | // We decided to load classes for each definition separately. |
| 32 | 33 | // It allows us to cache classes for each definition separately and if we reuse the |
| 33 | 34 | // same target in multiple listeners, we will not have to load classes for the same target. |
| 34 | - foreach ($definitions as $definition) { |
|
| 35 | + foreach ($definitions as $definition) |
|
| 36 | + { |
|
| 35 | 37 | $cacheKey = $definition->getCacheKey(); |
| 36 | 38 | |
| 37 | 39 | $classes = $this->memory->loadData($cacheKey); |
| 38 | - if ($classes === null) { |
|
| 40 | + if ($classes === null) |
|
| 41 | + { |
|
| 39 | 42 | $this->memory->saveData( |
| 40 | 43 | $cacheKey, |
| 41 | 44 | $classes = $this->cacheBuilder->getClasses($definition), |
@@ -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,13 +37,13 @@ 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 | 45 | $this->getLogger()->warning( |
| 46 | - \sprintf('File `%s` has includes and excluded from analysis', (string) $file), |
|
| 46 | + \sprintf('File `%s` has includes and excluded from analysis', (string)$file), |
|
| 47 | 47 | ['file' => $file] |
| 48 | 48 | ); |
| 49 | 49 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | protected function classReflection(string $class): \ReflectionClass |
| 68 | 68 | { |
| 69 | - $loader = static function ($class) { |
|
| 70 | - if ($class === LocatorException::class) { |
|
| 69 | + $loader = static function ($class){ |
|
| 70 | + if ($class === LocatorException::class){ |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | //To suspend class dependency exception |
| 78 | 78 | \spl_autoload_register($loader); |
| 79 | 79 | |
| 80 | - try { |
|
| 80 | + try{ |
|
| 81 | 81 | //In some cases reflection can thrown an exception if class invalid or can not be loaded, |
| 82 | 82 | //we are going to handle such exception and convert it soft exception |
| 83 | 83 | return new \ReflectionClass($class); |
| 84 | - } catch (\Throwable $e) { |
|
| 85 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
| 84 | + }catch (\Throwable $e){ |
|
| 85 | + if ($e instanceof LocatorException && $e->getPrevious() != null){ |
|
| 86 | 86 | $e = $e->getPrevious(); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | ['error' => $e] |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 101 | - } finally { |
|
| 100 | + throw new LocatorException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 101 | + }finally{ |
|
| 102 | 102 | \spl_autoload_unregister($loader); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -58,15 +58,18 @@ discard block |
||
| 58 | 58 | ): void { |
| 59 | 59 | // First, we check if the listener has been cached. If it has, we will load the classes |
| 60 | 60 | // from the cache. |
| 61 | - foreach ($this->listeners as $i => $listener) { |
|
| 62 | - if ($loader->loadClasses($listener)) { |
|
| 61 | + foreach ($this->listeners as $i => $listener) |
|
| 62 | + { |
|
| 63 | + if ($loader->loadClasses($listener)) |
|
| 64 | + { |
|
| 63 | 65 | unset($this->listeners[$i]); |
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | // If there are no listeners left, we don't need to use static analysis at all and save |
| 68 | 70 | // valuable time. |
| 69 | - if ($this->listeners === []) { |
|
| 71 | + if ($this->listeners === []) |
|
| 72 | + { |
|
| 70 | 73 | return; |
| 71 | 74 | } |
| 72 | 75 | |
@@ -74,7 +77,8 @@ discard block |
||
| 74 | 77 | // Please note that this is a very expensive operation and should be avoided if possible. |
| 75 | 78 | // Use #[TargetClass] or #[TargetAttribute] attributes in your listeners to cache the classes. |
| 76 | 79 | $classes = $classes->getClasses(); |
| 77 | - foreach ($this->listeners as $listener) { |
|
| 80 | + foreach ($this->listeners as $listener) |
|
| 81 | + { |
|
| 78 | 82 | $invoker->invoke($listener, $classes); |
| 79 | 83 | } |
| 80 | 84 | |
@@ -58,15 +58,15 @@ discard block |
||
| 58 | 58 | ): void { |
| 59 | 59 | // First, we check if the listener has been cached. If it has, we will load the classes |
| 60 | 60 | // from the cache. |
| 61 | - foreach ($this->listeners as $i => $listener) { |
|
| 62 | - if ($loader->loadClasses($listener)) { |
|
| 61 | + foreach ($this->listeners as $i => $listener){ |
|
| 62 | + if ($loader->loadClasses($listener)){ |
|
| 63 | 63 | unset($this->listeners[$i]); |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // If there are no listeners left, we don't need to use static analysis at all and save |
| 68 | 68 | // valuable time. |
| 69 | - if ($this->listeners === []) { |
|
| 69 | + if ($this->listeners === []){ |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | // Please note that this is a very expensive operation and should be avoided if possible. |
| 75 | 75 | // Use #[TargetClass] or #[TargetAttribute] attributes in your listeners to cache the classes. |
| 76 | 76 | $classes = $classes->getClasses(); |
| 77 | - foreach ($this->listeners as $listener) { |
|
| 77 | + foreach ($this->listeners as $listener){ |
|
| 78 | 78 | $invoker->invoke($listener, $classes); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | // If you want to disable the cache, you can use the TOKENIZER_CACHE_TARGETS environment variable. |
| 94 | 94 | $memory = $env->get('TOKENIZER_CACHE_TARGETS', $config->isCacheEnabled()) |
| 95 | 95 | ? $factory->make(Memory::class, [ |
| 96 | - 'directory' => $config->getCacheDirectory() ?? $dirs->get('runtime') . 'cache/listeners', |
|
| 96 | + 'directory' => $config->getCacheDirectory() ?? $dirs->get('runtime').'cache/listeners', |
|
| 97 | 97 | ]) |
| 98 | 98 | : new NullMemory(); |
| 99 | 99 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function __construct( |
| 32 | 32 | private readonly ConfiguratorInterface $config, |
| 33 | - ) { |
|
| 33 | + ){ |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function init(BinderInterface $binder, DirectoriesInterface $dirs): void |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function addScopedDirectory(string $scope, string $directory): void |
| 71 | 71 | { |
| 72 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) { |
|
| 72 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])){ |
|
| 73 | 73 | $this->config->modify( |
| 74 | 74 | TokenizerConfig::CONFIG, |
| 75 | 75 | new Append('scopes', $scope, []) |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $this->config->modify( |
| 80 | 80 | TokenizerConfig::CONFIG, |
| 81 | - new Append('scopes.' . $scope, null, $directory) |
|
| 81 | + new Append('scopes.'.$scope, null, $directory) |
|
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public readonly string $class, |
| 26 | 26 | public readonly ?string $scope = null, |
| 27 | 27 | public readonly bool $useAnnotations = false, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function filter(array $classes): \Generator |
@@ -39,27 +39,27 @@ discard block |
||
| 39 | 39 | ? (new Factory())->create() |
| 40 | 40 | : new AttributeReader(); |
| 41 | 41 | |
| 42 | - if ($attribute === null) { |
|
| 42 | + if ($attribute === null){ |
|
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $attribute = $attribute->newInstance(); |
| 47 | 47 | |
| 48 | - foreach ($classes as $class) { |
|
| 48 | + foreach ($classes as $class){ |
|
| 49 | 49 | // If attribute is defined on class level and class has target attribute |
| 50 | 50 | // then we can add it to the list of classes |
| 51 | 51 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
| 52 | 52 | && $reader->firstClassMetadata($class, $target->getName()) |
| 53 | - ) { |
|
| 53 | + ){ |
|
| 54 | 54 | yield $class->getName(); |
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // If attribute is defined on method level and class methods has target attribute |
| 59 | 59 | // then we can add it to the list of classes |
| 60 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 61 | - foreach ($class->getMethods() as $method) { |
|
| 62 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 60 | + if ($attribute->flags & \Attribute::TARGET_METHOD){ |
|
| 61 | + foreach ($class->getMethods() as $method){ |
|
| 62 | + if ($reader->firstFunctionMetadata($method, $target->getName())){ |
|
| 63 | 63 | yield $class->getName(); |
| 64 | 64 | continue 2; |
| 65 | 65 | } |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | // If attribute is defined on property level and class properties has target attribute |
| 70 | 70 | // then we can add it to the list of classes |
| 71 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 72 | - foreach ($class->getProperties() as $property) { |
|
| 73 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 71 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY){ |
|
| 72 | + foreach ($class->getProperties() as $property){ |
|
| 73 | + if ($reader->firstPropertyMetadata($property, $target->getName())){ |
|
| 74 | 74 | yield $class->getName(); |
| 75 | 75 | continue 2; |
| 76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | // If attribute is defined on constant level and class constants has target attribute |
| 82 | 82 | // then we can add it to the list of classes |
| 83 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 84 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 85 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 83 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){ |
|
| 84 | + foreach ($class->getReflectionConstants() as $constant){ |
|
| 85 | + if ($reader->firstConstantMetadata($constant, $target->getName())){ |
|
| 86 | 86 | yield $class->getName(); |
| 87 | 87 | continue 2; |
| 88 | 88 | } |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 94 | 94 | // then we can add it to the list of classes |
| 95 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 96 | - foreach ($class->getMethods() as $method) { |
|
| 97 | - foreach ($method->getParameters() as $parameter) { |
|
| 98 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 95 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER){ |
|
| 96 | + foreach ($class->getMethods() as $method){ |
|
| 97 | + foreach ($method->getParameters() as $parameter){ |
|
| 98 | + if ($reader->firstParameterMetadata($parameter, $target->getName())){ |
|
| 99 | 99 | yield $class->getName(); |
| 100 | 100 | continue 3; |
| 101 | 101 | } |
@@ -112,6 +112,6 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function getCacheKey(): string |
| 114 | 114 | { |
| 115 | - return \md5($this->class . $this->scope); |
|
| 115 | + return \md5($this->class.$this->scope); |
|
| 116 | 116 | } |
| 117 | 117 | } |
@@ -39,13 +39,15 @@ discard block |
||
| 39 | 39 | ? (new Factory())->create() |
| 40 | 40 | : new AttributeReader(); |
| 41 | 41 | |
| 42 | - if ($attribute === null) { |
|
| 42 | + if ($attribute === null) |
|
| 43 | + { |
|
| 43 | 44 | return; |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | $attribute = $attribute->newInstance(); |
| 47 | 48 | |
| 48 | - foreach ($classes as $class) { |
|
| 49 | + foreach ($classes as $class) |
|
| 50 | + { |
|
| 49 | 51 | // If attribute is defined on class level and class has target attribute |
| 50 | 52 | // then we can add it to the list of classes |
| 51 | 53 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
@@ -57,9 +59,12 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | // If attribute is defined on method level and class methods has target attribute |
| 59 | 61 | // then we can add it to the list of classes |
| 60 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 61 | - foreach ($class->getMethods() as $method) { |
|
| 62 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 62 | + if ($attribute->flags & \Attribute::TARGET_METHOD) |
|
| 63 | + { |
|
| 64 | + foreach ($class->getMethods() as $method) |
|
| 65 | + { |
|
| 66 | + if ($reader->firstFunctionMetadata($method, $target->getName())) |
|
| 67 | + { |
|
| 63 | 68 | yield $class->getName(); |
| 64 | 69 | continue 2; |
| 65 | 70 | } |
@@ -68,9 +73,12 @@ discard block |
||
| 68 | 73 | |
| 69 | 74 | // If attribute is defined on property level and class properties has target attribute |
| 70 | 75 | // then we can add it to the list of classes |
| 71 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 72 | - foreach ($class->getProperties() as $property) { |
|
| 73 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 76 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY) |
|
| 77 | + { |
|
| 78 | + foreach ($class->getProperties() as $property) |
|
| 79 | + { |
|
| 80 | + if ($reader->firstPropertyMetadata($property, $target->getName())) |
|
| 81 | + { |
|
| 74 | 82 | yield $class->getName(); |
| 75 | 83 | continue 2; |
| 76 | 84 | } |
@@ -80,9 +88,12 @@ discard block |
||
| 80 | 88 | |
| 81 | 89 | // If attribute is defined on constant level and class constants has target attribute |
| 82 | 90 | // then we can add it to the list of classes |
| 83 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 84 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 85 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 91 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) |
|
| 92 | + { |
|
| 93 | + foreach ($class->getReflectionConstants() as $constant) |
|
| 94 | + { |
|
| 95 | + if ($reader->firstConstantMetadata($constant, $target->getName())) |
|
| 96 | + { |
|
| 86 | 97 | yield $class->getName(); |
| 87 | 98 | continue 2; |
| 88 | 99 | } |
@@ -92,10 +103,14 @@ discard block |
||
| 92 | 103 | |
| 93 | 104 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 94 | 105 | // then we can add it to the list of classes |
| 95 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 96 | - foreach ($class->getMethods() as $method) { |
|
| 97 | - foreach ($method->getParameters() as $parameter) { |
|
| 98 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 106 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER) |
|
| 107 | + { |
|
| 108 | + foreach ($class->getMethods() as $method) |
|
| 109 | + { |
|
| 110 | + foreach ($method->getParameters() as $parameter) |
|
| 111 | + { |
|
| 112 | + if ($reader->firstParameterMetadata($parameter, $target->getName())) |
|
| 113 | + { |
|
| 99 | 114 | yield $class->getName(); |
| 100 | 115 | continue 3; |
| 101 | 116 | } |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | public function __construct( |
| 22 | 22 | private readonly ReaderInterface $reader, |
| 23 | 23 | private readonly GroupRegistry $groups, |
| 24 | - ) { |
|
| 24 | + ){ |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function listen(ReflectionClass $class): void |
| 28 | 28 | { |
| 29 | - foreach ($class->getMethods() as $method) { |
|
| 29 | + foreach ($class->getMethods() as $method){ |
|
| 30 | 30 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
| 31 | 31 | |
| 32 | - if ($route === null) { |
|
| 32 | + if ($route === null){ |
|
| 33 | 33 | continue; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $defaultGroup = $this->groups->getDefaultGroup(); |
| 43 | 43 | |
| 44 | 44 | $routes = []; |
| 45 | - foreach ($this->attributes as $classes) { |
|
| 45 | + foreach ($this->attributes as $classes){ |
|
| 46 | 46 | [$method, $route] = $classes; |
| 47 | 47 | $class = $method->getDeclaringClass(); |
| 48 | 48 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | private function configureRoutes(array $routes): void |
| 68 | 68 | { |
| 69 | - foreach ($routes as $name => $schema) { |
|
| 69 | + foreach ($routes as $name => $schema){ |
|
| 70 | 70 | $route = new \Spiral\Router\Route( |
| 71 | 71 | $schema['pattern'], |
| 72 | 72 | new Action($schema['controller'], $schema['action']), |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | public readonly string $class, |
| 27 | 27 | public readonly ?string $scope = null, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function filter(array $classes): \Generator |
| 32 | 32 | { |
| 33 | 33 | $target = new \ReflectionClass($this->class); |
| 34 | 34 | |
| 35 | - foreach ($classes as $class) { |
|
| 36 | - if (!$target->isTrait()) { |
|
| 37 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
| 35 | + foreach ($classes as $class){ |
|
| 36 | + if (!$target->isTrait()){ |
|
| 37 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()){ |
|
| 38 | 38 | yield $class->getName(); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Checking using traits |
| 45 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) { |
|
| 45 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)){ |
|
| 46 | 46 | yield $class->getName(); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function getCacheKey(): string |
| 52 | 52 | { |
| 53 | - return \md5($this->class . $this->scope); |
|
| 53 | + return \md5($this->class.$this->scope); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function getScope(): ?string |
@@ -32,9 +32,12 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $target = new \ReflectionClass($this->class); |
| 34 | 34 | |
| 35 | - foreach ($classes as $class) { |
|
| 36 | - if (!$target->isTrait()) { |
|
| 37 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
| 35 | + foreach ($classes as $class) |
|
| 36 | + { |
|
| 37 | + if (!$target->isTrait()) |
|
| 38 | + { |
|
| 39 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) |
|
| 40 | + { |
|
| 38 | 41 | yield $class->getName(); |
| 39 | 42 | } |
| 40 | 43 | |
@@ -42,7 +45,8 @@ discard block |
||
| 42 | 45 | } |
| 43 | 46 | |
| 44 | 47 | // Checking using traits |
| 45 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) { |
|
| 48 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) |
|
| 49 | + { |
|
| 46 | 50 | yield $class->getName(); |
| 47 | 51 | } |
| 48 | 52 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | $env = m::mock(EnvironmentInterface::class); |
| 60 | 60 | $env->shouldReceive('get')->with('TOKENIZER_CACHE_TARGETS', false)->andReturnTrue(); |
| 61 | 61 | |
| 62 | - $config = new TokenizerConfig(['cache' => ['directory' => 'cache',]]); |
|
| 62 | + $config = new TokenizerConfig(['cache' => ['directory' => 'cache', ]]); |
|
| 63 | 63 | |
| 64 | 64 | $this->assertSame( |
| 65 | 65 | $loader, |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | private readonly ConsoleBootloader $bootloader, |
| 27 | 27 | ContainerInterface $container |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->container = $container; |
| 30 | 30 | $this->target = new \ReflectionClass(SymfonyCommand::class); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function listen(\ReflectionClass $class): void |
| 34 | 34 | { |
| 35 | - if (!$this->isTargeted($class, $this->target)) { |
|
| 35 | + if (!$this->isTargeted($class, $this->target)){ |
|
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function finalize(): void |
| 43 | 43 | { |
| 44 | - foreach ($this->commands as $class) { |
|
| 45 | - if ($class->isAbstract()) { |
|
| 44 | + foreach ($this->commands as $class){ |
|
| 45 | + if ($class->isAbstract()){ |
|
| 46 | 46 | continue; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target): bool |
| 57 | 57 | { |
| 58 | - if (!$target->isTrait()) { |
|
| 58 | + if (!$target->isTrait()){ |
|
| 59 | 59 | // Target is interface or class |
| 60 | 60 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
| 61 | 61 | } |
@@ -32,7 +32,8 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function listen(\ReflectionClass $class): void |
| 34 | 34 | { |
| 35 | - if (!$this->isTargeted($class, $this->target)) { |
|
| 35 | + if (!$this->isTargeted($class, $this->target)) |
|
| 36 | + { |
|
| 36 | 37 | return; |
| 37 | 38 | } |
| 38 | 39 | |
@@ -41,8 +42,10 @@ discard block |
||
| 41 | 42 | |
| 42 | 43 | public function finalize(): void |
| 43 | 44 | { |
| 44 | - foreach ($this->commands as $class) { |
|
| 45 | - if ($class->isAbstract()) { |
|
| 45 | + foreach ($this->commands as $class) |
|
| 46 | + { |
|
| 47 | + if ($class->isAbstract()) |
|
| 48 | + { |
|
| 46 | 49 | continue; |
| 47 | 50 | } |
| 48 | 51 | |
@@ -55,7 +58,8 @@ discard block |
||
| 55 | 58 | */ |
| 56 | 59 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target): bool |
| 57 | 60 | { |
| 58 | - if (!$target->isTrait()) { |
|
| 61 | + if (!$target->isTrait()) |
|
| 62 | + { |
|
| 59 | 63 | // Target is interface or class |
| 60 | 64 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
| 61 | 65 | } |