Passed
Pull Request — master (#1221)
by Aleksei
12:41
created
src/Tokenizer/src/EnumsInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,5 +18,5 @@
 block discarded – undo
18 18
      *
19 19
      * @return array<class-string, \ReflectionEnum>
20 20
      */
21
-    public function getEnums(object|string|null $target = null): array;
21
+    public function getEnums(object | string | null $target = null): array;
22 22
 }
Please login to merge, or discard this patch.
src/Tokenizer/src/InterfacesInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
19 19
      *                                  results.
20 20
      * @return array<class-string, \ReflectionClass>
21 21
      */
22
-    public function getInterfaces(string|null $target = null): array;
22
+    public function getInterfaces(string | null $target = null): array;
23 23
 }
Please login to merge, or discard this patch.
src/Tokenizer/src/ScopedInterfaceLocator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly Tokenizer $tokenizer,
11
-    ) {}
11
+    ){}
12 12
 
13
-    public function getScopedInterfaces(string $scope, string|null $target = null): array
13
+    public function getScopedInterfaces(string $scope, string | null $target = null): array
14 14
     {
15 15
         return $this->tokenizer->scopedInterfaceLocator($scope)->getInterfaces($target);
16 16
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly Tokenizer $tokenizer,
11
-    ) {}
11
+    ) {
12
+}
12 13
 
13 14
     public function getScopedInterfaces(string $scope, string|null $target = null): array
14 15
     {
Please login to merge, or discard this patch.
src/Tokenizer/src/InterfaceLocatorInjector.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 __construct(
18 18
         private readonly Tokenizer $tokenizer,
19
-    ) {}
19
+    ){}
20 20
 
21 21
     /**
22 22
      * @throws InjectionException
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 __construct(
18 18
         private readonly Tokenizer $tokenizer,
19
-    ) {}
19
+    ) {
20
+}
20 21
 
21 22
     /**
22 23
      * @throws InjectionException
Please login to merge, or discard this patch.
src/Tokenizer/src/ClassesInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
19 19
      *                                          results.
20 20
      * @return array<class-string, \ReflectionClass>
21 21
      */
22
-    public function getClasses(object|string|null $target = null): array;
22
+    public function getClasses(object | string | null $target = null): array;
23 23
 }
Please login to merge, or discard this patch.
src/Tokenizer/src/ScopedEnumLocator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly Tokenizer $tokenizer,
11
-    ) {}
11
+    ){}
12 12
 
13
-    public function getScopedEnums(string $scope, object|string|null $target = null): array
13
+    public function getScopedEnums(string $scope, object | string | null $target = null): array
14 14
     {
15 15
         return $this->tokenizer->scopedEnumLocator($scope)->getEnums($target);
16 16
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly Tokenizer $tokenizer,
11
-    ) {}
11
+    ) {
12
+}
12 13
 
13 14
     public function getScopedEnums(string $scope, object|string|null $target = null): array
14 15
     {
Please login to merge, or discard this patch.
src/Tokenizer/src/AbstractLocator.php 2 patches
Spacing   +20 added lines, -20 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
      * Available file reflections. Generator.
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected function availableReflections(): \Generator
37 37
     {
38
-        foreach ($this->finder->getIterator() as $file) {
39
-            $reflection = new ReflectionFile((string) $file);
38
+        foreach ($this->finder->getIterator() as $file){
39
+            $reflection = new ReflectionFile((string)$file);
40 40
 
41
-            if ($reflection->hasIncludes()) {
41
+            if ($reflection->hasIncludes()){
42 42
                 // We are not analyzing files which has includes, it's not safe to require such reflections
43
-                if ($this->debug) {
43
+                if ($this->debug){
44 44
                     $this->getLogger()->warning(
45
-                        \sprintf('File `%s` has includes and excluded from analysis', (string) $file),
45
+                        \sprintf('File `%s` has includes and excluded from analysis', (string)$file),
46 46
                         ['file' => $file],
47 47
                     );
48 48
                 }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     protected function classReflection(string $class): \ReflectionClass
68 68
     {
69 69
         $loader = static function ($class): void {
70
-            if ($class === LocatorException::class) {
70
+            if ($class === LocatorException::class){
71 71
                 return;
72 72
             }
73 73
 
@@ -77,24 +77,24 @@  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
 
89
-            if ($this->debug) {
89
+            if ($this->debug){
90 90
                 $this->getLogger()->error(
91 91
                     \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()),
92 92
                     ['error' => $e],
93 93
                 );
94 94
             }
95 95
 
96
-            throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e);
97
-        } finally {
96
+            throw new LocatorException($e->getMessage(), (int)$e->getCode(), $e);
97
+        }finally{
98 98
             \spl_autoload_unregister($loader);
99 99
         }
100 100
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     protected function enumReflection(string $enum): \ReflectionEnum
111 111
     {
112 112
         $loader = static function (string $enum): void {
113
-            if ($enum === LocatorException::class) {
113
+            if ($enum === LocatorException::class){
114 114
                 return;
115 115
             }
116 116
 
@@ -120,24 +120,24 @@  discard block
 block discarded – undo
120 120
         //To suspend class dependency exception
121 121
         \spl_autoload_register($loader);
122 122
 
123
-        try {
123
+        try{
124 124
             //In some enum reflection can thrown an exception if enum invalid or can not be loaded,
125 125
             //we are going to handle such exception and convert it soft exception
126 126
             return new \ReflectionEnum($enum);
127
-        } catch (\Throwable $e) {
128
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
127
+        }catch (\Throwable $e){
128
+            if ($e instanceof LocatorException && $e->getPrevious() != null){
129 129
                 $e = $e->getPrevious();
130 130
             }
131 131
 
132
-            if ($this->debug) {
132
+            if ($this->debug){
133 133
                 $this->getLogger()->error(
134 134
                     \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()),
135 135
                     ['error' => $e],
136 136
                 );
137 137
             }
138 138
 
139
-            throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e);
140
-        } finally {
139
+            throw new LocatorException($e->getMessage(), (int)$e->getCode(), $e);
140
+        }finally{
141 141
             \spl_autoload_unregister($loader);
142 142
         }
143 143
     }
Please login to merge, or discard this patch.
Braces   +36 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  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 32
      * Available file reflections. Generator.
@@ -35,12 +36,15 @@  discard block
 block discarded – undo
35 36
      */
36 37
     protected function availableReflections(): \Generator
37 38
     {
38
-        foreach ($this->finder->getIterator() as $file) {
39
+        foreach ($this->finder->getIterator() as $file)
40
+        {
39 41
             $reflection = new ReflectionFile((string) $file);
40 42
 
41
-            if ($reflection->hasIncludes()) {
43
+            if ($reflection->hasIncludes())
44
+            {
42 45
                 // We are not analyzing files which has includes, it's not safe to require such reflections
43
-                if ($this->debug) {
46
+                if ($this->debug)
47
+                {
44 48
                     $this->getLogger()->warning(
45 49
                         \sprintf('File `%s` has includes and excluded from analysis', (string) $file),
46 50
                         ['file' => $file],
@@ -67,7 +71,8 @@  discard block
 block discarded – undo
67 71
     protected function classReflection(string $class): \ReflectionClass
68 72
     {
69 73
         $loader = static function ($class): void {
70
-            if ($class === LocatorException::class) {
74
+            if ($class === LocatorException::class)
75
+            {
71 76
                 return;
72 77
             }
73 78
 
@@ -77,16 +82,21 @@  discard block
 block discarded – undo
77 82
         //To suspend class dependency exception
78 83
         \spl_autoload_register($loader);
79 84
 
80
-        try {
85
+        try
86
+        {
81 87
             //In some cases reflection can thrown an exception if class invalid or can not be loaded,
82 88
             //we are going to handle such exception and convert it soft exception
83 89
             return new \ReflectionClass($class);
84
-        } catch (\Throwable $e) {
85
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
90
+        }
91
+        catch (\Throwable $e)
92
+        {
93
+            if ($e instanceof LocatorException && $e->getPrevious() != null)
94
+            {
86 95
                 $e = $e->getPrevious();
87 96
             }
88 97
 
89
-            if ($this->debug) {
98
+            if ($this->debug)
99
+            {
90 100
                 $this->getLogger()->error(
91 101
                     \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()),
92 102
                     ['error' => $e],
@@ -94,7 +104,9 @@  discard block
 block discarded – undo
94 104
             }
95 105
 
96 106
             throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e);
97
-        } finally {
107
+        }
108
+        finally
109
+        {
98 110
             \spl_autoload_unregister($loader);
99 111
         }
100 112
     }
@@ -110,7 +122,8 @@  discard block
 block discarded – undo
110 122
     protected function enumReflection(string $enum): \ReflectionEnum
111 123
     {
112 124
         $loader = static function (string $enum): void {
113
-            if ($enum === LocatorException::class) {
125
+            if ($enum === LocatorException::class)
126
+            {
114 127
                 return;
115 128
             }
116 129
 
@@ -120,16 +133,21 @@  discard block
 block discarded – undo
120 133
         //To suspend class dependency exception
121 134
         \spl_autoload_register($loader);
122 135
 
123
-        try {
136
+        try
137
+        {
124 138
             //In some enum reflection can thrown an exception if enum invalid or can not be loaded,
125 139
             //we are going to handle such exception and convert it soft exception
126 140
             return new \ReflectionEnum($enum);
127
-        } catch (\Throwable $e) {
128
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
141
+        }
142
+        catch (\Throwable $e)
143
+        {
144
+            if ($e instanceof LocatorException && $e->getPrevious() != null)
145
+            {
129 146
                 $e = $e->getPrevious();
130 147
             }
131 148
 
132
-            if ($this->debug) {
149
+            if ($this->debug)
150
+            {
133 151
                 $this->getLogger()->error(
134 152
                     \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()),
135 153
                     ['error' => $e],
@@ -137,7 +155,9 @@  discard block
 block discarded – undo
137 155
             }
138 156
 
139 157
             throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e);
140
-        } finally {
158
+        }
159
+        finally
160
+        {
141 161
             \spl_autoload_unregister($loader);
142 162
         }
143 163
     }
Please login to merge, or discard this patch.
src/Tokenizer/src/Config/TokenizerConfig.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function isDebug(): bool
50 50
     {
51
-        return (bool) ($this->config['debug'] ?? false);
51
+        return (bool)($this->config['debug'] ?? false);
52 52
     }
53 53
 
54 54
     /**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getDirectories(): array
58 58
     {
59
-        return $this->config['directories'] ?? [(string) \getcwd()];
59
+        return $this->config['directories'] ?? [(string)\getcwd()];
60 60
     }
61 61
 
62 62
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function isCacheEnabled(): bool
93 93
     {
94
-        return (bool) ($this->config['cache']['enabled'] ?? false);
94
+        return (bool)($this->config['cache']['enabled'] ?? false);
95 95
     }
96 96
 
97 97
     /**
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
 
108 108
     public function isLoadClassesEnabled(): bool
109 109
     {
110
-        return (bool) ($this->config['load']['classes'] ?? true);
110
+        return (bool)($this->config['load']['classes'] ?? true);
111 111
     }
112 112
 
113 113
     public function isLoadEnumsEnabled(): bool
114 114
     {
115
-        return (bool) ($this->config['load']['enums'] ?? false);
115
+        return (bool)($this->config['load']['enums'] ?? false);
116 116
     }
117 117
 
118 118
     public function isLoadInterfacesEnabled(): bool
119 119
     {
120
-        return (bool) ($this->config['load']['interfaces'] ?? false);
120
+        return (bool)($this->config['load']['interfaces'] ?? false);
121 121
     }
122 122
 }
Please login to merge, or discard this patch.
src/Tokenizer/src/Tokenizer.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function __construct(
26 26
         private readonly TokenizerConfig $config,
27
-    ) {}
27
+    ){}
28 28
 
29 29
     /**
30 30
      * Get all tokes for specific file.
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
         $tokens = \token_get_all(\file_get_contents($filename));
35 35
 
36 36
         $line = 0;
37
-        foreach ($tokens as &$token) {
38
-            if (isset($token[self::LINE])) {
37
+        foreach ($tokens as &$token){
38
+            if (isset($token[self::LINE])){
39 39
                 $line = $token[self::LINE];
40 40
             }
41 41
 
42
-            if (!\is_array($token)) {
42
+            if (!\is_array($token)){
43 43
                 $token = [$token, $token, $line];
44 44
             }
45 45
 
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $finder = new Finder();
123 123
 
124
-        if (empty($directories)) {
124
+        if (empty($directories)){
125 125
             $directories = $this->config->getDirectories();
126 126
         }
127 127
 
128
-        if (empty($exclude)) {
128
+        if (empty($exclude)){
129 129
             $exclude = $this->config->getExcludes();
130 130
         }
131 131
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function __construct(
26 26
         private readonly TokenizerConfig $config,
27
-    ) {}
27
+    ) {
28
+}
28 29
 
29 30
     /**
30 31
      * Get all tokes for specific file.
@@ -34,12 +35,15 @@  discard block
 block discarded – undo
34 35
         $tokens = \token_get_all(\file_get_contents($filename));
35 36
 
36 37
         $line = 0;
37
-        foreach ($tokens as &$token) {
38
-            if (isset($token[self::LINE])) {
38
+        foreach ($tokens as &$token)
39
+        {
40
+            if (isset($token[self::LINE]))
41
+            {
39 42
                 $line = $token[self::LINE];
40 43
             }
41 44
 
42
-            if (!\is_array($token)) {
45
+            if (!\is_array($token))
46
+            {
43 47
                 $token = [$token, $token, $line];
44 48
             }
45 49
 
@@ -121,11 +125,13 @@  discard block
 block discarded – undo
121 125
     {
122 126
         $finder = new Finder();
123 127
 
124
-        if (empty($directories)) {
128
+        if (empty($directories))
129
+        {
125 130
             $directories = $this->config->getDirectories();
126 131
         }
127 132
 
128
-        if (empty($exclude)) {
133
+        if (empty($exclude))
134
+        {
129 135
             $exclude = $this->config->getExcludes();
130 136
         }
131 137
 
Please login to merge, or discard this patch.