@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | use MockeryPHPUnitIntegration; |
| 21 | 21 | |
| 22 | 22 | private ClassLocatorByDefinition $locator; |
| 23 | - private ClassesInterface|m\LegacyMockInterface|m\MockInterface $classes; |
|
| 24 | - private ScopedClassesInterface|m\LegacyMockInterface|m\MockInterface $scopedClasses; |
|
| 23 | + private ClassesInterface | m\LegacyMockInterface | m\MockInterface $classes; |
|
| 24 | + private ScopedClassesInterface | m\LegacyMockInterface | m\MockInterface $scopedClasses; |
|
| 25 | 25 | |
| 26 | 26 | protected function setUp(): void |
| 27 | 27 | { |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $definition = \iterator_to_array((new AttributesParser(new AttributeReader())) |
| 106 | 106 | ->parse(new $listener))[0]; |
| 107 | 107 | |
| 108 | - if ($definition->scope === null) { |
|
| 108 | + if ($definition->scope === null){ |
|
| 109 | 109 | $this->classes |
| 110 | 110 | ->shouldReceive('getClasses') |
| 111 | 111 | ->andReturn($classes); |
| 112 | - } else { |
|
| 112 | + }else{ |
|
| 113 | 113 | $this->scopedClasses |
| 114 | 114 | ->shouldReceive('getScopedClasses') |
| 115 | 115 | ->with($definition->scope) |
@@ -105,11 +105,14 @@ |
||
| 105 | 105 | $definition = \iterator_to_array((new AttributesParser(new AttributeReader())) |
| 106 | 106 | ->parse(new $listener))[0]; |
| 107 | 107 | |
| 108 | - if ($definition->scope === null) { |
|
| 108 | + if ($definition->scope === null) |
|
| 109 | + { |
|
| 109 | 110 | $this->classes |
| 110 | 111 | ->shouldReceive('getClasses') |
| 111 | 112 | ->andReturn($classes); |
| 112 | - } else { |
|
| 113 | + } |
|
| 114 | + else |
|
| 115 | + { |
|
| 113 | 116 | $this->scopedClasses |
| 114 | 117 | ->shouldReceive('getScopedClasses') |
| 115 | 118 | ->with($definition->scope) |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
| 32 | 32 | |
| 33 | - foreach ($classes as $class) { |
|
| 33 | + foreach ($classes as $class){ |
|
| 34 | 34 | $listener->shouldReceive('listen') |
| 35 | 35 | ->once() |
| 36 | 36 | ->with($class); |
@@ -30,7 +30,8 @@ |
||
| 30 | 30 | |
| 31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
| 32 | 32 | |
| 33 | - foreach ($classes as $class) { |
|
| 33 | + foreach ($classes as $class) |
|
| 34 | + { |
|
| 34 | 35 | $listener->shouldReceive('listen') |
| 35 | 36 | ->once() |
| 36 | 37 | ->with($class); |
@@ -20,6 +20,6 @@ |
||
| 20 | 20 | public function __construct( |
| 21 | 21 | public readonly string $target, |
| 22 | 22 | public readonly ?string $scope = null |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | } |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | ): void { |
| 58 | 58 | // First, we check if the listener has been cached. If it has, we will load the classes |
| 59 | 59 | // from the cache. |
| 60 | - foreach ($this->listeners as $i => $listener) { |
|
| 61 | - if ($cachedClassesLoader->loadClasses($listener)) { |
|
| 60 | + foreach ($this->listeners as $i => $listener){ |
|
| 61 | + if ($cachedClassesLoader->loadClasses($listener)){ |
|
| 62 | 62 | unset($this->listeners[$i]); |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // If there are no listeners left, we don't need to use static analysis at all and save |
| 67 | 67 | // valuable time. |
| 68 | - if ($this->listeners === []) { |
|
| 68 | + if ($this->listeners === []){ |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // Please note that this is a very expensive operation and should be avoided if possible. |
| 74 | 74 | // Use #[ListenForClasses] attribute in your listeners to cache the classes. |
| 75 | 75 | $classes = $classes->getClasses(); |
| 76 | - foreach ($this->listeners as $listener) { |
|
| 76 | + foreach ($this->listeners as $listener){ |
|
| 77 | 77 | $invoker->invoke($listener, $classes); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // We will use a file memory to cache the classes. Because it's available in the runtime. |
| 92 | 92 | // If you want to disable the cache, you can use the TOKENIZER_WARMUP environment variable. |
| 93 | 93 | $memory = $env->get('TOKENIZER_WARMUP', false) |
| 94 | - ? new Memory($dirs->get('runtime') . 'cache/listeners', $files) |
|
| 94 | + ? new Memory($dirs->get('runtime').'cache/listeners', $files) |
|
| 95 | 95 | : new NullMemory(); |
| 96 | 96 | |
| 97 | 97 | return $factory->make(CachedClassesLoader::class, [ |
@@ -57,15 +57,18 @@ discard block |
||
| 57 | 57 | ): void { |
| 58 | 58 | // First, we check if the listener has been cached. If it has, we will load the classes |
| 59 | 59 | // from the cache. |
| 60 | - foreach ($this->listeners as $i => $listener) { |
|
| 61 | - if ($cachedClassesLoader->loadClasses($listener)) { |
|
| 60 | + foreach ($this->listeners as $i => $listener) |
|
| 61 | + { |
|
| 62 | + if ($cachedClassesLoader->loadClasses($listener)) |
|
| 63 | + { |
|
| 62 | 64 | unset($this->listeners[$i]); |
| 63 | 65 | } |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | // If there are no listeners left, we don't need to use static analysis at all and save |
| 67 | 69 | // valuable time. |
| 68 | - if ($this->listeners === []) { |
|
| 70 | + if ($this->listeners === []) |
|
| 71 | + { |
|
| 69 | 72 | return; |
| 70 | 73 | } |
| 71 | 74 | |
@@ -73,7 +76,8 @@ discard block |
||
| 73 | 76 | // Please note that this is a very expensive operation and should be avoided if possible. |
| 74 | 77 | // Use #[ListenForClasses] attribute in your listeners to cache the classes. |
| 75 | 78 | $classes = $classes->getClasses(); |
| 76 | - foreach ($this->listeners as $listener) { |
|
| 79 | + foreach ($this->listeners as $listener) |
|
| 80 | + { |
|
| 77 | 81 | $invoker->invoke($listener, $classes); |
| 78 | 82 | } |
| 79 | 83 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | private readonly ReaderInterface $reader, |
| 21 | 21 | private readonly ClassesInterface $classes, |
| 22 | 22 | private readonly ScopedClassesInterface $scopedClasses, |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | private function getClassesForClass(array $classes, \ReflectionClass $target): \Generator |
| 47 | 47 | { |
| 48 | - foreach ($classes as $class) { |
|
| 49 | - if (!$target->isTrait()) { |
|
| 50 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
| 48 | + foreach ($classes as $class){ |
|
| 49 | + if (!$target->isTrait()){ |
|
| 50 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()){ |
|
| 51 | 51 | yield $class->getName(); |
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Checking using traits |
| 57 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()))) { |
|
| 57 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()))){ |
|
| 58 | 58 | yield $class->getName(); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function getClassesForAttribute(array $classes, \ReflectionClass $target, \Attribute $attribute): \Generator |
| 70 | 70 | { |
| 71 | - foreach ($classes as $class) { |
|
| 71 | + foreach ($classes as $class){ |
|
| 72 | 72 | // If attribute is defined on class level and class has target attribute |
| 73 | 73 | // then we can add it to the list of classes |
| 74 | 74 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
| 75 | 75 | && $this->reader->firstClassMetadata($class, $target->getName()) |
| 76 | - ) { |
|
| 76 | + ){ |
|
| 77 | 77 | yield $class->getName(); |
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // If attribute is defined on method level and class methods has target attribute |
| 82 | 82 | // then we can add it to the list of classes |
| 83 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 84 | - foreach ($class->getMethods() as $method) { |
|
| 85 | - if ($this->reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 83 | + if ($attribute->flags & \Attribute::TARGET_METHOD){ |
|
| 84 | + foreach ($class->getMethods() as $method){ |
|
| 85 | + if ($this->reader->firstFunctionMetadata($method, $target->getName())){ |
|
| 86 | 86 | yield $class->getName(); |
| 87 | 87 | continue 2; |
| 88 | 88 | } |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | // If attribute is defined on property level and class properties has target attribute |
| 93 | 93 | // then we can add it to the list of classes |
| 94 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 95 | - foreach ($class->getProperties() as $property) { |
|
| 96 | - if ($this->reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 94 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY){ |
|
| 95 | + foreach ($class->getProperties() as $property){ |
|
| 96 | + if ($this->reader->firstPropertyMetadata($property, $target->getName())){ |
|
| 97 | 97 | yield $class->getName(); |
| 98 | 98 | continue 2; |
| 99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // If attribute is defined on constant level and class constants has target attribute |
| 105 | 105 | // then we can add it to the list of classes |
| 106 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 107 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 108 | - if ($this->reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 106 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){ |
|
| 107 | + foreach ($class->getReflectionConstants() as $constant){ |
|
| 108 | + if ($this->reader->firstConstantMetadata($constant, $target->getName())){ |
|
| 109 | 109 | yield $class->getName(); |
| 110 | 110 | continue 2; |
| 111 | 111 | } |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 117 | 117 | // then we can add it to the list of classes |
| 118 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 119 | - foreach ($class->getMethods() as $method) { |
|
| 120 | - foreach ($method->getParameters() as $parameter) { |
|
| 121 | - if ($this->reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 118 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER){ |
|
| 119 | + foreach ($class->getMethods() as $method){ |
|
| 120 | + foreach ($method->getParameters() as $parameter){ |
|
| 121 | + if ($this->reader->firstParameterMetadata($parameter, $target->getName())){ |
|
| 122 | 122 | yield $class->getName(); |
| 123 | 123 | continue 3; |
| 124 | 124 | } |
@@ -45,16 +45,20 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | private function getClassesForClass(array $classes, \ReflectionClass $target): \Generator |
| 47 | 47 | { |
| 48 | - foreach ($classes as $class) { |
|
| 49 | - if (!$target->isTrait()) { |
|
| 50 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
| 48 | + foreach ($classes as $class) |
|
| 49 | + { |
|
| 50 | + if (!$target->isTrait()) |
|
| 51 | + { |
|
| 52 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) |
|
| 53 | + { |
|
| 51 | 54 | yield $class->getName(); |
| 52 | 55 | continue; |
| 53 | 56 | } |
| 54 | 57 | } |
| 55 | 58 | |
| 56 | 59 | // Checking using traits |
| 57 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()))) { |
|
| 60 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()))) |
|
| 61 | + { |
|
| 58 | 62 | yield $class->getName(); |
| 59 | 63 | } |
| 60 | 64 | } |
@@ -68,7 +72,8 @@ discard block |
||
| 68 | 72 | */ |
| 69 | 73 | private function getClassesForAttribute(array $classes, \ReflectionClass $target, \Attribute $attribute): \Generator |
| 70 | 74 | { |
| 71 | - foreach ($classes as $class) { |
|
| 75 | + foreach ($classes as $class) |
|
| 76 | + { |
|
| 72 | 77 | // If attribute is defined on class level and class has target attribute |
| 73 | 78 | // then we can add it to the list of classes |
| 74 | 79 | if (($attribute->flags & \Attribute::TARGET_CLASS) |
@@ -80,9 +85,12 @@ discard block |
||
| 80 | 85 | |
| 81 | 86 | // If attribute is defined on method level and class methods has target attribute |
| 82 | 87 | // then we can add it to the list of classes |
| 83 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 84 | - foreach ($class->getMethods() as $method) { |
|
| 85 | - if ($this->reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 88 | + if ($attribute->flags & \Attribute::TARGET_METHOD) |
|
| 89 | + { |
|
| 90 | + foreach ($class->getMethods() as $method) |
|
| 91 | + { |
|
| 92 | + if ($this->reader->firstFunctionMetadata($method, $target->getName())) |
|
| 93 | + { |
|
| 86 | 94 | yield $class->getName(); |
| 87 | 95 | continue 2; |
| 88 | 96 | } |
@@ -91,9 +99,12 @@ discard block |
||
| 91 | 99 | |
| 92 | 100 | // If attribute is defined on property level and class properties has target attribute |
| 93 | 101 | // then we can add it to the list of classes |
| 94 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 95 | - foreach ($class->getProperties() as $property) { |
|
| 96 | - if ($this->reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 102 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY) |
|
| 103 | + { |
|
| 104 | + foreach ($class->getProperties() as $property) |
|
| 105 | + { |
|
| 106 | + if ($this->reader->firstPropertyMetadata($property, $target->getName())) |
|
| 107 | + { |
|
| 97 | 108 | yield $class->getName(); |
| 98 | 109 | continue 2; |
| 99 | 110 | } |
@@ -103,9 +114,12 @@ discard block |
||
| 103 | 114 | |
| 104 | 115 | // If attribute is defined on constant level and class constants has target attribute |
| 105 | 116 | // then we can add it to the list of classes |
| 106 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 107 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 108 | - if ($this->reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 117 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) |
|
| 118 | + { |
|
| 119 | + foreach ($class->getReflectionConstants() as $constant) |
|
| 120 | + { |
|
| 121 | + if ($this->reader->firstConstantMetadata($constant, $target->getName())) |
|
| 122 | + { |
|
| 109 | 123 | yield $class->getName(); |
| 110 | 124 | continue 2; |
| 111 | 125 | } |
@@ -115,10 +129,14 @@ discard block |
||
| 115 | 129 | |
| 116 | 130 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 117 | 131 | // then we can add it to the list of classes |
| 118 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 119 | - foreach ($class->getMethods() as $method) { |
|
| 120 | - foreach ($method->getParameters() as $parameter) { |
|
| 121 | - if ($this->reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 132 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER) |
|
| 133 | + { |
|
| 134 | + foreach ($class->getMethods() as $method) |
|
| 135 | + { |
|
| 136 | + foreach ($method->getParameters() as $parameter) |
|
| 137 | + { |
|
| 138 | + if ($this->reader->firstParameterMetadata($parameter, $target->getName())) |
|
| 139 | + { |
|
| 122 | 140 | yield $class->getName(); |
| 123 | 141 | continue 3; |
| 124 | 142 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function invoke(TokenizationListenerInterface $listener, iterable $classes): void |
| 15 | 15 | { |
| 16 | - foreach ($classes as $class) { |
|
| 16 | + foreach ($classes as $class){ |
|
| 17 | 17 | $listener->listen($class); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -13,7 +13,8 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function invoke(TokenizationListenerInterface $listener, iterable $classes): void |
| 15 | 15 | { |
| 16 | - foreach ($classes as $class) { |
|
| 16 | + foreach ($classes as $class) |
|
| 17 | + { |
|
| 17 | 18 | $listener->listen($class); |
| 18 | 19 | } |
| 19 | 20 | |
@@ -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,9 +31,9 @@ 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 | $classes = $this->memory->loadData($definition->getHash()); |
| 36 | - if ($classes === null) { |
|
| 36 | + if ($classes === null){ |
|
| 37 | 37 | $this->memory->saveData( |
| 38 | 38 | $definition->getHash(), |
| 39 | 39 | $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,9 +32,11 @@ 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 | $classes = $this->memory->loadData($definition->getHash()); |
| 36 | - if ($classes === null) { |
|
| 38 | + if ($classes === null) |
|
| 39 | + { |
|
| 37 | 40 | $this->memory->saveData( |
| 38 | 41 | $definition->getHash(), |
| 39 | 42 | $classes = $this->cacheBuilder->getClasses($definition) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly ReaderInterface $reader |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $listener = new \ReflectionClass($listener); |
| 27 | 27 | |
| 28 | - foreach ($this->reader->getClassMetadata($listener, ListenForClasses::class) as $attribute) { |
|
| 28 | + foreach ($this->reader->getClassMetadata($listener, ListenForClasses::class) as $attribute){ |
|
| 29 | 29 | // Analyze the target class from ListenForClasses attribute. |
| 30 | 30 | $refl = new \ReflectionClass($attribute->target); |
| 31 | 31 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $attr = $refl->getAttributes(\Attribute::class)[0] ?? null; |
| 34 | 34 | |
| 35 | 35 | // If the target class has no attribute, then it's a normal class or interface. |
| 36 | - if ($attr === null) { |
|
| 36 | + if ($attr === null){ |
|
| 37 | 37 | yield new ListenerDefinition( |
| 38 | 38 | listenerClass: $listener->getName(), |
| 39 | 39 | target: $refl, |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $listener = new \ReflectionClass($listener); |
| 27 | 27 | |
| 28 | - foreach ($this->reader->getClassMetadata($listener, ListenForClasses::class) as $attribute) { |
|
| 28 | + foreach ($this->reader->getClassMetadata($listener, ListenForClasses::class) as $attribute) |
|
| 29 | + { |
|
| 29 | 30 | // Analyze the target class from ListenForClasses attribute. |
| 30 | 31 | $refl = new \ReflectionClass($attribute->target); |
| 31 | 32 | |
@@ -33,7 +34,8 @@ discard block |
||
| 33 | 34 | $attr = $refl->getAttributes(\Attribute::class)[0] ?? null; |
| 34 | 35 | |
| 35 | 36 | // If the target class has no attribute, then it's a normal class or interface. |
| 36 | - if ($attr === null) { |
|
| 37 | + if ($attr === null) |
|
| 38 | + { |
|
| 37 | 39 | yield new ListenerDefinition( |
| 38 | 40 | listenerClass: $listener->getName(), |
| 39 | 41 | target: $refl, |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | public readonly string $listenerClass, |
| 19 | 19 | public readonly \ReflectionClass $target, |
| 20 | 20 | public readonly ?string $scope = null, |
| 21 | - public readonly ?\Attribute $attribute = null, |
|
| 22 | - ) { |
|
| 21 | + public readonly ? \Attribute $attribute = null, |
|
| 22 | + ){ |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function getHash(): string |
| 26 | 26 | { |
| 27 | - return \md5($this->target->getName() . $this->scope); |
|
| 27 | + return \md5($this->target->getName().$this->scope); |
|
| 28 | 28 | } |
| 29 | 29 | } |