Completed
Pull Request — master (#82)
by Loren
05:16
created
src/NodeVisitor/BuiltinAliasFixer.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -189,6 +189,9 @@
 block discarded – undo
189 189
         $node->returnType = $this->fixType($node->returnType, self::RETURN_TYPES);
190 190
     }
191 191
 
192
+    /**
193
+     * @param integer $contextType
194
+     */
192 195
     private function fixType($node, $contextType) {
193 196
         if (!is_object($node) && (strval($node) == '')) {
194 197
             return $node;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             }
43 43
             $numericIndexCount = count(array_filter(
44 44
                 $options['supportedBuiltinTypeHints'],
45
-                (function ($val) { return preg_match('/^0*(0|[1-9]\\d*)$/', $val); }),
45
+                (function($val) { return preg_match('/^0*(0|[1-9]\\d*)$/', $val); }),
46 46
                 ARRAY_FILTER_USE_KEY
47 47
             ));
48 48
             foreach ($options['supportedBuiltinTypeHints'] as $key => $value) {
@@ -51,31 +51,31 @@  discard block
 block discarded – undo
51 51
                 $validFor     = $value;
52 52
                 if (
53 53
                     preg_match('/^0*(0|[1-9]\\d*)$/', $key) &&
54
-                    (intval($key) >= 0)                     &&
55
-                    (intval($key) <  $numericIndexCount)
54
+                    (intval($key) >= 0) &&
55
+                    (intval($key) < $numericIndexCount)
56 56
                 ) {
57 57
                     $numericIndex = true;
58 58
                     $typeHintName = $value;
59
-                    $validFor     = self::PARAMETER_TYPES|self::RETURN_TYPES;
59
+                    $validFor     = self::PARAMETER_TYPES | self::RETURN_TYPES;
60 60
                 }
61 61
                 if (!is_string($typeHintName) || !preg_match('/^\\w(?<!\\d)\\w*$/', $typeHintName)) {
62 62
                     throw new \InvalidArgumentException(
63 63
                         sprintf(
64
-                            "Option 'supportedBuiltinTypeHints's element %s " .
64
+                            "Option 'supportedBuiltinTypeHints's element %s ".
65 65
                                 " isn't a valid typehint string.",
66 66
                             var_export($typeHintName, true)
67 67
                         )
68 68
                     );
69 69
                 } elseif (
70
-                    !is_scalar($validFor)                                                                   ||
71
-                    (strval($validFor) != strval(intval($validFor)))                                        ||
72
-                    (intval($validFor) != (intval($validFor) & (self::PARAMETER_TYPES|self::RETURN_TYPES))) ||
70
+                    !is_scalar($validFor) ||
71
+                    (strval($validFor) != strval(intval($validFor))) ||
72
+                    (intval($validFor) != (intval($validFor) & (self::PARAMETER_TYPES | self::RETURN_TYPES))) ||
73 73
                     (intval($validFor) == 0)
74 74
                 ) {
75 75
                     throw new \InvalidArgumentException(
76 76
                         sprintf(
77
-                            "Option 'supportedBuiltinTypeHints's %s typehint applies to invalid " .
78
-                                "mask %s. Mask must be one of: %s::PARAMETER_TYPES (%d), %s::RETURN_TYPES (%d)" .
77
+                            "Option 'supportedBuiltinTypeHints's %s typehint applies to invalid ".
78
+                                "mask %s. Mask must be one of: %s::PARAMETER_TYPES (%d), %s::RETURN_TYPES (%d)".
79 79
                                 " or %s::PARAMETER_TYPES|%s::RETURN_TYPES (%d)",
80 80
                             var_export($validFor, true),
81 81
                             self::class,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                         )
89 89
                     );
90 90
                 } else {
91
-                    $this->supportedBuiltinTypeHints[$typeHintName] = intval($validFor) & (self::PARAMETER_TYPES|self::RETURN_TYPES);
91
+                    $this->supportedBuiltinTypeHints[$typeHintName] = intval($validFor) & (self::PARAMETER_TYPES | self::RETURN_TYPES);
92 92
                 }
93 93
             }
94 94
         } else {
@@ -126,31 +126,31 @@  discard block
 block discarded – undo
126 126
             $builtInTypeNames = [
127 127
                 'array'    => [
128 128
                     'introduced_version' => 50100,
129
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
129
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
130 130
                 ],
131 131
                 'callable' => [
132 132
                     'introduced_version' => 50400,
133
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
133
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
134 134
                 ],
135 135
                 'bool'     => [
136 136
                     'introduced_version' => 70000,
137
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
137
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
138 138
                 ],
139 139
                 'float'    => [
140 140
                     'introduced_version' => 70000,
141
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
141
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
142 142
                 ],
143 143
                 'int'      => [
144 144
                     'introduced_version' => 70000,
145
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
145
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
146 146
                 ],
147 147
                 'string'   => [
148 148
                     'introduced_version' => 70000,
149
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
149
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
150 150
                 ],
151 151
                 'iterable' => [
152 152
                     'introduced_version' => 70100,
153
-                    'valid_for'          => self::PARAMETER_TYPES|self::RETURN_TYPES,
153
+                    'valid_for'          => self::PARAMETER_TYPES | self::RETURN_TYPES,
154 154
                 ],
155 155
                 'void'     => [
156 156
                     'introduced_version' => 70100,
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
     public function enterNode(Node $node) {
175 175
         if (
176
-            ($node instanceof Stmt\Function_)   ||
176
+            ($node instanceof Stmt\Function_) ||
177 177
             ($node instanceof Stmt\ClassMethod) ||
178 178
             ($node instanceof Expr\Closure)
179 179
         ) {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         //     where a builtin type could be recognized as a class
215 215
         //     name instead.
216 216
         if (
217
-            ($node instanceof Name)      &&
217
+            ($node instanceof Name) &&
218 218
             !($node->isFullyQualified()) &&
219 219
             (count($node->parts) == 1) &&
220 220
             (
Please login to merge, or discard this patch.