Completed
Push — master ( 454e04...38876e )
by Marco
21s queued 11s
created
src/SourceLocator/Type/AutoloadSourceLocator.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -60,6 +60,8 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * Note: the constructor has been made a 0-argument constructor because `\stream_wrapper_register`
62 62
      *       is a piece of trash, and doesn't accept instances, just class names.
63
+     * @param AstLocator $astLocator
64
+     * @param Parser $phpParser
63 65
      */
64 66
     public function __construct(?AstLocator $astLocator = null, ?Parser $phpParser = null)
65 67
     {
@@ -113,6 +115,7 @@  discard block
 block discarded – undo
113 115
      * Attempts to locate the specified identifier.
114 116
      *
115 117
      * @throws ReflectionException
118
+     * @return string
116 119
      */
117 120
     private function attemptAutoloadForIdentifier(Identifier $identifier) : ?string
118 121
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $potentiallyLocatedFile = $this->attemptAutoloadForIdentifier($identifier);
101 101
 
102
-        if (! ($potentiallyLocatedFile && file_exists($potentiallyLocatedFile))) {
102
+        if (!($potentiallyLocatedFile && file_exists($potentiallyLocatedFile))) {
103 103
             return null;
104 104
         }
105 105
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) {
152 152
             $filename = (new ReflectionClass($className))->getFileName();
153 153
 
154
-            if (! is_string($filename)) {
154
+            if (!is_string($filename)) {
155 155
                 return null;
156 156
             }
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         self::$autoloadLocatedFile = null;
162 162
         self::$currentAstLocator   = $this->astLocator; // passing the locator on to the implicitly instantiated `self`
163
-        $previousErrorHandler      = set_error_handler(static function () : void {
163
+        $previousErrorHandler      = set_error_handler(static function() : void {
164 164
         });
165 165
         stream_wrapper_unregister('file');
166 166
         stream_wrapper_register('file', self::class);
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
      */
182 182
     private function locateFunctionByName(string $functionName) : ?string
183 183
     {
184
-        if (! function_exists($functionName)) {
184
+        if (!function_exists($functionName)) {
185 185
             return null;
186 186
         }
187 187
 
188 188
         $reflection         = new ReflectionFunction($functionName);
189 189
         $reflectionFileName = $reflection->getFileName();
190 190
 
191
-        if (! is_string($reflectionFileName)) {
191
+        if (!is_string($reflectionFileName)) {
192 192
             return null;
193 193
         }
194 194
 
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
      */
203 203
     private function locateConstantByName(string $constantName) : ?string
204 204
     {
205
-        if (! defined($constantName)) {
205
+        if (!defined($constantName)) {
206 206
             return null;
207 207
         }
208 208
 
209
-        if (! array_key_exists($constantName, get_defined_constants(true)['user'])) {
209
+        if (!array_key_exists($constantName, get_defined_constants(true)['user'])) {
210 210
             return null;
211 211
         }
212 212
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         stream_wrapper_restore('file');
272 272
 
273 273
         if ($flags & STREAM_URL_STAT_QUIET) {
274
-            set_error_handler(static function () {
274
+            set_error_handler(static function() {
275 275
                 // Use native error handler
276 276
                 return false;
277 277
             });
Please login to merge, or discard this patch.
src/SourceLocator/Type/PhpInternalSourceLocator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     private function getClassSource(Identifier $identifier) : ?InternalLocatedSource
43 43
     {
44
-        if (! $identifier->isClass()) {
44
+        if (!$identifier->isClass()) {
45 45
             return null;
46 46
         }
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     private function getFunctionSource(Identifier $identifier) : ?InternalLocatedSource
52 52
     {
53
-        if (! $identifier->isFunction()) {
53
+        if (!$identifier->isFunction()) {
54 54
             return null;
55 55
         }
56 56
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     private function getConstantSource(Identifier $identifier) : ?InternalLocatedSource
61 61
     {
62
-        if (! $identifier->isConstant()) {
62
+        if (!$identifier->isConstant()) {
63 63
             return null;
64 64
         }
65 65
 
Please login to merge, or discard this patch.
src/SourceLocator/Ast/FindReflectionsInTree.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                     for ($i = 0; $i < count($node->consts); $i++) {
106 106
                         $reflection = $this->astConversionStrategy->__invoke($this->reflector, $node, $this->locatedSource, $this->currentNamespace, $i);
107 107
 
108
-                        if (! $this->identifierType->isMatchingReflector($reflection)) {
108
+                        if (!$this->identifierType->isMatchingReflector($reflection)) {
109 109
                             continue;
110 110
                         }
111 111
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
                     return null;
129 129
                 }
130 130
 
131
-                if (! ($node instanceof Node\Stmt\Function_)) {
131
+                if (!($node instanceof Node\Stmt\Function_)) {
132 132
                     return null;
133 133
                 }
134 134
 
135 135
                 $reflection = $this->astConversionStrategy->__invoke($this->reflector, $node, $this->locatedSource, $this->currentNamespace);
136 136
 
137
-                if (! $this->identifierType->isMatchingReflector($reflection)) {
137
+                if (!$this->identifierType->isMatchingReflector($reflection)) {
138 138
                     return null;
139 139
                 }
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
              */
147 147
             public function leaveNode(Node $node)
148 148
             {
149
-                if (! ($node instanceof Namespace_)) {
149
+                if (!($node instanceof Namespace_)) {
150 150
                     return null;
151 151
                 }
152 152
 
Please login to merge, or discard this patch.
src/Reflection/ReflectionConstant.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function getName() : string
130 130
     {
131
-        if (! $this->inNamespace()) {
131
+        if (!$this->inNamespace()) {
132 132
             return $this->getShortName();
133 133
         }
134 134
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function getNamespaceName() : string
153 153
     {
154
-        if (! $this->inNamespace()) {
154
+        if (!$this->inNamespace()) {
155 155
             return '';
156 156
         }
157 157
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function isUserDefined() : bool
189 189
     {
190
-        return ! $this->isInternal();
190
+        return !$this->isInternal();
191 191
     }
192 192
 
193 193
     /**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             : $this->node->consts[$this->positionInNode]->value;
208 208
 
209 209
         /** @psalm-suppress UndefinedPropertyFetch */
210
-        $this->value          = (new CompileNodeToValue())->__invoke(
210
+        $this->value = (new CompileNodeToValue())->__invoke(
211 211
             $valueNode,
212 212
             new CompilerContext($this->reflector, null)
213 213
         );
Please login to merge, or discard this patch.
src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 {
33 33
     private const BUILDER_OPTIONS    = ['shortArraySyntax' => true];
34 34
     private const SEARCH_DIRECTORIES = [
35
-        __DIR__ . '/../../../../../jetbrains/phpstorm-stubs',
36
-        __DIR__ . '/../../../vendor/jetbrains/phpstorm-stubs',
35
+        __DIR__.'/../../../../../jetbrains/phpstorm-stubs',
36
+        __DIR__.'/../../../vendor/jetbrains/phpstorm-stubs',
37 37
     ];
38 38
 
39 39
     /** @var Parser */
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function generateClassStub(string $className) : ?StubData
79 79
     {
80
-        if (! array_key_exists($className, PhpStormStubsMap::CLASSES)) {
80
+        if (!array_key_exists($className, PhpStormStubsMap::CLASSES)) {
81 81
             return null;
82 82
         }
83 83
 
84 84
         $filePath = PhpStormStubsMap::CLASSES[$className];
85 85
 
86
-        if (! array_key_exists($className, $this->classNodes)) {
86
+        if (!array_key_exists($className, $this->classNodes)) {
87 87
             $this->parseFile($filePath);
88 88
         }
89 89
 
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function generateFunctionStub(string $functionName) : ?StubData
104 104
     {
105
-        if (! array_key_exists($functionName, PhpStormStubsMap::FUNCTIONS)) {
105
+        if (!array_key_exists($functionName, PhpStormStubsMap::FUNCTIONS)) {
106 106
             return null;
107 107
         }
108 108
 
109 109
         $filePath = PhpStormStubsMap::FUNCTIONS[$functionName];
110 110
 
111
-        if (! array_key_exists($functionName, $this->functionNodes)) {
111
+        if (!array_key_exists($functionName, $this->functionNodes)) {
112 112
             $this->parseFile($filePath);
113 113
         }
114 114
 
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
             $constantName = strtolower($constantName);
126 126
         }
127 127
 
128
-        if (! array_key_exists($constantName, PhpStormStubsMap::CONSTANTS)) {
128
+        if (!array_key_exists($constantName, PhpStormStubsMap::CONSTANTS)) {
129 129
             return null;
130 130
         }
131 131
 
132 132
         $filePath = PhpStormStubsMap::CONSTANTS[$constantName];
133 133
 
134
-        if (! array_key_exists($constantName, $this->constantNodes)) {
134
+        if (!array_key_exists($constantName, $this->constantNodes)) {
135 135
             $this->parseFile($filePath);
136 136
         }
137 137
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
     private function createStub(Node $node) : string
170 170
     {
171
-        return "<?php\n\n" . $this->prettyPrinter->prettyPrint([$node]) . ($node instanceof Node\Expr\FuncCall ? ';' : '') . "\n";
171
+        return "<?php\n\n".$this->prettyPrinter->prettyPrint([$node]).($node instanceof Node\Expr\FuncCall ? ';' : '')."\n";
172 172
     }
173 173
 
174 174
     private function createCachingVisitor() : NodeVisitorAbstract
Please login to merge, or discard this patch.
bin/generate-phpstorm-stubs-map.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 use function substr;
28 28
 use function var_export;
29 29
 
30
-(function () : void {
31
-    require __DIR__ . '/../vendor/autoload.php';
30
+(function() : void {
31
+    require __DIR__.'/../vendor/autoload.php';
32 32
 
33
-    $phpStormStubsDirectory = __DIR__ . '/../vendor/jetbrains/phpstorm-stubs';
33
+    $phpStormStubsDirectory = __DIR__.'/../vendor/jetbrains/phpstorm-stubs';
34 34
 
35 35
     $phpParser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
36 36
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             continue;
132 132
         }
133 133
 
134
-        if (! $directoryInfo->isDir()) {
134
+        if (!$directoryInfo->isDir()) {
135 135
             continue;
136 136
         }
137 137
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 continue;
145 145
             }
146 146
 
147
-            if (! preg_match('/\.php$/', $fileInfo->getBasename())) {
147
+            if (!preg_match('/\.php$/', $fileInfo->getBasename())) {
148 148
                 continue;
149 149
             }
150 150
 
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
         }
174 174
     }
175 175
 
176
-    $mapWithRelativeFilePaths = array_map(static function (array $files) use ($phpStormStubsDirectory) : array {
176
+    $mapWithRelativeFilePaths = array_map(static function(array $files) use ($phpStormStubsDirectory) : array {
177 177
         ksort($files);
178 178
 
179
-        return array_map(static function (string $filePath) use ($phpStormStubsDirectory) : string {
179
+        return array_map(static function(string $filePath) use ($phpStormStubsDirectory) : string {
180 180
             return str_replace('\\', '/', substr($filePath, strlen($phpStormStubsDirectory) + 1));
181 181
         }, $files);
182 182
     }, $map);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 }
206 206
 PHP;
207 207
 
208
-    $mapFile = __DIR__ . '/../src/SourceLocator/SourceStubber/PhpStormStubsMap.php';
208
+    $mapFile = __DIR__.'/../src/SourceLocator/SourceStubber/PhpStormStubsMap.php';
209 209
 
210 210
     $bytesWritten = @file_put_contents($mapFile, $output);
211 211
     if ($bytesWritten === false) {
Please login to merge, or discard this patch.
src/BetterReflection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
     public function astLocator() : AstLocator
95 95
     {
96 96
         return $this->astLocator
97
-            ?? $this->astLocator = new AstLocator($this->phpParser(), function () : FunctionReflector {
97
+            ?? $this->astLocator = new AstLocator($this->phpParser(), function() : FunctionReflector {
98 98
                 return $this->functionReflector();
99 99
             });
100 100
     }
Please login to merge, or discard this patch.
src/SourceLocator/SourceStubber/AggregateSourceStubber.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
      */
55 55
     public function generateConstantStub(string $constantName) : ?StubData
56 56
     {
57
-        return array_reduce($this->sourceStubbers, static function (?StubData $stubData, SourceStubber $sourceStubber) use ($constantName) : ?StubData {
57
+        return array_reduce($this->sourceStubbers, static function(?StubData $stubData, SourceStubber $sourceStubber) use ($constantName) : ?StubData {
58 58
             return $stubData ?? $sourceStubber->generateConstantStub($constantName);
59 59
         }, null);
60 60
     }
Please login to merge, or discard this patch.
src/SourceLocator/SourceStubber/ReflectionSourceStubber.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function generateClassStub(string $className) : ?StubData
72 72
     {
73
-        if (! (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false))) {
73
+        if (!(class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false))) {
74 74
             return null;
75 75
         }
76 76
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         $extensionName = $classReflection->getExtensionName() ?: null;
98 98
 
99
-        if (! $classReflection->inNamespace()) {
99
+        if (!$classReflection->inNamespace()) {
100 100
             return $this->createStubData($this->generateStub($classNode->getNode()), $extensionName);
101 101
         }
102 102
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function generateFunctionStub(string $functionName) : ?StubData
107 107
     {
108
-        if (! function_exists($functionName)) {
108
+        if (!function_exists($functionName)) {
109 109
             return null;
110 110
         }
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
         $extensionName = $functionReflection->getExtensionName() ?: null;
119 119
 
120
-        if (! $functionReflection->inNamespace()) {
120
+        if (!$functionReflection->inNamespace()) {
121 121
             return $this->createStubData($this->generateStub($functionNode->getNode()), $extensionName);
122 122
         }
123 123
 
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 
198 198
     private function addClassModifiers(Class_ $classNode, CoreReflectionClass $classReflection) : void
199 199
     {
200
-        if (! $classReflection->isInterface() && $classReflection->isAbstract()) {
200
+        if (!$classReflection->isInterface() && $classReflection->isAbstract()) {
201 201
             // Interface \Iterator is interface and abstract
202 202
             $classNode->makeAbstract();
203 203
         }
204 204
 
205
-        if (! $classReflection->isFinal()) {
205
+        if (!$classReflection->isFinal()) {
206 206
             return;
207 207
         }
208 208
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         $defaultProperties = $classReflection->getDefaultProperties();
262 262
 
263 263
         foreach ($classReflection->getProperties() as $propertyReflection) {
264
-            if (! $this->isPropertyDeclaredInClass($propertyReflection, $classReflection)) {
264
+            if (!$this->isPropertyDeclaredInClass($propertyReflection, $classReflection)) {
265 265
                 continue;
266 266
             }
267 267
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             $propertyNode->makeProtected();
308 308
         }
309 309
 
310
-        if (! $propertyReflection->isPrivate()) {
310
+        if (!$propertyReflection->isPrivate()) {
311 311
             return;
312 312
         }
313 313
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     private function addMethods(Declaration $classNode, CoreReflectionClass $classReflection) : void
351 351
     {
352 352
         foreach ($classReflection->getMethods() as $methodReflection) {
353
-            if (! $this->isMethodDeclaredInClass($methodReflection, $classReflection)) {
353
+            if (!$this->isMethodDeclaredInClass($methodReflection, $classReflection)) {
354 354
                 continue;
355 355
             }
356 356
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
             $methodNode->makePrivate();
416 416
         }
417 417
 
418
-        if (! $methodReflection->returnsReference()) {
418
+        if (!$methodReflection->returnsReference()) {
419 419
             return;
420 420
         }
421 421
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
             $this->addParameterModifiers($parameterReflection, $parameterNode);
431 431
 
432
-            if ($parameterReflection->isOptional() && ! $parameterReflection->isVariadic()) {
432
+            if ($parameterReflection->isOptional() && !$parameterReflection->isVariadic()) {
433 433
                 $parameterNode->setDefault($this->parameterDefaultValue($parameterReflection, $functionReflectionAbstract));
434 434
             }
435 435
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
      */
476 476
     private function formatType(CoreReflectionType $type) : NodeAbstract
477 477
     {
478
-        $name     = (string) $type;
478
+        $name     = (string)$type;
479 479
         $nameNode = $type->isBuiltin() || in_array($name, ['self', 'parent'], true) ? new Name($name) : new FullyQualified($name);
480 480
 
481 481
         return $type->allowsNull() ? new NullableType($nameNode) : $nameNode;
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 
492 492
     private function generateStub(Node $node) : string
493 493
     {
494
-        return "<?php\n\n" . $this->prettyPrinter->prettyPrint([$node]) . ($node instanceof Node\Expr\FuncCall ? ';' : '') . "\n";
494
+        return "<?php\n\n".$this->prettyPrinter->prettyPrint([$node]).($node instanceof Node\Expr\FuncCall ? ';' : '')."\n";
495 495
     }
496 496
 
497 497
     private function createStubData(string $stub, ?string $extensionName) : StubData
Please login to merge, or discard this patch.