Passed
Pull Request — master (#656)
by Abdul Malik
09:21
created
src/Distribution/src/Internal/DateTimeIntervalFactory.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function create($duration): DateInterval
46 46
     {
47
-        try {
47
+        try{
48 48
             return $this->createOrFail($duration);
49
-        } catch (InvalidArgumentException $e) {
49
+        }catch (InvalidArgumentException $e){
50 50
             throw $e;
51
-        } catch (Throwable $e) {
51
+        }catch (Throwable $e){
52 52
             throw new InvalidArgumentException($e->getMessage(), (int)$e->getCode(), $e);
53 53
         }
54 54
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     private function createOrFail($duration): DateInterval
71 71
     {
72
-        switch (true) {
72
+        switch (true){
73 73
             case $duration instanceof DateInterval:
74 74
                 return $duration;
75 75
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 return new DateInterval($duration);
81 81
 
82 82
             case \is_int($duration):
83
-                return new DateInterval('PT' . $duration . 'S');
83
+                return new DateInterval('PT'.$duration.'S');
84 84
 
85 85
             case $duration === null:
86 86
                 return new DateInterval('PT0S');
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,11 +44,16 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function create($duration): DateInterval
46 46
     {
47
-        try {
47
+        try
48
+        {
48 49
             return $this->createOrFail($duration);
49
-        } catch (InvalidArgumentException $e) {
50
+        }
51
+        catch (InvalidArgumentException $e)
52
+        {
50 53
             throw $e;
51
-        } catch (Throwable $e) {
54
+        }
55
+        catch (Throwable $e)
56
+        {
52 57
             throw new InvalidArgumentException($e->getMessage(), (int)$e->getCode(), $e);
53 58
         }
54 59
     }
@@ -69,7 +74,8 @@  discard block
 block discarded – undo
69 74
      */
70 75
     private function createOrFail($duration): DateInterval
71 76
     {
72
-        switch (true) {
77
+        switch (true)
78
+        {
73 79
             case $duration instanceof DateInterval:
74 80
                 return $duration;
75 81
 
Please login to merge, or discard this patch.
src/Pagination/src/Paginator.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function getPage(): int
94 94
     {
95
-        if ($this->pageNumber < 1) {
95
+        if ($this->pageNumber < 1){
96 96
             return 1;
97 97
         }
98 98
 
99
-        if ($this->pageNumber > $this->countPages) {
99
+        if ($this->pageNumber > $this->countPages){
100 100
             return $this->countPages;
101 101
         }
102 102
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     public function paginate(PaginableInterface $target): PaginatorInterface
118 118
     {
119 119
         $paginator = clone $this;
120
-        if ($target instanceof Countable && $paginator->count === 0) {
120
+        if ($target instanceof Countable && $paginator->count === 0){
121 121
             $paginator->setCount($target->count());
122 122
         }
123 123
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function countDisplayed(): int
147 147
     {
148
-        if ($this->getPage() == $this->countPages) {
148
+        if ($this->getPage() == $this->countPages){
149 149
             return $this->count - $this->getOffset();
150 150
         }
151 151
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function nextPage()
167 167
     {
168
-        if ($this->getPage() != $this->countPages) {
168
+        if ($this->getPage() != $this->countPages){
169 169
             return $this->getPage() + 1;
170 170
         }
171 171
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function previousPage()
179 179
     {
180
-        if ($this->getPage() > 1) {
180
+        if ($this->getPage() > 1){
181 181
             return $this->getPage() - 1;
182 182
         }
183 183
 
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
     private function setCount(int $count): self
193 193
     {
194 194
         $this->count = max($count, 0);
195
-        if ($this->count > 0) {
195
+        if ($this->count > 0){
196 196
             $this->countPages = (int)ceil($this->count / $this->limit);
197
-        } else {
197
+        }else{
198 198
             $this->countPages = 1;
199 199
         }
200 200
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -92,11 +92,13 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function getPage(): int
94 94
     {
95
-        if ($this->pageNumber < 1) {
95
+        if ($this->pageNumber < 1)
96
+        {
96 97
             return 1;
97 98
         }
98 99
 
99
-        if ($this->pageNumber > $this->countPages) {
100
+        if ($this->pageNumber > $this->countPages)
101
+        {
100 102
             return $this->countPages;
101 103
         }
102 104
 
@@ -117,7 +119,8 @@  discard block
 block discarded – undo
117 119
     public function paginate(PaginableInterface $target): PaginatorInterface
118 120
     {
119 121
         $paginator = clone $this;
120
-        if ($target instanceof Countable && $paginator->count === 0) {
122
+        if ($target instanceof Countable && $paginator->count === 0)
123
+        {
121 124
             $paginator->setCount($target->count());
122 125
         }
123 126
 
@@ -145,7 +148,8 @@  discard block
 block discarded – undo
145 148
      */
146 149
     public function countDisplayed(): int
147 150
     {
148
-        if ($this->getPage() == $this->countPages) {
151
+        if ($this->getPage() == $this->countPages)
152
+        {
149 153
             return $this->count - $this->getOffset();
150 154
         }
151 155
 
@@ -165,7 +169,8 @@  discard block
 block discarded – undo
165 169
      */
166 170
     public function nextPage()
167 171
     {
168
-        if ($this->getPage() != $this->countPages) {
172
+        if ($this->getPage() != $this->countPages)
173
+        {
169 174
             return $this->getPage() + 1;
170 175
         }
171 176
 
@@ -177,7 +182,8 @@  discard block
 block discarded – undo
177 182
      */
178 183
     public function previousPage()
179 184
     {
180
-        if ($this->getPage() > 1) {
185
+        if ($this->getPage() > 1)
186
+        {
181 187
             return $this->getPage() - 1;
182 188
         }
183 189
 
@@ -192,9 +198,12 @@  discard block
 block discarded – undo
192 198
     private function setCount(int $count): self
193 199
     {
194 200
         $this->count = max($count, 0);
195
-        if ($this->count > 0) {
201
+        if ($this->count > 0)
202
+        {
196 203
             $this->countPages = (int)ceil($this->count / $this->limit);
197
-        } else {
204
+        }
205
+        else
206
+        {
198 207
             $this->countPages = 1;
199 208
         }
200 209
 
Please login to merge, or discard this patch.
src/Tokenizer/src/AbstractLocator.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function availableReflections(): Generator
50 50
     {
51
-        foreach ($this->finder->getIterator() as $file) {
51
+        foreach ($this->finder->getIterator() as $file){
52 52
             $reflection = new ReflectionFile((string)$file);
53 53
 
54
-            if ($reflection->hasIncludes()) {
54
+            if ($reflection->hasIncludes()){
55 55
                 // We are not analyzing files which has includes, it's not safe to require such reflections
56 56
                 $this->getLogger()->warning(
57 57
                     sprintf('File `%s` has includes and excluded from analysis', $file),
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
      */
78 78
     protected function classReflection(string $class): ReflectionClass
79 79
     {
80
-        $loader = static function ($class) {
81
-            if ($class === LocatorException::class) {
80
+        $loader = static function ($class){
81
+            if ($class === LocatorException::class){
82 82
                 return;
83 83
             }
84 84
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
         //To suspend class dependency exception
89 89
         spl_autoload_register($loader);
90 90
 
91
-        try {
91
+        try{
92 92
             //In some cases reflection can thrown an exception if class invalid or can not be loaded,
93 93
             //we are going to handle such exception and convert it soft exception
94 94
             return new ReflectionClass($class);
95
-        } catch (Throwable $e) {
96
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
95
+        }catch (Throwable $e){
96
+            if ($e instanceof LocatorException && $e->getPrevious() != null){
97 97
                 $e = $e->getPrevious();
98 98
             }
99 99
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             );
110 110
 
111 111
             throw new LocatorException($e->getMessage(), $e->getCode(), $e);
112
-        } finally {
112
+        }finally{
113 113
             spl_autoload_unregister($loader);
114 114
         }
115 115
     }
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
     {
126 126
         $traits = [];
127 127
 
128
-        do {
128
+        do{
129 129
             $traits = \array_merge(\class_uses($class), $traits);
130 130
             $class = \get_parent_class($class);
131
-        } while ($class !== false);
131
+        }while ($class !== false);
132 132
 
133 133
         //Traits from traits
134
-        foreach (\array_flip($traits) as $trait) {
134
+        foreach (\array_flip($traits) as $trait){
135 135
             $traits = \array_merge(\class_uses($trait), $traits);
136 136
         }
137 137
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,10 +48,12 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function availableReflections(): Generator
50 50
     {
51
-        foreach ($this->finder->getIterator() as $file) {
51
+        foreach ($this->finder->getIterator() as $file)
52
+        {
52 53
             $reflection = new ReflectionFile((string)$file);
53 54
 
54
-            if ($reflection->hasIncludes()) {
55
+            if ($reflection->hasIncludes())
56
+            {
55 57
                 // We are not analyzing files which has includes, it's not safe to require such reflections
56 58
                 $this->getLogger()->warning(
57 59
                     sprintf('File `%s` has includes and excluded from analysis', $file),
@@ -77,8 +79,10 @@  discard block
 block discarded – undo
77 79
      */
78 80
     protected function classReflection(string $class): ReflectionClass
79 81
     {
80
-        $loader = static function ($class) {
81
-            if ($class === LocatorException::class) {
82
+        $loader = static function ($class)
83
+        {
84
+            if ($class === LocatorException::class)
85
+            {
82 86
                 return;
83 87
             }
84 88
 
@@ -88,12 +92,16 @@  discard block
 block discarded – undo
88 92
         //To suspend class dependency exception
89 93
         spl_autoload_register($loader);
90 94
 
91
-        try {
95
+        try
96
+        {
92 97
             //In some cases reflection can thrown an exception if class invalid or can not be loaded,
93 98
             //we are going to handle such exception and convert it soft exception
94 99
             return new ReflectionClass($class);
95
-        } catch (Throwable $e) {
96
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
100
+        }
101
+        catch (Throwable $e)
102
+        {
103
+            if ($e instanceof LocatorException && $e->getPrevious() != null)
104
+            {
97 105
                 $e = $e->getPrevious();
98 106
             }
99 107
 
@@ -109,7 +117,9 @@  discard block
 block discarded – undo
109 117
             );
110 118
 
111 119
             throw new LocatorException($e->getMessage(), $e->getCode(), $e);
112
-        } finally {
120
+        }
121
+        finally
122
+        {
113 123
             spl_autoload_unregister($loader);
114 124
         }
115 125
     }
@@ -125,13 +135,15 @@  discard block
 block discarded – undo
125 135
     {
126 136
         $traits = [];
127 137
 
128
-        do {
138
+        do
139
+        {
129 140
             $traits = \array_merge(\class_uses($class), $traits);
130 141
             $class = \get_parent_class($class);
131 142
         } while ($class !== false);
132 143
 
133 144
         //Traits from traits
134
-        foreach (\array_flip($traits) as $trait) {
145
+        foreach (\array_flip($traits) as $trait)
146
+        {
135 147
             $traits = \array_merge(\class_uses($trait), $traits);
136 148
         }
137 149
 
Please login to merge, or discard this patch.
src/Tokenizer/src/InvocationLocator.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     public function getInvocations(ReflectionFunctionAbstract $function): array
33 33
     {
34 34
         $result = [];
35
-        foreach ($this->availableInvocations($function->getName()) as $invocation) {
36
-            if ($this->isTargeted($invocation, $function)) {
35
+        foreach ($this->availableInvocations($function->getName()) as $invocation){
36
+            if ($this->isTargeted($invocation, $function)){
37 37
                 $result[] = $invocation;
38 38
             }
39 39
         }
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
     protected function availableInvocations(string $signature = ''): Generator
51 51
     {
52 52
         $signature = strtolower(trim($signature, '\\'));
53
-        foreach ($this->availableReflections() as $reflection) {
54
-            foreach ($reflection->getInvocations() as $invocation) {
53
+        foreach ($this->availableReflections() as $reflection){
54
+            foreach ($reflection->getInvocations() as $invocation){
55 55
                 if (
56 56
                     !empty($signature)
57 57
                     && strtolower(trim($invocation->getName(), '\\')) != $signature
58
-                ) {
58
+                ){
59 59
                     continue;
60 60
                 }
61 61
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
     protected function isTargeted(ReflectionInvocation $invocation, ReflectionFunctionAbstract $function): bool
68 68
     {
69
-        if ($function instanceof ReflectionFunction) {
69
+        if ($function instanceof ReflectionFunction){
70 70
             return !$invocation->isMethod();
71 71
         }
72 72
 
73
-        try {
73
+        try{
74 74
             $reflection = $this->classReflection($invocation->getClass());
75
-        } catch (LocatorException $e) {
75
+        }catch (LocatorException $e){
76 76
             return false;
77 77
         }
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
          */
82 82
         $target = $function->getDeclaringClass();
83 83
 
84
-        if ($target->isTrait()) {
84
+        if ($target->isTrait()){
85 85
             //Let's compare traits
86 86
             return in_array($target->getName(), $this->fetchTraits($invocation->getClass()));
87 87
         }
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,8 +32,10 @@  discard block
 block discarded – undo
32 32
     public function getInvocations(ReflectionFunctionAbstract $function): array
33 33
     {
34 34
         $result = [];
35
-        foreach ($this->availableInvocations($function->getName()) as $invocation) {
36
-            if ($this->isTargeted($invocation, $function)) {
35
+        foreach ($this->availableInvocations($function->getName()) as $invocation)
36
+        {
37
+            if ($this->isTargeted($invocation, $function))
38
+            {
37 39
                 $result[] = $invocation;
38 40
             }
39 41
         }
@@ -50,8 +52,10 @@  discard block
 block discarded – undo
50 52
     protected function availableInvocations(string $signature = ''): Generator
51 53
     {
52 54
         $signature = strtolower(trim($signature, '\\'));
53
-        foreach ($this->availableReflections() as $reflection) {
54
-            foreach ($reflection->getInvocations() as $invocation) {
55
+        foreach ($this->availableReflections() as $reflection)
56
+        {
57
+            foreach ($reflection->getInvocations() as $invocation)
58
+            {
55 59
                 if (
56 60
                     !empty($signature)
57 61
                     && strtolower(trim($invocation->getName(), '\\')) != $signature
@@ -66,13 +70,17 @@  discard block
 block discarded – undo
66 70
 
67 71
     protected function isTargeted(ReflectionInvocation $invocation, ReflectionFunctionAbstract $function): bool
68 72
     {
69
-        if ($function instanceof ReflectionFunction) {
73
+        if ($function instanceof ReflectionFunction)
74
+        {
70 75
             return !$invocation->isMethod();
71 76
         }
72 77
 
73
-        try {
78
+        try
79
+        {
74 80
             $reflection = $this->classReflection($invocation->getClass());
75
-        } catch (LocatorException $e) {
81
+        }
82
+        catch (LocatorException $e)
83
+        {
76 84
             return false;
77 85
         }
78 86
 
@@ -81,7 +89,8 @@  discard block
 block discarded – undo
81 89
          */
82 90
         $target = $function->getDeclaringClass();
83 91
 
84
-        if ($target->isTrait()) {
92
+        if ($target->isTrait())
93
+        {
85 94
             //Let's compare traits
86 95
             return in_array($target->getName(), $this->fetchTraits($invocation->getClass()));
87 96
         }
Please login to merge, or discard this patch.
src/Tokenizer/src/ClassLocator.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function getClasses($target = null): array
26 26
     {
27
-        if (!empty($target) && (is_object($target) || is_string($target))) {
27
+        if (!empty($target) && (is_object($target) || is_string($target))){
28 28
             $target = new ReflectionClass($target);
29 29
         }
30 30
 
31 31
         $result = [];
32
-        foreach ($this->availableClasses() as $class) {
33
-            try {
32
+        foreach ($this->availableClasses() as $class){
33
+            try{
34 34
                 $reflection = $this->classReflection($class);
35
-            } catch (LocatorException $e) {
35
+            }catch (LocatorException $e){
36 36
                 //Ignoring
37 37
                 continue;
38 38
             }
39 39
 
40
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
40
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){
41 41
                 continue;
42 42
             }
43 43
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $classes = [];
56 56
 
57
-        foreach ($this->availableReflections() as $reflection) {
57
+        foreach ($this->availableReflections() as $reflection){
58 58
             $classes = array_merge($classes, $reflection->getClasses());
59 59
         }
60 60
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
      */
69 69
     protected function isTargeted(ReflectionClass $class, ReflectionClass $target = null): bool
70 70
     {
71
-        if (empty($target)) {
71
+        if (empty($target)){
72 72
             return true;
73 73
         }
74 74
 
75
-        if (!$target->isTrait()) {
75
+        if (!$target->isTrait()){
76 76
             //Target is interface or class
77 77
             return $class->isSubclassOf($target) || $class->getName() == $target->getName();
78 78
         }
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,20 +24,26 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function getClasses($target = null): array
26 26
     {
27
-        if (!empty($target) && (is_object($target) || is_string($target))) {
27
+        if (!empty($target) && (is_object($target) || is_string($target)))
28
+        {
28 29
             $target = new ReflectionClass($target);
29 30
         }
30 31
 
31 32
         $result = [];
32
-        foreach ($this->availableClasses() as $class) {
33
-            try {
33
+        foreach ($this->availableClasses() as $class)
34
+        {
35
+            try
36
+            {
34 37
                 $reflection = $this->classReflection($class);
35
-            } catch (LocatorException $e) {
38
+            }
39
+            catch (LocatorException $e)
40
+            {
36 41
                 //Ignoring
37 42
                 continue;
38 43
             }
39 44
 
40
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
45
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface())
46
+            {
41 47
                 continue;
42 48
             }
43 49
 
@@ -54,7 +60,8 @@  discard block
 block discarded – undo
54 60
     {
55 61
         $classes = [];
56 62
 
57
-        foreach ($this->availableReflections() as $reflection) {
63
+        foreach ($this->availableReflections() as $reflection)
64
+        {
58 65
             $classes = array_merge($classes, $reflection->getClasses());
59 66
         }
60 67
 
@@ -68,11 +75,13 @@  discard block
 block discarded – undo
68 75
      */
69 76
     protected function isTargeted(ReflectionClass $class, ReflectionClass $target = null): bool
70 77
     {
71
-        if (empty($target)) {
78
+        if (empty($target))
79
+        {
72 80
             return true;
73 81
         }
74 82
 
75
-        if (!$target->isTrait()) {
83
+        if (!$target->isTrait())
84
+        {
76 85
             //Target is interface or class
77 86
             return $class->isSubclassOf($target) || $class->getName() == $target->getName();
78 87
         }
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionArgument.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * Argument types.
23 23
      */
24
-    public const CONSTANT   = 'constant';   //Scalar constant and not variable.
25
-    public const VARIABLE   = 'variable';   //PHP variable
24
+    public const CONSTANT   = 'constant'; //Scalar constant and not variable.
25
+    public const VARIABLE   = 'variable'; //PHP variable
26 26
     public const EXPRESSION = 'expression'; //PHP code (expression).
27 27
     public const STRING     = 'string';
28 28
     private string $type;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function stringValue(): string
61 61
     {
62
-        if ($this->type != self::STRING) {
62
+        if ($this->type != self::STRING){
63 63
             throw new ReflectionException(
64 64
                 "Unable to represent value as string, value type is '{$this->type}'"
65 65
             );
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
         $level = 0;
81 81
 
82 82
         $result = [];
83
-        foreach ($tokens as $token) {
84
-            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) {
83
+        foreach ($tokens as $token){
84
+            if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){
85 85
                 continue;
86 86
             }
87 87
 
88
-            if (empty($definition)) {
88
+            if (empty($definition)){
89 89
                 $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []];
90 90
             }
91 91
 
92 92
             if (
93 93
                 $token[ReflectionFile::TOKEN_TYPE] == '('
94 94
                 || $token[ReflectionFile::TOKEN_TYPE] == '['
95
-            ) {
95
+            ){
96 96
                 ++$level;
97 97
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
98 98
                 continue;
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
             if (
102 102
                 $token[ReflectionFile::TOKEN_TYPE] == ')'
103 103
                 || $token[ReflectionFile::TOKEN_TYPE] == ']'
104
-            ) {
104
+            ){
105 105
                 --$level;
106 106
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
107 107
                 continue;
108 108
             }
109 109
 
110
-            if ($level) {
110
+            if ($level){
111 111
                 $definition['value'] .= $token[ReflectionFile::TOKEN_CODE];
112 112
                 continue;
113 113
             }
114 114
 
115
-            if ($token[ReflectionFile::TOKEN_TYPE] == ',') {
115
+            if ($token[ReflectionFile::TOKEN_TYPE] == ','){
116 116
                 $result[] = self::createArgument($definition);
117 117
                 $definition = null;
118 118
                 continue;
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         //Last argument
126
-        if (is_array($definition)) {
126
+        if (is_array($definition)){
127 127
             $definition = self::createArgument($definition);
128
-            if (!empty($definition->getType())) {
128
+            if (!empty($definition->getType())){
129 129
                 $result[] = $definition;
130 130
             }
131 131
         }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
     {
143 143
         $result = new static(self::EXPRESSION, $definition['value']);
144 144
 
145
-        if (count($definition['tokens']) == 1) {
145
+        if (count($definition['tokens']) == 1){
146 146
             //If argument represent by one token we can try to resolve it's type more precisely
147
-            switch ($definition['tokens'][0][0]) {
147
+            switch ($definition['tokens'][0][0]){
148 148
                 case T_VARIABLE:
149 149
                     $result->type = self::VARIABLE;
150 150
                     break;
Please login to merge, or discard this patch.
src/Tokenizer/src/Tokenizer.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function createInjection(ReflectionClass $class, string $context = null)
79 79
     {
80
-        if ($class->isSubclassOf(ClassesInterface::class)) {
80
+        if ($class->isSubclassOf(ClassesInterface::class)){
81 81
             return $this->classLocator();
82
-        } elseif ($class->isSubclassOf(InvocationsInterface::class)) {
82
+        } elseif ($class->isSubclassOf(InvocationsInterface::class)){
83 83
             return $this->invocationLocator();
84 84
         }
85 85
 
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
         $tokens = token_get_all(file_get_contents($filename));
95 95
 
96 96
         $line = 0;
97
-        foreach ($tokens as &$token) {
98
-            if (isset($token[self::LINE])) {
97
+        foreach ($tokens as &$token){
98
+            if (isset($token[self::LINE])){
99 99
                 $line = $token[self::LINE];
100 100
             }
101 101
 
102
-            if (!is_array($token)) {
102
+            if (!is_array($token)){
103 103
                 $token = [$token, $token, $line];
104 104
             }
105 105
 
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $finder = new Finder();
119 119
 
120
-        if (empty($directories)) {
120
+        if (empty($directories)){
121 121
             $directories = $this->config->getDirectories();
122 122
         }
123 123
 
124
-        if (empty($exclude)) {
124
+        if (empty($exclude)){
125 125
             $exclude = $this->config->getExcludes();
126 126
         }
127 127
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,9 +77,12 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function createInjection(ReflectionClass $class, string $context = null)
79 79
     {
80
-        if ($class->isSubclassOf(ClassesInterface::class)) {
80
+        if ($class->isSubclassOf(ClassesInterface::class))
81
+        {
81 82
             return $this->classLocator();
82
-        } elseif ($class->isSubclassOf(InvocationsInterface::class)) {
83
+        }
84
+        elseif ($class->isSubclassOf(InvocationsInterface::class))
85
+        {
83 86
             return $this->invocationLocator();
84 87
         }
85 88
 
@@ -94,12 +97,15 @@  discard block
 block discarded – undo
94 97
         $tokens = token_get_all(file_get_contents($filename));
95 98
 
96 99
         $line = 0;
97
-        foreach ($tokens as &$token) {
98
-            if (isset($token[self::LINE])) {
100
+        foreach ($tokens as &$token)
101
+        {
102
+            if (isset($token[self::LINE]))
103
+            {
99 104
                 $line = $token[self::LINE];
100 105
             }
101 106
 
102
-            if (!is_array($token)) {
107
+            if (!is_array($token))
108
+            {
103 109
                 $token = [$token, $token, $line];
104 110
             }
105 111
 
@@ -117,11 +123,13 @@  discard block
 block discarded – undo
117 123
     {
118 124
         $finder = new Finder();
119 125
 
120
-        if (empty($directories)) {
126
+        if (empty($directories))
127
+        {
121 128
             $directories = $this->config->getDirectories();
122 129
         }
123 130
 
124
-        if (empty($exclude)) {
131
+        if (empty($exclude))
132
+        {
125 133
             $exclude = $this->config->getExcludes();
126 134
         }
127 135
 
Please login to merge, or discard this patch.
src/Router/src/CoreHandler.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         CoreInterface $core,
53 53
         ScopeInterface $scope,
54 54
         ResponseFactoryInterface $responseFactory
55
-    ) {
55
+    ){
56 56
         $this->core = $core;
57 57
         $this->scope = $scope;
58 58
         $this->responseFactory = $responseFactory;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function handle(Request $request): Response
92 92
     {
93
-        if ($this->controller === null) {
93
+        if ($this->controller === null){
94 94
             throw new HandlerException('Controller and action pair is not set');
95 95
         }
96 96
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $output = $result = null;
101 101
 
102 102
         $response = $this->responseFactory->createResponse(200);
103
-        try {
103
+        try{
104 104
             // run the core withing PSR-7 Request/Response scope
105 105
             $result = $this->scope->runScope(
106 106
                 [
@@ -113,29 +113,29 @@  discard block
 block discarded – undo
113 113
                     $this->parameters
114 114
                 )
115 115
             );
116
-        } catch (ControllerException $e) {
116
+        }catch (ControllerException $e){
117 117
             ob_get_clean();
118 118
             throw $this->mapException($e);
119
-        } catch (Throwable $e) {
119
+        }catch (Throwable $e){
120 120
             ob_get_clean();
121 121
             throw $e;
122
-        } finally {
123
-            while (ob_get_level() > $outputLevel + 1) {
124
-                $output = ob_get_clean() . $output;
122
+        }finally{
123
+            while (ob_get_level() > $outputLevel + 1){
124
+                $output = ob_get_clean().$output;
125 125
             }
126 126
         }
127 127
 
128 128
         return $this->wrapResponse(
129 129
             $response,
130 130
             $result,
131
-            ob_get_clean() . $output
131
+            ob_get_clean().$output
132 132
         );
133 133
     }
134 134
 
135 135
     private function getAction(Request $request): string
136 136
     {
137
-        if ($this->verbActions) {
138
-            return strtolower($request->getMethod()) . ucfirst($this->action);
137
+        if ($this->verbActions){
138
+            return strtolower($request->getMethod()).ucfirst($this->action);
139 139
         }
140 140
 
141 141
         return $this->action;
@@ -150,21 +150,21 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function wrapResponse(Response $response, $result = null, string $output = ''): Response
152 152
     {
153
-        if ($result instanceof Response) {
154
-            if ($output !== '' && $result->getBody()->isWritable()) {
153
+        if ($result instanceof Response){
154
+            if ($output !== '' && $result->getBody()->isWritable()){
155 155
                 $result->getBody()->write($output);
156 156
             }
157 157
 
158 158
             return $result;
159 159
         }
160 160
 
161
-        if ($result instanceof Generator) {
161
+        if ($result instanceof Generator){
162 162
             return $response->withBody(new GeneratorStream($result));
163 163
         }
164 164
 
165
-        if (\is_array($result) || $result instanceof JsonSerializable) {
165
+        if (\is_array($result) || $result instanceof JsonSerializable){
166 166
             $response = $this->writeJson($response, $result);
167
-        } else {
167
+        }else{
168 168
             $response->getBody()->write((string)$result);
169 169
         }
170 170
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function mapException(ControllerException $exception): ClientException
181 181
     {
182
-        switch ($exception->getCode()) {
182
+        switch ($exception->getCode()){
183 183
             case ControllerException::BAD_ACTION:
184 184
             case ControllerException::NOT_FOUND:
185 185
                 return new NotFoundException($exception->getMessage());
Please login to merge, or discard this patch.
Braces   +30 added lines, -13 removed lines patch added patch discarded remove patch
@@ -90,7 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function handle(Request $request): Response
92 92
     {
93
-        if ($this->controller === null) {
93
+        if ($this->controller === null)
94
+        {
94 95
             throw new HandlerException('Controller and action pair is not set');
95 96
         }
96 97
 
@@ -100,7 +101,8 @@  discard block
 block discarded – undo
100 101
         $output = $result = null;
101 102
 
102 103
         $response = $this->responseFactory->createResponse(200);
103
-        try {
104
+        try
105
+        {
104 106
             // run the core withing PSR-7 Request/Response scope
105 107
             $result = $this->scope->runScope(
106 108
                 [
@@ -113,14 +115,21 @@  discard block
 block discarded – undo
113 115
                     $this->parameters
114 116
                 )
115 117
             );
116
-        } catch (ControllerException $e) {
118
+        }
119
+        catch (ControllerException $e)
120
+        {
117 121
             ob_get_clean();
118 122
             throw $this->mapException($e);
119
-        } catch (Throwable $e) {
123
+        }
124
+        catch (Throwable $e)
125
+        {
120 126
             ob_get_clean();
121 127
             throw $e;
122
-        } finally {
123
-            while (ob_get_level() > $outputLevel + 1) {
128
+        }
129
+        finally
130
+        {
131
+            while (ob_get_level() > $outputLevel + 1)
132
+            {
124 133
                 $output = ob_get_clean() . $output;
125 134
             }
126 135
         }
@@ -134,7 +143,8 @@  discard block
 block discarded – undo
134 143
 
135 144
     private function getAction(Request $request): string
136 145
     {
137
-        if ($this->verbActions) {
146
+        if ($this->verbActions)
147
+        {
138 148
             return strtolower($request->getMethod()) . ucfirst($this->action);
139 149
         }
140 150
 
@@ -150,21 +160,27 @@  discard block
 block discarded – undo
150 160
      */
151 161
     private function wrapResponse(Response $response, $result = null, string $output = ''): Response
152 162
     {
153
-        if ($result instanceof Response) {
154
-            if ($output !== '' && $result->getBody()->isWritable()) {
163
+        if ($result instanceof Response)
164
+        {
165
+            if ($output !== '' && $result->getBody()->isWritable())
166
+            {
155 167
                 $result->getBody()->write($output);
156 168
             }
157 169
 
158 170
             return $result;
159 171
         }
160 172
 
161
-        if ($result instanceof Generator) {
173
+        if ($result instanceof Generator)
174
+        {
162 175
             return $response->withBody(new GeneratorStream($result));
163 176
         }
164 177
 
165
-        if (\is_array($result) || $result instanceof JsonSerializable) {
178
+        if (\is_array($result) || $result instanceof JsonSerializable)
179
+        {
166 180
             $response = $this->writeJson($response, $result);
167
-        } else {
181
+        }
182
+        else
183
+        {
168 184
             $response->getBody()->write((string)$result);
169 185
         }
170 186
 
@@ -179,7 +195,8 @@  discard block
 block discarded – undo
179 195
      */
180 196
     private function mapException(ControllerException $exception): ClientException
181 197
     {
182
-        switch ($exception->getCode()) {
198
+        switch ($exception->getCode())
199
+        {
183 200
             case ControllerException::BAD_ACTION:
184 201
             case ControllerException::NOT_FOUND:
185 202
                 return new NotFoundException($exception->getMessage());
Please login to merge, or discard this patch.
src/Router/src/UriHandler.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         'integer' => '\d+',
35 35
         'uuid'    => '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}',
36 36
     ];
37
-    private const URI_FIXERS       = [
37
+    private const URI_FIXERS = [
38 38
         '[]'  => '',
39 39
         '[/]' => '',
40 40
         '['   => '',
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     public function __construct(
71 71
         UriFactoryInterface $uriFactory,
72 72
         SlugifyInterface $slugify = null
73
-    ) {
73
+    ){
74 74
         $this->uriFactory = $uriFactory;
75 75
         $this->slugify = $slugify ?? new Slugify();
76 76
     }
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function match(UriInterface $uri, array $defaults): ?array
135 135
     {
136
-        if (!$this->isCompiled()) {
136
+        if (!$this->isCompiled()){
137 137
             $this->compile();
138 138
         }
139 139
 
140 140
         $matches = [];
141
-        if (!preg_match($this->compiled, $this->fetchTarget($uri), $matches)) {
141
+        if (!preg_match($this->compiled, $this->fetchTarget($uri), $matches)){
142 142
             return null;
143 143
         }
144 144
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function uri($parameters = [], array $defaults = []): UriInterface
156 156
     {
157
-        if (!$this->isCompiled()) {
157
+        if (!$this->isCompiled()){
158 158
             $this->compile();
159 159
         }
160 160
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
             $this->fetchOptions($parameters, $query)
165 165
         );
166 166
 
167
-        foreach ($this->constrains as $key => $_) {
168
-            if (empty($parameters[$key])) {
167
+        foreach ($this->constrains as $key => $_){
168
+            if (empty($parameters[$key])){
169 169
                 throw new UriHandlerException("Unable to generate Uri, parameter `{$key}` is missing");
170 170
             }
171 171
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         $path = $this->interpolate($this->template, $parameters);
175 175
 
176 176
         //Uri with added prefix
177
-        $uri = $this->uriFactory->createUri(($this->matchHost ? '' : $this->prefix) . trim($path, '/'));
177
+        $uri = $this->uriFactory->createUri(($this->matchHost ? '' : $this->prefix).trim($path, '/'));
178 178
 
179 179
         return empty($query) ? $uri : $uri->withQuery(http_build_query($query));
180 180
     }
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
         $allowed = array_keys($this->options);
191 191
 
192 192
         $result = [];
193
-        foreach ($parameters as $key => $parameter) {
194
-            if (is_numeric($key) && isset($allowed[$key])) {
193
+        foreach ($parameters as $key => $parameter){
194
+            if (is_numeric($key) && isset($allowed[$key])){
195 195
                 // this segment fetched keys from given parameters either by name or by position
196 196
                 $key = $allowed[$key];
197
-            } elseif (!array_key_exists($key, $this->options) && is_array($parameters)) {
197
+            } elseif (!array_key_exists($key, $this->options) && is_array($parameters)){
198 198
                 // all additional parameters given in array form can be glued to query string
199 199
                 $query[$key] = $parameter;
200 200
                 continue;
201 201
             }
202 202
 
203 203
             //String must be normalized here
204
-            if (is_string($parameter) && !preg_match('/^[a-z\-_0-9]+$/i', $parameter)) {
204
+            if (is_string($parameter) && !preg_match('/^[a-z\-_0-9]+$/i', $parameter)){
205 205
                 $result[$key] = $this->slugify->slugify($parameter);
206 206
                 continue;
207 207
             }
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
     {
220 220
         $path = $uri->getPath();
221 221
 
222
-        if (empty($path) || $path[0] !== '/') {
223
-            $path = '/' . $path;
222
+        if (empty($path) || $path[0] !== '/'){
223
+            $path = '/'.$path;
224 224
         }
225 225
 
226
-        if ($this->matchHost) {
227
-            $uriString = $uri->getHost() . $path;
228
-        } else {
226
+        if ($this->matchHost){
227
+            $uriString = $uri->getHost().$path;
228
+        }else{
229 229
             $uriString = substr($path, strlen($this->prefix));
230
-            if ($uriString === false) {
230
+            if ($uriString === false){
231 231
                 $uriString = '';
232 232
             }
233 233
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     private function compile(): void
242 242
     {
243
-        if ($this->pattern === null) {
243
+        if ($this->pattern === null){
244 244
             throw new UriHandlerException('Unable to compile UriHandler, pattern is not set');
245 245
         }
246 246
 
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
         $pattern = rtrim(ltrim($this->pattern, ':/'), '/');
249 249
 
250 250
         // correct [/ first occurrence]
251
-        if (strpos($pattern, '[/') === 0) {
252
-            $pattern = '[' . substr($pattern, 2);
251
+        if (strpos($pattern, '[/') === 0){
252
+            $pattern = '['.substr($pattern, 2);
253 253
         }
254 254
 
255
-        if (preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)) {
255
+        if (preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)){
256 256
             $variables = array_combine($matches[1], $matches[2]);
257 257
 
258
-            foreach ($variables as $key => $segment) {
258
+            foreach ($variables as $key => $segment){
259 259
                 $segment = $this->prepareSegment($key, $segment);
260 260
                 $replaces["<$key>"] = "(?P<$key>$segment)";
261 261
                 $options[] = $key;
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
         $template = preg_replace('/<(\w+):?.*?>/', '<\1>', $pattern);
266 266
         $options = array_fill_keys($options, null);
267 267
 
268
-        foreach ($this->constrains as $key => $value) {
269
-            if ($value instanceof Autofill) {
268
+        foreach ($this->constrains as $key => $value){
269
+            if ($value instanceof Autofill){
270 270
                 // only forces value replacement, not required to be presented as parameter
271 271
                 continue;
272 272
             }
273 273
 
274
-            if (!array_key_exists($key, $options) && !isset($this->defaults[$key])) {
274
+            if (!array_key_exists($key, $options) && !isset($this->defaults[$key])){
275 275
                 throw new ConstrainException(
276 276
                     sprintf(
277 277
                         'Route `%s` does not define routing parameter `<%s>`.',
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             }
283 283
         }
284 284
 
285
-        $this->compiled = '/^' . strtr($template, $replaces + self::PATTERN_REPLACES) . '$/iu';
285
+        $this->compiled = '/^'.strtr($template, $replaces + self::PATTERN_REPLACES).'$/iu';
286 286
         $this->template = stripslashes(str_replace('?', '', $template));
287 287
         $this->options = $options;
288 288
     }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     private function interpolate(string $string, array $values): string
294 294
     {
295 295
         $replaces = [];
296
-        foreach ($values as $key => $value) {
296
+        foreach ($values as $key => $value){
297 297
             $value = (is_array($value) || $value instanceof Closure) ? '' : $value;
298 298
             $replaces["<{$key}>"] = is_object($value) ? (string)$value : $value;
299 299
         }
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
      */
307 307
     private function prepareSegment(string $name, string $segment): string
308 308
     {
309
-        if ($segment !== '') {
309
+        if ($segment !== ''){
310 310
             return self::SEGMENT_TYPES[$segment] ?? $segment;
311 311
         }
312 312
 
313
-        if (!isset($this->constrains[$name])) {
313
+        if (!isset($this->constrains[$name])){
314 314
             return self::DEFAULT_SEGMENT;
315 315
         }
316 316
 
317
-        if (is_array($this->constrains[$name])) {
317
+        if (is_array($this->constrains[$name])){
318 318
             $values = array_map([$this, 'filterSegment'], $this->constrains[$name]);
319 319
 
320 320
             return implode('|', $values);
Please login to merge, or discard this patch.
Braces   +50 added lines, -24 removed lines patch added patch discarded remove patch
@@ -133,12 +133,14 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function match(UriInterface $uri, array $defaults): ?array
135 135
     {
136
-        if (!$this->isCompiled()) {
136
+        if (!$this->isCompiled())
137
+        {
137 138
             $this->compile();
138 139
         }
139 140
 
140 141
         $matches = [];
141
-        if (!preg_match($this->compiled, $this->fetchTarget($uri), $matches)) {
142
+        if (!preg_match($this->compiled, $this->fetchTarget($uri), $matches))
143
+        {
142 144
             return null;
143 145
         }
144 146
 
@@ -154,7 +156,8 @@  discard block
 block discarded – undo
154 156
      */
155 157
     public function uri($parameters = [], array $defaults = []): UriInterface
156 158
     {
157
-        if (!$this->isCompiled()) {
159
+        if (!$this->isCompiled())
160
+        {
158 161
             $this->compile();
159 162
         }
160 163
 
@@ -164,8 +167,10 @@  discard block
 block discarded – undo
164 167
             $this->fetchOptions($parameters, $query)
165 168
         );
166 169
 
167
-        foreach ($this->constrains as $key => $_) {
168
-            if (empty($parameters[$key])) {
170
+        foreach ($this->constrains as $key => $_)
171
+        {
172
+            if (empty($parameters[$key]))
173
+            {
169 174
                 throw new UriHandlerException("Unable to generate Uri, parameter `{$key}` is missing");
170 175
             }
171 176
         }
@@ -190,18 +195,23 @@  discard block
 block discarded – undo
190 195
         $allowed = array_keys($this->options);
191 196
 
192 197
         $result = [];
193
-        foreach ($parameters as $key => $parameter) {
194
-            if (is_numeric($key) && isset($allowed[$key])) {
198
+        foreach ($parameters as $key => $parameter)
199
+        {
200
+            if (is_numeric($key) && isset($allowed[$key]))
201
+            {
195 202
                 // this segment fetched keys from given parameters either by name or by position
196 203
                 $key = $allowed[$key];
197
-            } elseif (!array_key_exists($key, $this->options) && is_array($parameters)) {
204
+            }
205
+            elseif (!array_key_exists($key, $this->options) && is_array($parameters))
206
+            {
198 207
                 // all additional parameters given in array form can be glued to query string
199 208
                 $query[$key] = $parameter;
200 209
                 continue;
201 210
             }
202 211
 
203 212
             //String must be normalized here
204
-            if (is_string($parameter) && !preg_match('/^[a-z\-_0-9]+$/i', $parameter)) {
213
+            if (is_string($parameter) && !preg_match('/^[a-z\-_0-9]+$/i', $parameter))
214
+            {
205 215
                 $result[$key] = $this->slugify->slugify($parameter);
206 216
                 continue;
207 217
             }
@@ -219,15 +229,20 @@  discard block
 block discarded – undo
219 229
     {
220 230
         $path = $uri->getPath();
221 231
 
222
-        if (empty($path) || $path[0] !== '/') {
232
+        if (empty($path) || $path[0] !== '/')
233
+        {
223 234
             $path = '/' . $path;
224 235
         }
225 236
 
226
-        if ($this->matchHost) {
237
+        if ($this->matchHost)
238
+        {
227 239
             $uriString = $uri->getHost() . $path;
228
-        } else {
240
+        }
241
+        else
242
+        {
229 243
             $uriString = substr($path, strlen($this->prefix));
230
-            if ($uriString === false) {
244
+            if ($uriString === false)
245
+            {
231 246
                 $uriString = '';
232 247
             }
233 248
         }
@@ -240,7 +255,8 @@  discard block
 block discarded – undo
240 255
      */
241 256
     private function compile(): void
242 257
     {
243
-        if ($this->pattern === null) {
258
+        if ($this->pattern === null)
259
+        {
244 260
             throw new UriHandlerException('Unable to compile UriHandler, pattern is not set');
245 261
         }
246 262
 
@@ -248,14 +264,17 @@  discard block
 block discarded – undo
248 264
         $pattern = rtrim(ltrim($this->pattern, ':/'), '/');
249 265
 
250 266
         // correct [/ first occurrence]
251
-        if (strpos($pattern, '[/') === 0) {
267
+        if (strpos($pattern, '[/') === 0)
268
+        {
252 269
             $pattern = '[' . substr($pattern, 2);
253 270
         }
254 271
 
255
-        if (preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)) {
272
+        if (preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches))
273
+        {
256 274
             $variables = array_combine($matches[1], $matches[2]);
257 275
 
258
-            foreach ($variables as $key => $segment) {
276
+            foreach ($variables as $key => $segment)
277
+            {
259 278
                 $segment = $this->prepareSegment($key, $segment);
260 279
                 $replaces["<$key>"] = "(?P<$key>$segment)";
261 280
                 $options[] = $key;
@@ -265,13 +284,16 @@  discard block
 block discarded – undo
265 284
         $template = preg_replace('/<(\w+):?.*?>/', '<\1>', $pattern);
266 285
         $options = array_fill_keys($options, null);
267 286
 
268
-        foreach ($this->constrains as $key => $value) {
269
-            if ($value instanceof Autofill) {
287
+        foreach ($this->constrains as $key => $value)
288
+        {
289
+            if ($value instanceof Autofill)
290
+            {
270 291
                 // only forces value replacement, not required to be presented as parameter
271 292
                 continue;
272 293
             }
273 294
 
274
-            if (!array_key_exists($key, $options) && !isset($this->defaults[$key])) {
295
+            if (!array_key_exists($key, $options) && !isset($this->defaults[$key]))
296
+            {
275 297
                 throw new ConstrainException(
276 298
                     sprintf(
277 299
                         'Route `%s` does not define routing parameter `<%s>`.',
@@ -293,7 +315,8 @@  discard block
 block discarded – undo
293 315
     private function interpolate(string $string, array $values): string
294 316
     {
295 317
         $replaces = [];
296
-        foreach ($values as $key => $value) {
318
+        foreach ($values as $key => $value)
319
+        {
297 320
             $value = (is_array($value) || $value instanceof Closure) ? '' : $value;
298 321
             $replaces["<{$key}>"] = is_object($value) ? (string)$value : $value;
299 322
         }
@@ -306,15 +329,18 @@  discard block
 block discarded – undo
306 329
      */
307 330
     private function prepareSegment(string $name, string $segment): string
308 331
     {
309
-        if ($segment !== '') {
332
+        if ($segment !== '')
333
+        {
310 334
             return self::SEGMENT_TYPES[$segment] ?? $segment;
311 335
         }
312 336
 
313
-        if (!isset($this->constrains[$name])) {
337
+        if (!isset($this->constrains[$name]))
338
+        {
314 339
             return self::DEFAULT_SEGMENT;
315 340
         }
316 341
 
317
-        if (is_array($this->constrains[$name])) {
342
+        if (is_array($this->constrains[$name]))
343
+        {
318 344
             $values = array_map([$this, 'filterSegment'], $this->constrains[$name]);
319 345
 
320 346
             return implode('|', $values);
Please login to merge, or discard this patch.