Test Failed
Pull Request — master (#878)
by butschster
08:18
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/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.
src/Tokenizer/src/Attribute/TargetAttribute.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -15 removed lines patch added patch discarded remove patch
@@ -39,13 +39,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                         }
Please login to merge, or discard this patch.
src/AnnotatedRoutes/src/RouteLocatorListener.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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']),
Please login to merge, or discard this patch.