Test Failed
Pull Request — master (#878)
by butschster
17:28 queued 07:56
created
src/Tokenizer/src/Listener/ListenerInvoker.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      */
17 17
     public function invoke(TokenizationListenerInterface $listener, iterable $classes): void
18 18
     {
19
-        foreach ($classes as $class) {
19
+        foreach ($classes as $class){
20 20
             $listener->listen($class);
21 21
         }
22 22
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@
 block discarded – undo
16 16
      */
17 17
     public function invoke(TokenizationListenerInterface $listener, iterable $classes): void
18 18
     {
19
-        foreach ($classes as $class) {
19
+        foreach ($classes as $class)
20
+        {
20 21
             $listener->listen($class);
21 22
         }
22 23
 
Please login to merge, or discard this patch.
src/Tokenizer/src/Listener/CachedClassesLoader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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),
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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),
Please login to merge, or discard this patch.
src/Tokenizer/src/Attribute/TargetAttribute.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function __construct(
24 24
         public readonly string $class,
25 25
         public readonly ?string $scope = null,
26
-    ) {
26
+    ){
27 27
     }
28 28
 
29 29
     public function filter(array $classes): \Generator
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
         $attribute = $target->getAttributes(\Attribute::class)[0] ?? null;
33 33
         $reader = (new Factory())->create();
34 34
 
35
-        if ($attribute === null) {
35
+        if ($attribute === null){
36 36
             return;
37 37
         }
38 38
 
39 39
         $attribute = $attribute->newInstance();
40 40
 
41
-        foreach ($classes as $class) {
41
+        foreach ($classes as $class){
42 42
             // If attribute is defined on class level and class has target attribute
43 43
             // then we can add it to the list of classes
44 44
             if (($attribute->flags & \Attribute::TARGET_CLASS)
45 45
                 && $reader->firstClassMetadata($class, $target->getName())
46
-            ) {
46
+            ){
47 47
                 yield $class->getName();
48 48
                 continue;
49 49
             }
50 50
 
51 51
             // If attribute is defined on method level and class methods has target attribute
52 52
             // then we can add it to the list of classes
53
-            if ($attribute->flags & \Attribute::TARGET_METHOD) {
54
-                foreach ($class->getMethods() as $method) {
55
-                    if ($reader->firstFunctionMetadata($method, $target->getName())) {
53
+            if ($attribute->flags & \Attribute::TARGET_METHOD){
54
+                foreach ($class->getMethods() as $method){
55
+                    if ($reader->firstFunctionMetadata($method, $target->getName())){
56 56
                         yield $class->getName();
57 57
                         continue 2;
58 58
                     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
             // If attribute is defined on property level and class properties has target attribute
63 63
             // then we can add it to the list of classes
64
-            if ($attribute->flags & \Attribute::TARGET_PROPERTY) {
65
-                foreach ($class->getProperties() as $property) {
66
-                    if ($reader->firstPropertyMetadata($property, $target->getName())) {
64
+            if ($attribute->flags & \Attribute::TARGET_PROPERTY){
65
+                foreach ($class->getProperties() as $property){
66
+                    if ($reader->firstPropertyMetadata($property, $target->getName())){
67 67
                         yield $class->getName();
68 68
                         continue 2;
69 69
                     }
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
             // If attribute is defined on constant level and class constants has target attribute
75 75
             // then we can add it to the list of classes
76
-            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) {
77
-                foreach ($class->getReflectionConstants() as $constant) {
78
-                    if ($reader->firstConstantMetadata($constant, $target->getName())) {
76
+            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){
77
+                foreach ($class->getReflectionConstants() as $constant){
78
+                    if ($reader->firstConstantMetadata($constant, $target->getName())){
79 79
                         yield $class->getName();
80 80
                         continue 2;
81 81
                     }
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 
86 86
             // If attribute is defined on method parameters level and class method parameter has target attribute
87 87
             // then we can add it to the list of classes
88
-            if ($attribute->flags & \Attribute::TARGET_PARAMETER) {
89
-                foreach ($class->getMethods() as $method) {
90
-                    foreach ($method->getParameters() as $parameter) {
91
-                        if ($reader->firstParameterMetadata($parameter, $target->getName())) {
88
+            if ($attribute->flags & \Attribute::TARGET_PARAMETER){
89
+                foreach ($class->getMethods() as $method){
90
+                    foreach ($method->getParameters() as $parameter){
91
+                        if ($reader->firstParameterMetadata($parameter, $target->getName())){
92 92
                             yield $class->getName();
93 93
                             continue 3;
94 94
                         }
@@ -105,6 +105,6 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function getCacheKey(): string
107 107
     {
108
-        return \md5($this->class . $this->scope);
108
+        return \md5($this->class.$this->scope);
109 109
     }
110 110
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,13 +32,15 @@  discard block
 block discarded – undo
32 32
         $attribute = $target->getAttributes(\Attribute::class)[0] ?? null;
33 33
         $reader = (new Factory())->create();
34 34
 
35
-        if ($attribute === null) {
35
+        if ($attribute === null)
36
+        {
36 37
             return;
37 38
         }
38 39
 
39 40
         $attribute = $attribute->newInstance();
40 41
 
41
-        foreach ($classes as $class) {
42
+        foreach ($classes as $class)
43
+        {
42 44
             // If attribute is defined on class level and class has target attribute
43 45
             // then we can add it to the list of classes
44 46
             if (($attribute->flags & \Attribute::TARGET_CLASS)
@@ -50,9 +52,12 @@  discard block
 block discarded – undo
50 52
 
51 53
             // If attribute is defined on method level and class methods has target attribute
52 54
             // then we can add it to the list of classes
53
-            if ($attribute->flags & \Attribute::TARGET_METHOD) {
54
-                foreach ($class->getMethods() as $method) {
55
-                    if ($reader->firstFunctionMetadata($method, $target->getName())) {
55
+            if ($attribute->flags & \Attribute::TARGET_METHOD)
56
+            {
57
+                foreach ($class->getMethods() as $method)
58
+                {
59
+                    if ($reader->firstFunctionMetadata($method, $target->getName()))
60
+                    {
56 61
                         yield $class->getName();
57 62
                         continue 2;
58 63
                     }
@@ -61,9 +66,12 @@  discard block
 block discarded – undo
61 66
 
62 67
             // If attribute is defined on property level and class properties has target attribute
63 68
             // then we can add it to the list of classes
64
-            if ($attribute->flags & \Attribute::TARGET_PROPERTY) {
65
-                foreach ($class->getProperties() as $property) {
66
-                    if ($reader->firstPropertyMetadata($property, $target->getName())) {
69
+            if ($attribute->flags & \Attribute::TARGET_PROPERTY)
70
+            {
71
+                foreach ($class->getProperties() as $property)
72
+                {
73
+                    if ($reader->firstPropertyMetadata($property, $target->getName()))
74
+                    {
67 75
                         yield $class->getName();
68 76
                         continue 2;
69 77
                     }
@@ -73,9 +81,12 @@  discard block
 block discarded – undo
73 81
 
74 82
             // If attribute is defined on constant level and class constants has target attribute
75 83
             // then we can add it to the list of classes
76
-            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) {
77
-                foreach ($class->getReflectionConstants() as $constant) {
78
-                    if ($reader->firstConstantMetadata($constant, $target->getName())) {
84
+            if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT)
85
+            {
86
+                foreach ($class->getReflectionConstants() as $constant)
87
+                {
88
+                    if ($reader->firstConstantMetadata($constant, $target->getName()))
89
+                    {
79 90
                         yield $class->getName();
80 91
                         continue 2;
81 92
                     }
@@ -85,10 +96,14 @@  discard block
 block discarded – undo
85 96
 
86 97
             // If attribute is defined on method parameters level and class method parameter has target attribute
87 98
             // then we can add it to the list of classes
88
-            if ($attribute->flags & \Attribute::TARGET_PARAMETER) {
89
-                foreach ($class->getMethods() as $method) {
90
-                    foreach ($method->getParameters() as $parameter) {
91
-                        if ($reader->firstParameterMetadata($parameter, $target->getName())) {
99
+            if ($attribute->flags & \Attribute::TARGET_PARAMETER)
100
+            {
101
+                foreach ($class->getMethods() as $method)
102
+                {
103
+                    foreach ($method->getParameters() as $parameter)
104
+                    {
105
+                        if ($reader->firstParameterMetadata($parameter, $target->getName()))
106
+                        {
92 107
                             yield $class->getName();
93 108
                             continue 3;
94 109
                         }
Please login to merge, or discard this patch.
src/Tokenizer/src/Attribute/TargetClass.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@  discard block
 block discarded – undo
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
                     continue;
40 40
                 }
41 41
             }
42 42
 
43 43
             // Checking using traits
44
-            if (\in_array($target->getName(), $this->fetchTraits($class->getName()))) {
44
+            if (\in_array($target->getName(), $this->fetchTraits($class->getName()))){
45 45
                 yield $class->getName();
46 46
             }
47 47
         }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function getCacheKey(): string
51 51
     {
52
-        return \md5($this->class . $this->scope);
52
+        return \md5($this->class.$this->scope);
53 53
     }
54 54
 
55 55
     public function getScope(): ?string
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,16 +32,20 @@
 block discarded – undo
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
                     continue;
40 43
                 }
41 44
             }
42 45
 
43 46
             // Checking using traits
44
-            if (\in_array($target->getName(), $this->fetchTraits($class->getName()))) {
47
+            if (\in_array($target->getName(), $this->fetchTraits($class->getName())))
48
+            {
45 49
                 yield $class->getName();
46 50
             }
47 51
         }
Please login to merge, or discard this patch.
src/Tokenizer/src/AbstractLocator.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Tokenizer/src/Bootloader/TokenizerListenerBootloader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
93 93
         // If you want to disable the cache, you can use the TOKENIZER_WARMUP environment variable.
94 94
         $memory = $env->get('TOKENIZER_WARMUP', $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
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,15 +58,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Tokenizer/src/Bootloader/TokenizerBootloader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.