Passed
Pull Request — master (#1221)
by Aleksei
12:41
created
src/Tokenizer/src/Exception/ReflectionException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
 /**
8 8
  * Exceptions happen while parsing files or method/function calls.
9 9
  */
10
-class ReflectionException extends TokenizerException {}
10
+class ReflectionException extends TokenizerException{}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,6 @@
 block discarded – undo
7 7
 /**
8 8
  * Exceptions happen while parsing files or method/function calls.
9 9
  */
10
-class ReflectionException extends TokenizerException {}
10
+class ReflectionException extends TokenizerException
11
+{
12
+}
Please login to merge, or discard this patch.
src/Tokenizer/src/Exception/LocatorException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
 /**
8 8
  * Raised when class can not be loaded.
9 9
  */
10
-class LocatorException extends TokenizerException {}
10
+class LocatorException extends TokenizerException{}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,6 @@
 block discarded – undo
7 7
 /**
8 8
  * Raised when class can not be loaded.
9 9
  */
10
-class LocatorException extends TokenizerException {}
10
+class LocatorException extends TokenizerException
11
+{
12
+}
Please login to merge, or discard this patch.
src/Tokenizer/src/Bootloader/TokenizerBootloader.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function __construct(
49 49
         private readonly ConfiguratorInterface $config,
50
-    ) {}
50
+    ){}
51 51
 
52 52
     public function init(BinderInterface $binder, DirectoriesInterface $dirs, EnvironmentInterface $env): void
53 53
     {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     'migrations',
69 69
                 ],
70 70
                 'cache' => [
71
-                    'directory' => $dirs->get('runtime') . 'cache/listeners',
71
+                    'directory' => $dirs->get('runtime').'cache/listeners',
72 72
                     'enabled' => \filter_var($env->get('TOKENIZER_CACHE_TARGETS', false), \FILTER_VALIDATE_BOOL),
73 73
                 ],
74 74
                 'load' => [
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
         $this->config->modify(
104 104
             TokenizerConfig::CONFIG,
105
-            new Append('scopes.' . $scope . '.directories', null, $directory),
105
+            new Append('scopes.'.$scope.'.directories', null, $directory),
106 106
         );
107 107
     }
108 108
 
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
 
118 118
         $this->config->modify(
119 119
             TokenizerConfig::CONFIG,
120
-            new Append('scopes.' . $scope . '.exclude', null, $directory),
120
+            new Append('scopes.'.$scope.'.exclude', null, $directory),
121 121
         );
122 122
     }
123 123
 
124 124
     private function ensureScopeExists(string $scope, string $section): void
125 125
     {
126
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])) {
126
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])){
127 127
             $this->config->modify(
128 128
                 TokenizerConfig::CONFIG,
129 129
                 new Set('scopes', []),
130 130
             );
131 131
         }
132 132
 
133
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) {
133
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])){
134 134
             $this->config->modify(
135 135
                 TokenizerConfig::CONFIG,
136 136
                 new Append('scopes', $scope, [$section => []]),
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function __construct(
49 49
         private readonly ConfiguratorInterface $config,
50
-    ) {}
50
+    ) {
51
+}
51 52
 
52 53
     public function init(BinderInterface $binder, DirectoriesInterface $dirs, EnvironmentInterface $env): void
53 54
     {
@@ -123,14 +124,16 @@  discard block
 block discarded – undo
123 124
 
124 125
     private function ensureScopeExists(string $scope, string $section): void
125 126
     {
126
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'])) {
127
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes']))
128
+        {
127 129
             $this->config->modify(
128 130
                 TokenizerConfig::CONFIG,
129 131
                 new Set('scopes', []),
130 132
             );
131 133
         }
132 134
 
133
-        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) {
135
+        if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope]))
136
+        {
134 137
             $this->config->modify(
135 138
                 TokenizerConfig::CONFIG,
136 139
                 new Append('scopes', $scope, [$section => []]),
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionInvocation.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         private readonly array $arguments,
30 30
         private readonly string $source,
31 31
         private readonly int $level,
32
-    ) {}
32
+    ){}
33 33
 
34 34
     /**
35 35
      * Function usage filename.
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function getArgument(int $index): ReflectionArgument
114 114
     {
115
-        if (!isset($this->arguments[$index])) {
115
+        if (!isset($this->arguments[$index])){
116 116
             throw new ReflectionException(\sprintf("No such argument with index '%d'", $index));
117 117
         }
118 118
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
         private readonly array $arguments,
30 30
         private readonly string $source,
31 31
         private readonly int $level,
32
-    ) {}
32
+    ) {
33
+}
33 34
 
34 35
     /**
35 36
      * Function usage filename.
@@ -112,7 +113,8 @@  discard block
 block discarded – undo
112 113
      */
113 114
     public function getArgument(int $index): ReflectionArgument
114 115
     {
115
-        if (!isset($this->arguments[$index])) {
116
+        if (!isset($this->arguments[$index]))
117
+        {
116 118
             throw new ReflectionException(\sprintf("No such argument with index '%d'", $index));
117 119
         }
118 120
 
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionArgument.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * Argument types.
16 16
      */
17
-    public const CONSTANT   = 'constant';   //Scalar constant and not variable.
17
+    public const CONSTANT   = 'constant'; //Scalar constant and not variable.
18 18
 
19
-    public const VARIABLE   = 'variable';   //PHP variable
19
+    public const VARIABLE   = 'variable'; //PHP variable
20 20
     public const EXPRESSION = 'expression'; //PHP code (expression).
21
-    public const STRING     = 'string';     //Simple scalar string, can be fetched using stringValue().
21
+    public const STRING     = 'string'; //Simple scalar string, can be fetched using stringValue().
22 22
 
23 23
     /**
24 24
      * New instance of ReflectionArgument.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public function __construct(
30 30
         private string $type,
31 31
         private readonly string $value,
32
-    ) {}
32
+    ){}
33 33
 
34 34
     /**
35 35
      * Create Argument reflections based on provided set of tokens (fetched from invoke).
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
         $level = 0;
43 43
 
44 44
         $result = [];
45
-        foreach ($tokens as $token) {
46
-            if ($token[ReflectionFile::TOKEN_TYPE] === T_WHITESPACE) {
45
+        foreach ($tokens as $token){
46
+            if ($token[ReflectionFile::TOKEN_TYPE] === T_WHITESPACE){
47 47
                 continue;
48 48
             }
49 49
 
50
-            if (empty($definition)) {
50
+            if (empty($definition)){
51 51
                 $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []];
52 52
             }
53 53
 
54
-            if ($token[ReflectionFile::TOKEN_TYPE] === '(' || $token[ReflectionFile::TOKEN_TYPE] === '[') {
54
+            if ($token[ReflectionFile::TOKEN_TYPE] === '(' || $token[ReflectionFile::TOKEN_TYPE] === '['){
55 55
                 ++$level;
56 56
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
57 57
                 continue;
58 58
             }
59 59
 
60
-            if ($token[ReflectionFile::TOKEN_TYPE] === ')' || $token[ReflectionFile::TOKEN_TYPE] === ']') {
60
+            if ($token[ReflectionFile::TOKEN_TYPE] === ')' || $token[ReflectionFile::TOKEN_TYPE] === ']'){
61 61
                 --$level;
62 62
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
63 63
                 continue;
64 64
             }
65 65
 
66
-            if ($level) {
66
+            if ($level){
67 67
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
68 68
                 continue;
69 69
             }
70 70
 
71
-            if ($token[ReflectionFile::TOKEN_TYPE] === ',') {
71
+            if ($token[ReflectionFile::TOKEN_TYPE] === ','){
72 72
                 $result[] = self::createArgument($definition);
73 73
                 $definition = null;
74 74
                 continue;
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
         }
80 80
 
81 81
         //Last argument
82
-        if (\is_array($definition)) {
82
+        if (\is_array($definition)){
83 83
             $definition = self::createArgument($definition);
84
-            if (!empty($definition->getType())) {
84
+            if (!empty($definition->getType())){
85 85
                 $result[] = $definition;
86 86
             }
87 87
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function stringValue(): string
108 108
     {
109
-        if ($this->type !== self::STRING) {
109
+        if ($this->type !== self::STRING){
110 110
             throw new ReflectionException(
111 111
                 \sprintf("Unable to represent value as string, value type is '%s'", $this->type),
112 112
             );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $result = new self(self::EXPRESSION, $definition['value']);
128 128
 
129
-        if (\count($definition['tokens']) == 1) {
129
+        if (\count($definition['tokens']) == 1){
130 130
             $result->type = match ($definition['tokens'][0][0]) {
131 131
                 T_VARIABLE => self::VARIABLE,
132 132
                 T_LNUMBER, T_DNUMBER => self::CONSTANT,
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
     public function __construct(
30 30
         private string $type,
31 31
         private readonly string $value,
32
-    ) {}
32
+    ) {
33
+}
33 34
 
34 35
     /**
35 36
      * Create Argument reflections based on provided set of tokens (fetched from invoke).
@@ -42,33 +43,40 @@  discard block
 block discarded – undo
42 43
         $level = 0;
43 44
 
44 45
         $result = [];
45
-        foreach ($tokens as $token) {
46
-            if ($token[ReflectionFile::TOKEN_TYPE] === T_WHITESPACE) {
46
+        foreach ($tokens as $token)
47
+        {
48
+            if ($token[ReflectionFile::TOKEN_TYPE] === T_WHITESPACE)
49
+            {
47 50
                 continue;
48 51
             }
49 52
 
50
-            if (empty($definition)) {
53
+            if (empty($definition))
54
+            {
51 55
                 $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []];
52 56
             }
53 57
 
54
-            if ($token[ReflectionFile::TOKEN_TYPE] === '(' || $token[ReflectionFile::TOKEN_TYPE] === '[') {
58
+            if ($token[ReflectionFile::TOKEN_TYPE] === '(' || $token[ReflectionFile::TOKEN_TYPE] === '[')
59
+            {
55 60
                 ++$level;
56 61
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
57 62
                 continue;
58 63
             }
59 64
 
60
-            if ($token[ReflectionFile::TOKEN_TYPE] === ')' || $token[ReflectionFile::TOKEN_TYPE] === ']') {
65
+            if ($token[ReflectionFile::TOKEN_TYPE] === ')' || $token[ReflectionFile::TOKEN_TYPE] === ']')
66
+            {
61 67
                 --$level;
62 68
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
63 69
                 continue;
64 70
             }
65 71
 
66
-            if ($level) {
72
+            if ($level)
73
+            {
67 74
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
68 75
                 continue;
69 76
             }
70 77
 
71
-            if ($token[ReflectionFile::TOKEN_TYPE] === ',') {
78
+            if ($token[ReflectionFile::TOKEN_TYPE] === ',')
79
+            {
72 80
                 $result[] = self::createArgument($definition);
73 81
                 $definition = null;
74 82
                 continue;
@@ -79,9 +87,11 @@  discard block
 block discarded – undo
79 87
         }
80 88
 
81 89
         //Last argument
82
-        if (\is_array($definition)) {
90
+        if (\is_array($definition))
91
+        {
83 92
             $definition = self::createArgument($definition);
84
-            if (!empty($definition->getType())) {
93
+            if (!empty($definition->getType()))
94
+            {
85 95
                 $result[] = $definition;
86 96
             }
87 97
         }
@@ -106,7 +116,8 @@  discard block
 block discarded – undo
106 116
      */
107 117
     public function stringValue(): string
108 118
     {
109
-        if ($this->type !== self::STRING) {
119
+        if ($this->type !== self::STRING)
120
+        {
110 121
             throw new ReflectionException(
111 122
                 \sprintf("Unable to represent value as string, value type is '%s'", $this->type),
112 123
             );
@@ -126,7 +137,8 @@  discard block
 block discarded – undo
126 137
     {
127 138
         $result = new self(self::EXPRESSION, $definition['value']);
128 139
 
129
-        if (\count($definition['tokens']) == 1) {
140
+        if (\count($definition['tokens']) == 1)
141
+        {
130 142
             $result->type = match ($definition['tokens'][0][0]) {
131 143
                 T_VARIABLE => self::VARIABLE,
132 144
                 T_LNUMBER, T_DNUMBER => self::CONSTANT,
Please login to merge, or discard this patch.
src/Tokenizer/src/ScopedClassLocator.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 getScopedClasses(string $scope, object|string|null $target = null): array
13
+    public function getScopedClasses(string $scope, object | string | null $target = null): array
14 14
     {
15 15
         return $this->tokenizer->scopedClassLocator($scope)->getClasses($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 getScopedClasses(string $scope, object|string|null $target = null): array
14 15
     {
Please login to merge, or discard this patch.
src/Tokenizer/src/Attribute/AbstractTarget.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function __construct(
13 13
         public readonly ?string $scope = null,
14
-    ) {}
14
+    ){}
15 15
 
16 16
     /**
17 17
      * Filter given classes and return only those that should be listened.
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@
 block discarded – undo
11 11
      */
12 12
     public function __construct(
13 13
         public readonly ?string $scope = null,
14
-    ) {}
14
+    ) {
15
+}
15 16
 
16 17
     /**
17 18
      * Filter given classes and return only those that should be listened.
Please login to merge, or discard this patch.
src/Validation/tests/ValidationProviderTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 final class ValidationProviderTest extends TestCase
13 13
 {
14
-    private m\MockInterface|InvokerInterface $invoker;
14
+    private m\MockInterface | InvokerInterface $invoker;
15 15
     private ValidationProvider $provider;
16 16
 
17 17
     public function testRegisterValidator(): void
Please login to merge, or discard this patch.
src/Validation/src/Exception/ValidationException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,4 +4,4 @@
 block discarded – undo
4 4
 
5 5
 namespace Spiral\Validation\Exception;
6 6
 
7
-class ValidationException extends \RuntimeException {}
7
+class ValidationException extends \RuntimeException{}
Please login to merge, or discard this patch.