@@ -10,43 +10,43 @@ |
||
10 | 10 | |
11 | 11 | class RemovedTag extends BaseTag |
12 | 12 | { |
13 | - private const REGEX_VECTOR = '(?:\d\S*|[^\s\:]+\:\s*\$[^\$]+\$)'; |
|
14 | - private $version; |
|
15 | - |
|
16 | - public function __construct(?string $version = null, Description $description = null) |
|
17 | - { |
|
18 | - $this->version = $version; |
|
19 | - $this->name = 'removed'; |
|
20 | - $this->description = $description; |
|
21 | - } |
|
22 | - |
|
23 | - public static function create(?string $body, ?DescriptionFactory $descriptionFactory = null, ?Context $context = null): RemovedTag |
|
24 | - { |
|
25 | - if (empty($body)) { |
|
26 | - return new self(); |
|
27 | - } |
|
28 | - |
|
29 | - $matches = []; |
|
30 | - if ($descriptionFactory !== null) { |
|
31 | - if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { |
|
32 | - return new self(null, $descriptionFactory->create($body, $context)); |
|
33 | - } |
|
34 | - |
|
35 | - return new self( |
|
36 | - $matches[1], |
|
37 | - $descriptionFactory->create($matches[2] ?? '', $context) |
|
38 | - ); |
|
39 | - } |
|
40 | - return new self(); |
|
41 | - } |
|
42 | - |
|
43 | - public function getVersion(): ?string |
|
44 | - { |
|
45 | - return $this->version; |
|
46 | - } |
|
47 | - |
|
48 | - public function __toString(): string |
|
49 | - { |
|
50 | - return "PhpStorm internal '@removed' tag"; |
|
51 | - } |
|
13 | + private const REGEX_VECTOR = '(?:\d\S*|[^\s\:]+\:\s*\$[^\$]+\$)'; |
|
14 | + private $version; |
|
15 | + |
|
16 | + public function __construct(?string $version = null, Description $description = null) |
|
17 | + { |
|
18 | + $this->version = $version; |
|
19 | + $this->name = 'removed'; |
|
20 | + $this->description = $description; |
|
21 | + } |
|
22 | + |
|
23 | + public static function create(?string $body, ?DescriptionFactory $descriptionFactory = null, ?Context $context = null): RemovedTag |
|
24 | + { |
|
25 | + if (empty($body)) { |
|
26 | + return new self(); |
|
27 | + } |
|
28 | + |
|
29 | + $matches = []; |
|
30 | + if ($descriptionFactory !== null) { |
|
31 | + if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { |
|
32 | + return new self(null, $descriptionFactory->create($body, $context)); |
|
33 | + } |
|
34 | + |
|
35 | + return new self( |
|
36 | + $matches[1], |
|
37 | + $descriptionFactory->create($matches[2] ?? '', $context) |
|
38 | + ); |
|
39 | + } |
|
40 | + return new self(); |
|
41 | + } |
|
42 | + |
|
43 | + public function getVersion(): ?string |
|
44 | + { |
|
45 | + return $this->version; |
|
46 | + } |
|
47 | + |
|
48 | + public function __toString(): string |
|
49 | + { |
|
50 | + return "PhpStorm internal '@removed' tag"; |
|
51 | + } |
|
52 | 52 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | $matches = []; |
30 | 30 | if ($descriptionFactory !== null) { |
31 | - if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) { |
|
31 | + if (!preg_match('/^('.self::REGEX_VECTOR.')\s*(.+)?$/sux', $body, $matches)) { |
|
32 | 32 | return new self(null, $descriptionFactory->create($body, $context)); |
33 | 33 | } |
34 | 34 |
@@ -8,8 +8,7 @@ |
||
8 | 8 | use phpDocumentor\Reflection\DocBlock\Tags\BaseTag; |
9 | 9 | use phpDocumentor\Reflection\Types\Context; |
10 | 10 | |
11 | -class RemovedTag extends BaseTag |
|
12 | -{ |
|
11 | +class RemovedTag extends BaseTag { |
|
13 | 12 | private const REGEX_VECTOR = '(?:\d\S*|[^\s\:]+\:\s*\$[^\$]+\$)'; |
14 | 13 | private $version; |
15 | 14 |
@@ -29,205 +29,205 @@ |
||
29 | 29 | |
30 | 30 | abstract class BasePHPElement |
31 | 31 | { |
32 | - use PHPDocElement; |
|
33 | - |
|
34 | - /** @var string|null */ |
|
35 | - public $name; |
|
36 | - public $stubBelongsToCore = false; |
|
37 | - /** @var Exception|null */ |
|
38 | - public $parseError; |
|
39 | - public $mutedProblems = []; |
|
40 | - public $availableVersionsRangeFromAttribute = []; |
|
41 | - /** @var string|null */ |
|
42 | - public $sourceFilePath; |
|
43 | - /** @var bool */ |
|
44 | - public $duplicateOtherElement = false; |
|
45 | - |
|
46 | - /** |
|
47 | - * @param Reflector $reflectionObject |
|
48 | - * @return static |
|
49 | - */ |
|
50 | - abstract public function readObjectFromReflection($reflectionObject); |
|
51 | - |
|
52 | - /** |
|
53 | - * @param Node $node |
|
54 | - * @return static |
|
55 | - */ |
|
56 | - abstract public function readObjectFromStubNode($node); |
|
57 | - |
|
58 | - /** |
|
59 | - * @param stdClass|array $jsonData |
|
60 | - */ |
|
61 | - abstract public function readMutedProblems($jsonData): void; |
|
62 | - |
|
63 | - public static function getFQN(Node $node): string |
|
64 | - { |
|
65 | - $fqn = ''; |
|
66 | - if (!property_exists($node, 'namespacedName') || $node->namespacedName === null) { |
|
67 | - if (property_exists($node, 'name')) { |
|
68 | - $fqn = $node->name->parts[0]; |
|
69 | - } else { |
|
70 | - foreach ($node->parts as $part) { |
|
71 | - $fqn .= "$part\\"; |
|
72 | - } |
|
73 | - } |
|
74 | - } else { |
|
75 | - /** @var string $part */ |
|
76 | - foreach ($node->namespacedName->parts as $part) { |
|
77 | - $fqn .= "$part\\"; |
|
78 | - } |
|
79 | - } |
|
80 | - return rtrim($fqn, "\\"); |
|
81 | - } |
|
82 | - |
|
83 | - protected static function getReflectionTypeAsArray(?ReflectionType $type): array |
|
84 | - { |
|
85 | - $reflectionTypes = []; |
|
86 | - if ($type instanceof ReflectionNamedType) { |
|
87 | - $type->allowsNull() && $type->getName() !== 'mixed' ? |
|
88 | - array_push($reflectionTypes, '?' . $type->getName()) : array_push($reflectionTypes, $type->getName()); |
|
89 | - } |
|
90 | - if ($type instanceof ReflectionUnionType) { |
|
91 | - foreach ($type->getTypes() as $namedType) { |
|
92 | - $reflectionTypes[] = $namedType->getName(); |
|
93 | - } |
|
94 | - } |
|
95 | - return $reflectionTypes; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param Name|Identifier|NullableType|string|UnionType|null|Type $type |
|
100 | - */ |
|
101 | - protected static function convertParsedTypeToArray($type): array |
|
102 | - { |
|
103 | - $types = []; |
|
104 | - if ($type !== null) { |
|
105 | - if ($type instanceof UnionType) { |
|
106 | - foreach ($type->types as $namedType) { |
|
107 | - $types[] = self::getTypeNameFromNode($namedType); |
|
108 | - } |
|
109 | - } elseif ($type instanceof Type) { |
|
110 | - array_push($types, ...explode('|', (string)$type)); |
|
111 | - } else { |
|
112 | - $types[] = self::getTypeNameFromNode($type); |
|
113 | - } |
|
114 | - } |
|
115 | - return $types; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @param Name|Identifier|NullableType|string $type |
|
120 | - */ |
|
121 | - protected static function getTypeNameFromNode($type): string |
|
122 | - { |
|
123 | - $nullable = false; |
|
124 | - $typeName = ''; |
|
125 | - if ($type instanceof NullableType) { |
|
126 | - $type = $type->type; |
|
127 | - $nullable = true; |
|
128 | - } |
|
129 | - if (empty($type->name)) { |
|
130 | - if (!empty($type->parts)) { |
|
131 | - $typeName = $nullable ? '?' . implode('\\', $type->parts) : implode('\\', $type->parts); |
|
132 | - } |
|
133 | - } else { |
|
134 | - $typeName = $nullable ? '?' . $type->name : $type->name; |
|
135 | - } |
|
136 | - return $typeName; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param AttributeGroup[] $attrGroups |
|
141 | - * @return string[] |
|
142 | - */ |
|
143 | - protected static function findTypesFromAttribute(array $attrGroups): array |
|
144 | - { |
|
145 | - foreach ($attrGroups as $attrGroup) { |
|
146 | - foreach ($attrGroup->attrs as $attr) { |
|
147 | - if ($attr->name->toString() === LanguageLevelTypeAware::class) { |
|
148 | - $types = []; |
|
149 | - $versionTypesMap = $attr->args[0]->value->items; |
|
150 | - foreach ($versionTypesMap as $item) { |
|
151 | - $firstVersionWithType = $item->key->value; |
|
152 | - foreach (new PhpVersions() as $version) { |
|
153 | - if ($version >= (float)$firstVersionWithType) { |
|
154 | - $types[number_format($version, 1)] = |
|
155 | - explode('|', preg_replace('/\w+\[]/', 'array', $item->value->value)); |
|
156 | - } |
|
157 | - } |
|
158 | - } |
|
159 | - $types[$attr->args[1]->name->name] = explode('|', preg_replace('/\w+\[]/', 'array', $attr->args[1]->value->value)); |
|
160 | - return $types; |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
164 | - return []; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @param AttributeGroup[] $attrGroups |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - protected static function findAvailableVersionsRangeFromAttribute(array $attrGroups): array |
|
172 | - { |
|
173 | - $versionRange = []; |
|
174 | - foreach ($attrGroups as $attrGroup) { |
|
175 | - foreach ($attrGroup->attrs as $attr) { |
|
176 | - if ($attr->name->toString() === PhpStormStubsElementAvailable::class) { |
|
177 | - if (count($attr->args) === 2) { |
|
178 | - foreach ($attr->args as $arg) { |
|
179 | - $versionRange[$arg->name->name] = (float)$arg->value->value; |
|
180 | - } |
|
181 | - } else { |
|
182 | - $arg = $attr->args[0]->value; |
|
183 | - if ($arg instanceof Array_) { |
|
184 | - $value = $arg->items[0]->value; |
|
185 | - if ($value instanceof String_) { |
|
186 | - return ['from' => (float)$value->value]; |
|
187 | - } |
|
188 | - } else { |
|
189 | - $rangeName = $attr->args[0]->name; |
|
190 | - return $rangeName === null || $rangeName->name === 'from' ? |
|
191 | - ['from' => (float)$arg->value, 'to' => PhpVersions::getLatest()] : |
|
192 | - ['from' => PhpVersions::getFirst(), 'to' => (float)$arg->value]; |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
197 | - } |
|
198 | - return $versionRange; |
|
199 | - } |
|
200 | - |
|
201 | - protected static function hasTentativeTypeAttribute(array $attrGroups): bool |
|
202 | - { |
|
203 | - foreach ($attrGroups as $attrGroup) { |
|
204 | - foreach ($attrGroup->attrs as $attr) { |
|
205 | - if ($attr->name->toString() === TentativeType::class) { |
|
206 | - return true; |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - return false; |
|
211 | - } |
|
212 | - |
|
213 | - public function hasMutedProblem(int $stubProblemType): bool |
|
214 | - { |
|
215 | - if (array_key_exists($stubProblemType, $this->mutedProblems)) { |
|
216 | - if (in_array('ALL', $this->mutedProblems[$stubProblemType], true) || |
|
217 | - in_array((float)getenv('PHP_VERSION'), $this->mutedProblems[$stubProblemType], true)) { |
|
218 | - return true; |
|
219 | - } |
|
220 | - } |
|
221 | - return false; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @param BasePHPElement $element |
|
226 | - * @return bool |
|
227 | - * @throws RuntimeException |
|
228 | - */ |
|
229 | - public static function entitySuitsCurrentPhpVersion(BasePHPElement $element): bool |
|
230 | - { |
|
231 | - return in_array((float)getenv('PHP_VERSION'), ParserUtils::getAvailableInVersions($element), true); |
|
232 | - } |
|
32 | + use PHPDocElement; |
|
33 | + |
|
34 | + /** @var string|null */ |
|
35 | + public $name; |
|
36 | + public $stubBelongsToCore = false; |
|
37 | + /** @var Exception|null */ |
|
38 | + public $parseError; |
|
39 | + public $mutedProblems = []; |
|
40 | + public $availableVersionsRangeFromAttribute = []; |
|
41 | + /** @var string|null */ |
|
42 | + public $sourceFilePath; |
|
43 | + /** @var bool */ |
|
44 | + public $duplicateOtherElement = false; |
|
45 | + |
|
46 | + /** |
|
47 | + * @param Reflector $reflectionObject |
|
48 | + * @return static |
|
49 | + */ |
|
50 | + abstract public function readObjectFromReflection($reflectionObject); |
|
51 | + |
|
52 | + /** |
|
53 | + * @param Node $node |
|
54 | + * @return static |
|
55 | + */ |
|
56 | + abstract public function readObjectFromStubNode($node); |
|
57 | + |
|
58 | + /** |
|
59 | + * @param stdClass|array $jsonData |
|
60 | + */ |
|
61 | + abstract public function readMutedProblems($jsonData): void; |
|
62 | + |
|
63 | + public static function getFQN(Node $node): string |
|
64 | + { |
|
65 | + $fqn = ''; |
|
66 | + if (!property_exists($node, 'namespacedName') || $node->namespacedName === null) { |
|
67 | + if (property_exists($node, 'name')) { |
|
68 | + $fqn = $node->name->parts[0]; |
|
69 | + } else { |
|
70 | + foreach ($node->parts as $part) { |
|
71 | + $fqn .= "$part\\"; |
|
72 | + } |
|
73 | + } |
|
74 | + } else { |
|
75 | + /** @var string $part */ |
|
76 | + foreach ($node->namespacedName->parts as $part) { |
|
77 | + $fqn .= "$part\\"; |
|
78 | + } |
|
79 | + } |
|
80 | + return rtrim($fqn, "\\"); |
|
81 | + } |
|
82 | + |
|
83 | + protected static function getReflectionTypeAsArray(?ReflectionType $type): array |
|
84 | + { |
|
85 | + $reflectionTypes = []; |
|
86 | + if ($type instanceof ReflectionNamedType) { |
|
87 | + $type->allowsNull() && $type->getName() !== 'mixed' ? |
|
88 | + array_push($reflectionTypes, '?' . $type->getName()) : array_push($reflectionTypes, $type->getName()); |
|
89 | + } |
|
90 | + if ($type instanceof ReflectionUnionType) { |
|
91 | + foreach ($type->getTypes() as $namedType) { |
|
92 | + $reflectionTypes[] = $namedType->getName(); |
|
93 | + } |
|
94 | + } |
|
95 | + return $reflectionTypes; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param Name|Identifier|NullableType|string|UnionType|null|Type $type |
|
100 | + */ |
|
101 | + protected static function convertParsedTypeToArray($type): array |
|
102 | + { |
|
103 | + $types = []; |
|
104 | + if ($type !== null) { |
|
105 | + if ($type instanceof UnionType) { |
|
106 | + foreach ($type->types as $namedType) { |
|
107 | + $types[] = self::getTypeNameFromNode($namedType); |
|
108 | + } |
|
109 | + } elseif ($type instanceof Type) { |
|
110 | + array_push($types, ...explode('|', (string)$type)); |
|
111 | + } else { |
|
112 | + $types[] = self::getTypeNameFromNode($type); |
|
113 | + } |
|
114 | + } |
|
115 | + return $types; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @param Name|Identifier|NullableType|string $type |
|
120 | + */ |
|
121 | + protected static function getTypeNameFromNode($type): string |
|
122 | + { |
|
123 | + $nullable = false; |
|
124 | + $typeName = ''; |
|
125 | + if ($type instanceof NullableType) { |
|
126 | + $type = $type->type; |
|
127 | + $nullable = true; |
|
128 | + } |
|
129 | + if (empty($type->name)) { |
|
130 | + if (!empty($type->parts)) { |
|
131 | + $typeName = $nullable ? '?' . implode('\\', $type->parts) : implode('\\', $type->parts); |
|
132 | + } |
|
133 | + } else { |
|
134 | + $typeName = $nullable ? '?' . $type->name : $type->name; |
|
135 | + } |
|
136 | + return $typeName; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param AttributeGroup[] $attrGroups |
|
141 | + * @return string[] |
|
142 | + */ |
|
143 | + protected static function findTypesFromAttribute(array $attrGroups): array |
|
144 | + { |
|
145 | + foreach ($attrGroups as $attrGroup) { |
|
146 | + foreach ($attrGroup->attrs as $attr) { |
|
147 | + if ($attr->name->toString() === LanguageLevelTypeAware::class) { |
|
148 | + $types = []; |
|
149 | + $versionTypesMap = $attr->args[0]->value->items; |
|
150 | + foreach ($versionTypesMap as $item) { |
|
151 | + $firstVersionWithType = $item->key->value; |
|
152 | + foreach (new PhpVersions() as $version) { |
|
153 | + if ($version >= (float)$firstVersionWithType) { |
|
154 | + $types[number_format($version, 1)] = |
|
155 | + explode('|', preg_replace('/\w+\[]/', 'array', $item->value->value)); |
|
156 | + } |
|
157 | + } |
|
158 | + } |
|
159 | + $types[$attr->args[1]->name->name] = explode('|', preg_replace('/\w+\[]/', 'array', $attr->args[1]->value->value)); |
|
160 | + return $types; |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | + return []; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @param AttributeGroup[] $attrGroups |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + protected static function findAvailableVersionsRangeFromAttribute(array $attrGroups): array |
|
172 | + { |
|
173 | + $versionRange = []; |
|
174 | + foreach ($attrGroups as $attrGroup) { |
|
175 | + foreach ($attrGroup->attrs as $attr) { |
|
176 | + if ($attr->name->toString() === PhpStormStubsElementAvailable::class) { |
|
177 | + if (count($attr->args) === 2) { |
|
178 | + foreach ($attr->args as $arg) { |
|
179 | + $versionRange[$arg->name->name] = (float)$arg->value->value; |
|
180 | + } |
|
181 | + } else { |
|
182 | + $arg = $attr->args[0]->value; |
|
183 | + if ($arg instanceof Array_) { |
|
184 | + $value = $arg->items[0]->value; |
|
185 | + if ($value instanceof String_) { |
|
186 | + return ['from' => (float)$value->value]; |
|
187 | + } |
|
188 | + } else { |
|
189 | + $rangeName = $attr->args[0]->name; |
|
190 | + return $rangeName === null || $rangeName->name === 'from' ? |
|
191 | + ['from' => (float)$arg->value, 'to' => PhpVersions::getLatest()] : |
|
192 | + ['from' => PhpVersions::getFirst(), 'to' => (float)$arg->value]; |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | + } |
|
198 | + return $versionRange; |
|
199 | + } |
|
200 | + |
|
201 | + protected static function hasTentativeTypeAttribute(array $attrGroups): bool |
|
202 | + { |
|
203 | + foreach ($attrGroups as $attrGroup) { |
|
204 | + foreach ($attrGroup->attrs as $attr) { |
|
205 | + if ($attr->name->toString() === TentativeType::class) { |
|
206 | + return true; |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + return false; |
|
211 | + } |
|
212 | + |
|
213 | + public function hasMutedProblem(int $stubProblemType): bool |
|
214 | + { |
|
215 | + if (array_key_exists($stubProblemType, $this->mutedProblems)) { |
|
216 | + if (in_array('ALL', $this->mutedProblems[$stubProblemType], true) || |
|
217 | + in_array((float)getenv('PHP_VERSION'), $this->mutedProblems[$stubProblemType], true)) { |
|
218 | + return true; |
|
219 | + } |
|
220 | + } |
|
221 | + return false; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @param BasePHPElement $element |
|
226 | + * @return bool |
|
227 | + * @throws RuntimeException |
|
228 | + */ |
|
229 | + public static function entitySuitsCurrentPhpVersion(BasePHPElement $element): bool |
|
230 | + { |
|
231 | + return in_array((float)getenv('PHP_VERSION'), ParserUtils::getAvailableInVersions($element), true); |
|
232 | + } |
|
233 | 233 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $reflectionTypes = []; |
86 | 86 | if ($type instanceof ReflectionNamedType) { |
87 | 87 | $type->allowsNull() && $type->getName() !== 'mixed' ? |
88 | - array_push($reflectionTypes, '?' . $type->getName()) : array_push($reflectionTypes, $type->getName()); |
|
88 | + array_push($reflectionTypes, '?'.$type->getName()) : array_push($reflectionTypes, $type->getName()); |
|
89 | 89 | } |
90 | 90 | if ($type instanceof ReflectionUnionType) { |
91 | 91 | foreach ($type->getTypes() as $namedType) { |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | } |
129 | 129 | if (empty($type->name)) { |
130 | 130 | if (!empty($type->parts)) { |
131 | - $typeName = $nullable ? '?' . implode('\\', $type->parts) : implode('\\', $type->parts); |
|
131 | + $typeName = $nullable ? '?'.implode('\\', $type->parts) : implode('\\', $type->parts); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $typeName = $nullable ? '?' . $type->name : $type->name; |
|
134 | + $typeName = $nullable ? '?'.$type->name : $type->name; |
|
135 | 135 | } |
136 | 136 | return $typeName; |
137 | 137 | } |
@@ -188,8 +188,7 @@ discard block |
||
188 | 188 | } else { |
189 | 189 | $rangeName = $attr->args[0]->name; |
190 | 190 | return $rangeName === null || $rangeName->name === 'from' ? |
191 | - ['from' => (float)$arg->value, 'to' => PhpVersions::getLatest()] : |
|
192 | - ['from' => PhpVersions::getFirst(), 'to' => (float)$arg->value]; |
|
191 | + ['from' => (float)$arg->value, 'to' => PhpVersions::getLatest()] : ['from' => PhpVersions::getFirst(), 'to' => (float)$arg->value]; |
|
193 | 192 | } |
194 | 193 | } |
195 | 194 | } |
@@ -27,8 +27,7 @@ |
||
27 | 27 | use function count; |
28 | 28 | use function in_array; |
29 | 29 | |
30 | -abstract class BasePHPElement |
|
31 | -{ |
|
30 | +abstract class BasePHPElement { |
|
32 | 31 | use PHPDocElement; |
33 | 32 | |
34 | 33 | /** @var string|null */ |
@@ -11,102 +11,102 @@ |
||
11 | 11 | |
12 | 12 | class PHPParameter extends BasePHPElement |
13 | 13 | { |
14 | - public $indexInSignature = 0; |
|
15 | - /** @var string[] */ |
|
16 | - public $typesFromSignature = []; |
|
17 | - /** @var string[][] */ |
|
18 | - public $typesFromAttribute = []; |
|
19 | - /** @var string[] */ |
|
20 | - public $typesFromPhpDoc = []; |
|
21 | - public $is_vararg = false; |
|
22 | - public $is_passed_by_ref = false; |
|
23 | - public $isOptional = false; |
|
24 | - public $defaultValue; |
|
14 | + public $indexInSignature = 0; |
|
15 | + /** @var string[] */ |
|
16 | + public $typesFromSignature = []; |
|
17 | + /** @var string[][] */ |
|
18 | + public $typesFromAttribute = []; |
|
19 | + /** @var string[] */ |
|
20 | + public $typesFromPhpDoc = []; |
|
21 | + public $is_vararg = false; |
|
22 | + public $is_passed_by_ref = false; |
|
23 | + public $isOptional = false; |
|
24 | + public $defaultValue; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param ReflectionParameter $reflectionObject |
|
28 | - * @return static |
|
29 | - */ |
|
30 | - public function readObjectFromReflection($reflectionObject) |
|
31 | - { |
|
32 | - $this->name = $reflectionObject->name; |
|
33 | - $this->typesFromSignature = self::getReflectionTypeAsArray($reflectionObject->getType()); |
|
34 | - $this->is_vararg = $reflectionObject->isVariadic(); |
|
35 | - $this->is_passed_by_ref = $reflectionObject->isPassedByReference() && !$reflectionObject->canBePassedByValue(); |
|
36 | - $this->isOptional = $reflectionObject->isOptional(); |
|
37 | - $this->indexInSignature = $reflectionObject->getPosition(); |
|
38 | - if ($reflectionObject->isDefaultValueAvailable()) { |
|
39 | - $this->defaultValue = $reflectionObject->getDefaultValue(); |
|
40 | - if (in_array('bool', $this->typesFromSignature, true)) { |
|
41 | - $this->defaultValue = $reflectionObject->getDefaultValue() ? 'true' : 'false'; |
|
42 | - } |
|
43 | - } |
|
44 | - return $this; |
|
45 | - } |
|
26 | + /** |
|
27 | + * @param ReflectionParameter $reflectionObject |
|
28 | + * @return static |
|
29 | + */ |
|
30 | + public function readObjectFromReflection($reflectionObject) |
|
31 | + { |
|
32 | + $this->name = $reflectionObject->name; |
|
33 | + $this->typesFromSignature = self::getReflectionTypeAsArray($reflectionObject->getType()); |
|
34 | + $this->is_vararg = $reflectionObject->isVariadic(); |
|
35 | + $this->is_passed_by_ref = $reflectionObject->isPassedByReference() && !$reflectionObject->canBePassedByValue(); |
|
36 | + $this->isOptional = $reflectionObject->isOptional(); |
|
37 | + $this->indexInSignature = $reflectionObject->getPosition(); |
|
38 | + if ($reflectionObject->isDefaultValueAvailable()) { |
|
39 | + $this->defaultValue = $reflectionObject->getDefaultValue(); |
|
40 | + if (in_array('bool', $this->typesFromSignature, true)) { |
|
41 | + $this->defaultValue = $reflectionObject->getDefaultValue() ? 'true' : 'false'; |
|
42 | + } |
|
43 | + } |
|
44 | + return $this; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param Param $node |
|
49 | - * @return static |
|
50 | - */ |
|
51 | - public function readObjectFromStubNode($node) |
|
52 | - { |
|
53 | - $this->name = $node->var->name; |
|
47 | + /** |
|
48 | + * @param Param $node |
|
49 | + * @return static |
|
50 | + */ |
|
51 | + public function readObjectFromStubNode($node) |
|
52 | + { |
|
53 | + $this->name = $node->var->name; |
|
54 | 54 | |
55 | - $this->typesFromAttribute = self::findTypesFromAttribute($node->attrGroups); |
|
56 | - $this->typesFromSignature = self::convertParsedTypeToArray($node->type); |
|
57 | - $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
58 | - $this->is_vararg = $node->variadic; |
|
59 | - $this->is_passed_by_ref = $node->byRef; |
|
60 | - $this->defaultValue = $node->default; |
|
61 | - $this->isOptional = !empty($this->defaultValue) || $this->is_vararg; |
|
62 | - return $this; |
|
63 | - } |
|
55 | + $this->typesFromAttribute = self::findTypesFromAttribute($node->attrGroups); |
|
56 | + $this->typesFromSignature = self::convertParsedTypeToArray($node->type); |
|
57 | + $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
58 | + $this->is_vararg = $node->variadic; |
|
59 | + $this->is_passed_by_ref = $node->byRef; |
|
60 | + $this->defaultValue = $node->default; |
|
61 | + $this->isOptional = !empty($this->defaultValue) || $this->is_vararg; |
|
62 | + return $this; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param stdClass|array $jsonData |
|
67 | - * @throws Exception |
|
68 | - */ |
|
69 | - public function readMutedProblems($jsonData): void |
|
70 | - { |
|
71 | - foreach ($jsonData as $parameter) { |
|
72 | - if ($parameter->name === $this->name && !empty($parameter->problems)) { |
|
73 | - foreach ($parameter->problems as $problem) { |
|
74 | - switch ($problem->description) { |
|
75 | - case 'parameter type mismatch': |
|
76 | - $this->mutedProblems[StubProblemType::PARAMETER_TYPE_MISMATCH] = $problem->versions; |
|
77 | - break; |
|
78 | - case 'parameter reference': |
|
79 | - $this->mutedProblems[StubProblemType::PARAMETER_REFERENCE] = $problem->versions; |
|
80 | - break; |
|
81 | - case 'parameter vararg': |
|
82 | - $this->mutedProblems[StubProblemType::PARAMETER_VARARG] = $problem->versions; |
|
83 | - break; |
|
84 | - case 'has scalar typehint': |
|
85 | - $this->mutedProblems[StubProblemType::PARAMETER_HAS_SCALAR_TYPEHINT] = $problem->versions; |
|
86 | - break; |
|
87 | - case 'parameter name mismatch': |
|
88 | - $this->mutedProblems[StubProblemType::PARAMETER_NAME_MISMATCH] = $problem->versions; |
|
89 | - break; |
|
90 | - case 'has nullable typehint': |
|
91 | - $this->mutedProblems[StubProblemType::HAS_NULLABLE_TYPEHINT] = $problem->versions; |
|
92 | - break; |
|
93 | - case 'has union typehint': |
|
94 | - $this->mutedProblems[StubProblemType::HAS_UNION_TYPEHINT] = $problem->versions; |
|
95 | - break; |
|
96 | - case 'has type mismatch in signature and phpdoc': |
|
97 | - $this->mutedProblems[StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE] = $problem->versions; |
|
98 | - break; |
|
99 | - case 'wrong default value': |
|
100 | - $this->mutedProblems[StubProblemType::WRONG_PARAMETER_DEFAULT_VALUE] = $problem->versions; |
|
101 | - break; |
|
102 | - case 'wrong optionallity': |
|
103 | - $this->mutedProblems[StubProblemType::WRONG_OPTIONALLITY] = $problem->versions; |
|
104 | - break; |
|
105 | - default: |
|
106 | - throw new Exception("Unexpected value $problem->description"); |
|
107 | - } |
|
108 | - } |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
65 | + /** |
|
66 | + * @param stdClass|array $jsonData |
|
67 | + * @throws Exception |
|
68 | + */ |
|
69 | + public function readMutedProblems($jsonData): void |
|
70 | + { |
|
71 | + foreach ($jsonData as $parameter) { |
|
72 | + if ($parameter->name === $this->name && !empty($parameter->problems)) { |
|
73 | + foreach ($parameter->problems as $problem) { |
|
74 | + switch ($problem->description) { |
|
75 | + case 'parameter type mismatch': |
|
76 | + $this->mutedProblems[StubProblemType::PARAMETER_TYPE_MISMATCH] = $problem->versions; |
|
77 | + break; |
|
78 | + case 'parameter reference': |
|
79 | + $this->mutedProblems[StubProblemType::PARAMETER_REFERENCE] = $problem->versions; |
|
80 | + break; |
|
81 | + case 'parameter vararg': |
|
82 | + $this->mutedProblems[StubProblemType::PARAMETER_VARARG] = $problem->versions; |
|
83 | + break; |
|
84 | + case 'has scalar typehint': |
|
85 | + $this->mutedProblems[StubProblemType::PARAMETER_HAS_SCALAR_TYPEHINT] = $problem->versions; |
|
86 | + break; |
|
87 | + case 'parameter name mismatch': |
|
88 | + $this->mutedProblems[StubProblemType::PARAMETER_NAME_MISMATCH] = $problem->versions; |
|
89 | + break; |
|
90 | + case 'has nullable typehint': |
|
91 | + $this->mutedProblems[StubProblemType::HAS_NULLABLE_TYPEHINT] = $problem->versions; |
|
92 | + break; |
|
93 | + case 'has union typehint': |
|
94 | + $this->mutedProblems[StubProblemType::HAS_UNION_TYPEHINT] = $problem->versions; |
|
95 | + break; |
|
96 | + case 'has type mismatch in signature and phpdoc': |
|
97 | + $this->mutedProblems[StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE] = $problem->versions; |
|
98 | + break; |
|
99 | + case 'wrong default value': |
|
100 | + $this->mutedProblems[StubProblemType::WRONG_PARAMETER_DEFAULT_VALUE] = $problem->versions; |
|
101 | + break; |
|
102 | + case 'wrong optionallity': |
|
103 | + $this->mutedProblems[StubProblemType::WRONG_OPTIONALLITY] = $problem->versions; |
|
104 | + break; |
|
105 | + default: |
|
106 | + throw new Exception("Unexpected value $problem->description"); |
|
107 | + } |
|
108 | + } |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | 112 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | use stdClass; |
10 | 10 | use function in_array; |
11 | 11 | |
12 | -class PHPParameter extends BasePHPElement |
|
13 | -{ |
|
12 | +class PHPParameter extends BasePHPElement { |
|
14 | 13 | public $indexInSignature = 0; |
15 | 14 | /** @var string[] */ |
16 | 15 | public $typesFromSignature = []; |
@@ -16,182 +16,182 @@ |
||
16 | 16 | |
17 | 17 | class PHPClass extends BasePHPClass |
18 | 18 | { |
19 | - /** |
|
20 | - * @var false|string|null |
|
21 | - */ |
|
22 | - public $parentClass; |
|
23 | - public $interfaces = []; |
|
24 | - /** @var PHPProperty[] */ |
|
25 | - public $properties = []; |
|
19 | + /** |
|
20 | + * @var false|string|null |
|
21 | + */ |
|
22 | + public $parentClass; |
|
23 | + public $interfaces = []; |
|
24 | + /** @var PHPProperty[] */ |
|
25 | + public $properties = []; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param ReflectionClass $reflectionObject |
|
29 | - * @return static |
|
30 | - */ |
|
31 | - public function readObjectFromReflection($reflectionObject) |
|
32 | - { |
|
33 | - $this->name = $reflectionObject->getName(); |
|
34 | - $parent = $reflectionObject->getParentClass(); |
|
35 | - if ($parent !== false) { |
|
36 | - $this->parentClass = $parent->getName(); |
|
37 | - } |
|
38 | - $this->interfaces = $reflectionObject->getInterfaceNames(); |
|
39 | - $this->isFinal = $reflectionObject->isFinal(); |
|
40 | - foreach ($reflectionObject->getMethods() as $method) { |
|
41 | - if ($method->getDeclaringClass()->getName() !== $this->name) { |
|
42 | - continue; |
|
43 | - } |
|
44 | - $parsedMethod = (new PHPMethod())->readObjectFromReflection($method); |
|
45 | - $this->addMethod($parsedMethod); |
|
46 | - } |
|
27 | + /** |
|
28 | + * @param ReflectionClass $reflectionObject |
|
29 | + * @return static |
|
30 | + */ |
|
31 | + public function readObjectFromReflection($reflectionObject) |
|
32 | + { |
|
33 | + $this->name = $reflectionObject->getName(); |
|
34 | + $parent = $reflectionObject->getParentClass(); |
|
35 | + if ($parent !== false) { |
|
36 | + $this->parentClass = $parent->getName(); |
|
37 | + } |
|
38 | + $this->interfaces = $reflectionObject->getInterfaceNames(); |
|
39 | + $this->isFinal = $reflectionObject->isFinal(); |
|
40 | + foreach ($reflectionObject->getMethods() as $method) { |
|
41 | + if ($method->getDeclaringClass()->getName() !== $this->name) { |
|
42 | + continue; |
|
43 | + } |
|
44 | + $parsedMethod = (new PHPMethod())->readObjectFromReflection($method); |
|
45 | + $this->addMethod($parsedMethod); |
|
46 | + } |
|
47 | 47 | |
48 | - foreach ($reflectionObject->getReflectionConstants() as $constant) { |
|
49 | - if ($constant->getDeclaringClass()->getName() !== $this->name) { |
|
50 | - continue; |
|
51 | - } |
|
52 | - $parsedConstant = (new PHPConst())->readObjectFromReflection($constant); |
|
53 | - $this->addConstant($parsedConstant); |
|
54 | - } |
|
48 | + foreach ($reflectionObject->getReflectionConstants() as $constant) { |
|
49 | + if ($constant->getDeclaringClass()->getName() !== $this->name) { |
|
50 | + continue; |
|
51 | + } |
|
52 | + $parsedConstant = (new PHPConst())->readObjectFromReflection($constant); |
|
53 | + $this->addConstant($parsedConstant); |
|
54 | + } |
|
55 | 55 | |
56 | - foreach ($reflectionObject->getProperties() as $property) { |
|
57 | - if ($property->getDeclaringClass()->getName() !== $this->name) { |
|
58 | - continue; |
|
59 | - } |
|
60 | - $parsedProperty = (new PHPProperty())->readObjectFromReflection($property); |
|
61 | - $this->addProperty($parsedProperty); |
|
62 | - } |
|
63 | - return $this; |
|
64 | - } |
|
56 | + foreach ($reflectionObject->getProperties() as $property) { |
|
57 | + if ($property->getDeclaringClass()->getName() !== $this->name) { |
|
58 | + continue; |
|
59 | + } |
|
60 | + $parsedProperty = (new PHPProperty())->readObjectFromReflection($property); |
|
61 | + $this->addProperty($parsedProperty); |
|
62 | + } |
|
63 | + return $this; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param Class_ $node |
|
68 | - * @return static |
|
69 | - */ |
|
70 | - public function readObjectFromStubNode($node) |
|
71 | - { |
|
72 | - $this->name = self::getFQN($node); |
|
73 | - $this->isFinal = $node->isFinal(); |
|
74 | - $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
75 | - $this->collectTags($node); |
|
76 | - if (!empty($node->extends)) { |
|
77 | - $this->parentClass = ''; |
|
78 | - foreach ($node->extends->parts as $part) { |
|
79 | - $this->parentClass .= "\\$part"; |
|
80 | - } |
|
81 | - $this->parentClass = ltrim($this->parentClass, "\\"); |
|
82 | - } |
|
83 | - if (!empty($node->implements)) { |
|
84 | - foreach ($node->implements as $interfaceObject) { |
|
85 | - $interfaceFQN = ''; |
|
86 | - foreach ($interfaceObject->parts as $interface) { |
|
87 | - $interfaceFQN .= "\\$interface"; |
|
88 | - } |
|
89 | - $this->interfaces[] = ltrim($interfaceFQN, "\\"); |
|
90 | - } |
|
91 | - } |
|
92 | - foreach ($node->getProperties() as $property) { |
|
93 | - $parsedProperty = (new PHPProperty($this->name))->readObjectFromStubNode($property); |
|
94 | - $this->addProperty($parsedProperty); |
|
95 | - } |
|
96 | - if ($node->getDocComment() !== null) { |
|
97 | - $docBlock = DocBlockFactory::createInstance()->create($node->getDocComment()->getText()); |
|
98 | - /** @var PropertyRead[] $properties */ |
|
99 | - $properties = array_merge( |
|
100 | - $docBlock->getTagsByName('property-read'), |
|
101 | - $docBlock->getTagsByName('property') |
|
102 | - ); |
|
103 | - foreach ($properties as $property) { |
|
104 | - $propertyName = $property->getVariableName(); |
|
105 | - assert($propertyName !== '', "@property name is empty in class $this->name"); |
|
106 | - $newProperty = new PHPProperty($this->name); |
|
107 | - $newProperty->is_static = false; |
|
108 | - $newProperty->access = 'public'; |
|
109 | - $newProperty->name = $propertyName; |
|
110 | - $newProperty->parentName = $this->name; |
|
111 | - $newProperty->typesFromSignature = self::convertParsedTypeToArray($property->getType()); |
|
112 | - assert( |
|
113 | - !array_key_exists($propertyName, $this->properties), |
|
114 | - "Property '$propertyName' is already declared in class '$this->name'" |
|
115 | - ); |
|
116 | - $this->properties[$propertyName] = $newProperty; |
|
117 | - } |
|
118 | - } |
|
66 | + /** |
|
67 | + * @param Class_ $node |
|
68 | + * @return static |
|
69 | + */ |
|
70 | + public function readObjectFromStubNode($node) |
|
71 | + { |
|
72 | + $this->name = self::getFQN($node); |
|
73 | + $this->isFinal = $node->isFinal(); |
|
74 | + $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
75 | + $this->collectTags($node); |
|
76 | + if (!empty($node->extends)) { |
|
77 | + $this->parentClass = ''; |
|
78 | + foreach ($node->extends->parts as $part) { |
|
79 | + $this->parentClass .= "\\$part"; |
|
80 | + } |
|
81 | + $this->parentClass = ltrim($this->parentClass, "\\"); |
|
82 | + } |
|
83 | + if (!empty($node->implements)) { |
|
84 | + foreach ($node->implements as $interfaceObject) { |
|
85 | + $interfaceFQN = ''; |
|
86 | + foreach ($interfaceObject->parts as $interface) { |
|
87 | + $interfaceFQN .= "\\$interface"; |
|
88 | + } |
|
89 | + $this->interfaces[] = ltrim($interfaceFQN, "\\"); |
|
90 | + } |
|
91 | + } |
|
92 | + foreach ($node->getProperties() as $property) { |
|
93 | + $parsedProperty = (new PHPProperty($this->name))->readObjectFromStubNode($property); |
|
94 | + $this->addProperty($parsedProperty); |
|
95 | + } |
|
96 | + if ($node->getDocComment() !== null) { |
|
97 | + $docBlock = DocBlockFactory::createInstance()->create($node->getDocComment()->getText()); |
|
98 | + /** @var PropertyRead[] $properties */ |
|
99 | + $properties = array_merge( |
|
100 | + $docBlock->getTagsByName('property-read'), |
|
101 | + $docBlock->getTagsByName('property') |
|
102 | + ); |
|
103 | + foreach ($properties as $property) { |
|
104 | + $propertyName = $property->getVariableName(); |
|
105 | + assert($propertyName !== '', "@property name is empty in class $this->name"); |
|
106 | + $newProperty = new PHPProperty($this->name); |
|
107 | + $newProperty->is_static = false; |
|
108 | + $newProperty->access = 'public'; |
|
109 | + $newProperty->name = $propertyName; |
|
110 | + $newProperty->parentName = $this->name; |
|
111 | + $newProperty->typesFromSignature = self::convertParsedTypeToArray($property->getType()); |
|
112 | + assert( |
|
113 | + !array_key_exists($propertyName, $this->properties), |
|
114 | + "Property '$propertyName' is already declared in class '$this->name'" |
|
115 | + ); |
|
116 | + $this->properties[$propertyName] = $newProperty; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - return $this; |
|
121 | - } |
|
120 | + return $this; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param stdClass|array $jsonData |
|
125 | - * @throws Exception |
|
126 | - */ |
|
127 | - public function readMutedProblems($jsonData): void |
|
128 | - { |
|
129 | - foreach ($jsonData as $class) { |
|
130 | - if ($class->name === $this->name) { |
|
131 | - if (!empty($class->problems)) { |
|
132 | - foreach ($class->problems as $problem) { |
|
133 | - switch ($problem->description) { |
|
134 | - case 'wrong parent': |
|
135 | - $this->mutedProblems[StubProblemType::WRONG_PARENT] = $problem->versions; |
|
136 | - break; |
|
137 | - case 'wrong interface': |
|
138 | - $this->mutedProblems[StubProblemType::WRONG_INTERFACE] = $problem->versions; |
|
139 | - break; |
|
140 | - case 'missing class': |
|
141 | - $this->mutedProblems[StubProblemType::STUB_IS_MISSED] = $problem->versions; |
|
142 | - break; |
|
143 | - case 'has wrong final modifier': |
|
144 | - $this->mutedProblems[StubProblemType::WRONG_FINAL_MODIFIER] = $problem->versions; |
|
145 | - break; |
|
146 | - default: |
|
147 | - throw new Exception("Unexpected value $problem->description"); |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - if (!empty($class->methods)) { |
|
152 | - foreach ($this->methods as $method) { |
|
153 | - $method->readMutedProblems($class->methods); |
|
154 | - } |
|
155 | - } |
|
156 | - if (!empty($class->constants)) { |
|
157 | - foreach ($this->constants as $constant) { |
|
158 | - $constant->readMutedProblems($class->constants); |
|
159 | - } |
|
160 | - } |
|
161 | - return; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
123 | + /** |
|
124 | + * @param stdClass|array $jsonData |
|
125 | + * @throws Exception |
|
126 | + */ |
|
127 | + public function readMutedProblems($jsonData): void |
|
128 | + { |
|
129 | + foreach ($jsonData as $class) { |
|
130 | + if ($class->name === $this->name) { |
|
131 | + if (!empty($class->problems)) { |
|
132 | + foreach ($class->problems as $problem) { |
|
133 | + switch ($problem->description) { |
|
134 | + case 'wrong parent': |
|
135 | + $this->mutedProblems[StubProblemType::WRONG_PARENT] = $problem->versions; |
|
136 | + break; |
|
137 | + case 'wrong interface': |
|
138 | + $this->mutedProblems[StubProblemType::WRONG_INTERFACE] = $problem->versions; |
|
139 | + break; |
|
140 | + case 'missing class': |
|
141 | + $this->mutedProblems[StubProblemType::STUB_IS_MISSED] = $problem->versions; |
|
142 | + break; |
|
143 | + case 'has wrong final modifier': |
|
144 | + $this->mutedProblems[StubProblemType::WRONG_FINAL_MODIFIER] = $problem->versions; |
|
145 | + break; |
|
146 | + default: |
|
147 | + throw new Exception("Unexpected value $problem->description"); |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + if (!empty($class->methods)) { |
|
152 | + foreach ($this->methods as $method) { |
|
153 | + $method->readMutedProblems($class->methods); |
|
154 | + } |
|
155 | + } |
|
156 | + if (!empty($class->constants)) { |
|
157 | + foreach ($this->constants as $constant) { |
|
158 | + $constant->readMutedProblems($class->constants); |
|
159 | + } |
|
160 | + } |
|
161 | + return; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - public function addProperty(PHPProperty $parsedProperty): void |
|
167 | - { |
|
168 | - if (isset($parsedProperty->name)) { |
|
169 | - if (array_key_exists($parsedProperty->name, $this->properties)) { |
|
170 | - $amount = count(array_filter( |
|
171 | - $this->properties, |
|
172 | - function (PHPProperty $nextProperty) use ($parsedProperty) { |
|
173 | - return $nextProperty->name === $parsedProperty->name; |
|
174 | - } |
|
175 | - )); |
|
176 | - $this->properties[$parsedProperty->name . '_duplicated_' . $amount] = $parsedProperty; |
|
177 | - } else { |
|
178 | - $this->properties[$parsedProperty->name] = $parsedProperty; |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
166 | + public function addProperty(PHPProperty $parsedProperty): void |
|
167 | + { |
|
168 | + if (isset($parsedProperty->name)) { |
|
169 | + if (array_key_exists($parsedProperty->name, $this->properties)) { |
|
170 | + $amount = count(array_filter( |
|
171 | + $this->properties, |
|
172 | + function (PHPProperty $nextProperty) use ($parsedProperty) { |
|
173 | + return $nextProperty->name === $parsedProperty->name; |
|
174 | + } |
|
175 | + )); |
|
176 | + $this->properties[$parsedProperty->name . '_duplicated_' . $amount] = $parsedProperty; |
|
177 | + } else { |
|
178 | + $this->properties[$parsedProperty->name] = $parsedProperty; |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * @throws RuntimeException |
|
185 | - */ |
|
186 | - public function getProperty($propertyName): ?PHPProperty |
|
187 | - { |
|
188 | - $properties = array_filter($this->properties, function (PHPProperty $property) use ($propertyName): bool { |
|
189 | - return $property->name === $propertyName && $property->duplicateOtherElement === false |
|
190 | - && BasePHPElement::entitySuitsCurrentPhpVersion($property); |
|
191 | - }); |
|
192 | - if (empty($properties)) { |
|
193 | - throw new RuntimeException("Property $propertyName not found in stubs for set language version"); |
|
194 | - } |
|
195 | - return array_pop($properties); |
|
196 | - } |
|
183 | + /** |
|
184 | + * @throws RuntimeException |
|
185 | + */ |
|
186 | + public function getProperty($propertyName): ?PHPProperty |
|
187 | + { |
|
188 | + $properties = array_filter($this->properties, function (PHPProperty $property) use ($propertyName): bool { |
|
189 | + return $property->name === $propertyName && $property->duplicateOtherElement === false |
|
190 | + && BasePHPElement::entitySuitsCurrentPhpVersion($property); |
|
191 | + }); |
|
192 | + if (empty($properties)) { |
|
193 | + throw new RuntimeException("Property $propertyName not found in stubs for set language version"); |
|
194 | + } |
|
195 | + return array_pop($properties); |
|
196 | + } |
|
197 | 197 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | if (array_key_exists($parsedProperty->name, $this->properties)) { |
170 | 170 | $amount = count(array_filter( |
171 | 171 | $this->properties, |
172 | - function (PHPProperty $nextProperty) use ($parsedProperty) { |
|
172 | + function(PHPProperty $nextProperty) use ($parsedProperty) { |
|
173 | 173 | return $nextProperty->name === $parsedProperty->name; |
174 | 174 | } |
175 | 175 | )); |
176 | - $this->properties[$parsedProperty->name . '_duplicated_' . $amount] = $parsedProperty; |
|
176 | + $this->properties[$parsedProperty->name.'_duplicated_'.$amount] = $parsedProperty; |
|
177 | 177 | } else { |
178 | 178 | $this->properties[$parsedProperty->name] = $parsedProperty; |
179 | 179 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getProperty($propertyName): ?PHPProperty |
187 | 187 | { |
188 | - $properties = array_filter($this->properties, function (PHPProperty $property) use ($propertyName): bool { |
|
188 | + $properties = array_filter($this->properties, function(PHPProperty $property) use ($propertyName) : bool { |
|
189 | 189 | return $property->name === $propertyName && $property->duplicateOtherElement === false |
190 | 190 | && BasePHPElement::entitySuitsCurrentPhpVersion($property); |
191 | 191 | }); |
@@ -14,8 +14,7 @@ |
||
14 | 14 | use function assert; |
15 | 15 | use function count; |
16 | 16 | |
17 | -class PHPClass extends BasePHPClass |
|
18 | -{ |
|
17 | +class PHPClass extends BasePHPClass { |
|
19 | 18 | /** |
20 | 19 | * @var false|string|null |
21 | 20 | */ |
@@ -9,79 +9,79 @@ |
||
9 | 9 | |
10 | 10 | abstract class BasePHPClass extends BasePHPElement |
11 | 11 | { |
12 | - /** |
|
13 | - * @var PHPMethod[] |
|
14 | - */ |
|
15 | - public $methods = []; |
|
12 | + /** |
|
13 | + * @var PHPMethod[] |
|
14 | + */ |
|
15 | + public $methods = []; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var PHPConst[] |
|
19 | - */ |
|
20 | - public $constants = []; |
|
17 | + /** |
|
18 | + * @var PHPConst[] |
|
19 | + */ |
|
20 | + public $constants = []; |
|
21 | 21 | |
22 | - public $isFinal = false; |
|
22 | + public $isFinal = false; |
|
23 | 23 | |
24 | - public function addConstant(PHPConst $parsedConstant): void |
|
25 | - { |
|
26 | - if (isset($parsedConstant->name)) { |
|
27 | - if (array_key_exists($parsedConstant->name, $this->constants)) { |
|
28 | - $amount = count(array_filter( |
|
29 | - $this->constants, |
|
30 | - function (PHPConst $nextConstant) use ($parsedConstant) { |
|
31 | - return $nextConstant->name === $parsedConstant->name; |
|
32 | - } |
|
33 | - )); |
|
34 | - $this->constants[$parsedConstant->name . '_duplicated_' . $amount] = $parsedConstant; |
|
35 | - } else { |
|
36 | - $this->constants[$parsedConstant->name] = $parsedConstant; |
|
37 | - } |
|
38 | - } |
|
39 | - } |
|
24 | + public function addConstant(PHPConst $parsedConstant): void |
|
25 | + { |
|
26 | + if (isset($parsedConstant->name)) { |
|
27 | + if (array_key_exists($parsedConstant->name, $this->constants)) { |
|
28 | + $amount = count(array_filter( |
|
29 | + $this->constants, |
|
30 | + function (PHPConst $nextConstant) use ($parsedConstant) { |
|
31 | + return $nextConstant->name === $parsedConstant->name; |
|
32 | + } |
|
33 | + )); |
|
34 | + $this->constants[$parsedConstant->name . '_duplicated_' . $amount] = $parsedConstant; |
|
35 | + } else { |
|
36 | + $this->constants[$parsedConstant->name] = $parsedConstant; |
|
37 | + } |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @throws RuntimeException |
|
43 | - */ |
|
44 | - public function getConstant($constantName): ?PHPConst |
|
45 | - { |
|
46 | - $constants = array_filter($this->constants, function (PHPConst $constant) use ($constantName): bool { |
|
47 | - return $constant->name === $constantName && $constant->duplicateOtherElement === false |
|
48 | - && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
|
49 | - }); |
|
50 | - if (empty($constants)) { |
|
51 | - throw new RuntimeException("Constant $constantName not found in stubs for set language version"); |
|
52 | - } |
|
53 | - return array_pop($constants); |
|
54 | - } |
|
41 | + /** |
|
42 | + * @throws RuntimeException |
|
43 | + */ |
|
44 | + public function getConstant($constantName): ?PHPConst |
|
45 | + { |
|
46 | + $constants = array_filter($this->constants, function (PHPConst $constant) use ($constantName): bool { |
|
47 | + return $constant->name === $constantName && $constant->duplicateOtherElement === false |
|
48 | + && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
|
49 | + }); |
|
50 | + if (empty($constants)) { |
|
51 | + throw new RuntimeException("Constant $constantName not found in stubs for set language version"); |
|
52 | + } |
|
53 | + return array_pop($constants); |
|
54 | + } |
|
55 | 55 | |
56 | - public function addMethod(PHPMethod $parsedMethod): void |
|
57 | - { |
|
58 | - if (isset($parsedMethod->name)) { |
|
59 | - if (array_key_exists($parsedMethod->name, $this->methods)) { |
|
60 | - $amount = count(array_filter( |
|
61 | - $this->methods, |
|
62 | - function (PHPMethod $nextMethod) use ($parsedMethod) { |
|
63 | - return $nextMethod->name === $parsedMethod->name; |
|
64 | - } |
|
65 | - )); |
|
66 | - $this->methods[$parsedMethod->name . '_duplicated_' . $amount] = $parsedMethod; |
|
67 | - } else { |
|
68 | - $this->methods[$parsedMethod->name] = $parsedMethod; |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
56 | + public function addMethod(PHPMethod $parsedMethod): void |
|
57 | + { |
|
58 | + if (isset($parsedMethod->name)) { |
|
59 | + if (array_key_exists($parsedMethod->name, $this->methods)) { |
|
60 | + $amount = count(array_filter( |
|
61 | + $this->methods, |
|
62 | + function (PHPMethod $nextMethod) use ($parsedMethod) { |
|
63 | + return $nextMethod->name === $parsedMethod->name; |
|
64 | + } |
|
65 | + )); |
|
66 | + $this->methods[$parsedMethod->name . '_duplicated_' . $amount] = $parsedMethod; |
|
67 | + } else { |
|
68 | + $this->methods[$parsedMethod->name] = $parsedMethod; |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @throws RuntimeException |
|
75 | - */ |
|
76 | - public function getMethod(string $methodName): ?PHPMethod |
|
77 | - { |
|
78 | - $methods = array_filter($this->methods, function (PHPMethod $method) use ($methodName): bool { |
|
79 | - return $method->name === $methodName && $method->duplicateOtherElement === false |
|
80 | - && BasePHPElement::entitySuitsCurrentPhpVersion($method); |
|
81 | - }); |
|
82 | - if (empty($methods)) { |
|
83 | - throw new RuntimeException("Method $methodName not found in stubs for set language version"); |
|
84 | - } |
|
85 | - return array_pop($methods); |
|
86 | - } |
|
73 | + /** |
|
74 | + * @throws RuntimeException |
|
75 | + */ |
|
76 | + public function getMethod(string $methodName): ?PHPMethod |
|
77 | + { |
|
78 | + $methods = array_filter($this->methods, function (PHPMethod $method) use ($methodName): bool { |
|
79 | + return $method->name === $methodName && $method->duplicateOtherElement === false |
|
80 | + && BasePHPElement::entitySuitsCurrentPhpVersion($method); |
|
81 | + }); |
|
82 | + if (empty($methods)) { |
|
83 | + throw new RuntimeException("Method $methodName not found in stubs for set language version"); |
|
84 | + } |
|
85 | + return array_pop($methods); |
|
86 | + } |
|
87 | 87 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | if (array_key_exists($parsedConstant->name, $this->constants)) { |
28 | 28 | $amount = count(array_filter( |
29 | 29 | $this->constants, |
30 | - function (PHPConst $nextConstant) use ($parsedConstant) { |
|
30 | + function(PHPConst $nextConstant) use ($parsedConstant) { |
|
31 | 31 | return $nextConstant->name === $parsedConstant->name; |
32 | 32 | } |
33 | 33 | )); |
34 | - $this->constants[$parsedConstant->name . '_duplicated_' . $amount] = $parsedConstant; |
|
34 | + $this->constants[$parsedConstant->name.'_duplicated_'.$amount] = $parsedConstant; |
|
35 | 35 | } else { |
36 | 36 | $this->constants[$parsedConstant->name] = $parsedConstant; |
37 | 37 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getConstant($constantName): ?PHPConst |
45 | 45 | { |
46 | - $constants = array_filter($this->constants, function (PHPConst $constant) use ($constantName): bool { |
|
46 | + $constants = array_filter($this->constants, function(PHPConst $constant) use ($constantName) : bool { |
|
47 | 47 | return $constant->name === $constantName && $constant->duplicateOtherElement === false |
48 | 48 | && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
49 | 49 | }); |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | if (array_key_exists($parsedMethod->name, $this->methods)) { |
60 | 60 | $amount = count(array_filter( |
61 | 61 | $this->methods, |
62 | - function (PHPMethod $nextMethod) use ($parsedMethod) { |
|
62 | + function(PHPMethod $nextMethod) use ($parsedMethod) { |
|
63 | 63 | return $nextMethod->name === $parsedMethod->name; |
64 | 64 | } |
65 | 65 | )); |
66 | - $this->methods[$parsedMethod->name . '_duplicated_' . $amount] = $parsedMethod; |
|
66 | + $this->methods[$parsedMethod->name.'_duplicated_'.$amount] = $parsedMethod; |
|
67 | 67 | } else { |
68 | 68 | $this->methods[$parsedMethod->name] = $parsedMethod; |
69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function getMethod(string $methodName): ?PHPMethod |
77 | 77 | { |
78 | - $methods = array_filter($this->methods, function (PHPMethod $method) use ($methodName): bool { |
|
78 | + $methods = array_filter($this->methods, function(PHPMethod $method) use ($methodName) : bool { |
|
79 | 79 | return $method->name === $methodName && $method->duplicateOtherElement === false |
80 | 80 | && BasePHPElement::entitySuitsCurrentPhpVersion($method); |
81 | 81 | }); |
@@ -7,8 +7,7 @@ |
||
7 | 7 | use function array_key_exists; |
8 | 8 | use function count; |
9 | 9 | |
10 | -abstract class BasePHPClass extends BasePHPElement |
|
11 | -{ |
|
10 | +abstract class BasePHPClass extends BasePHPElement { |
|
12 | 11 | /** |
13 | 12 | * @var PHPMethod[] |
14 | 13 | */ |
@@ -16,84 +16,84 @@ |
||
16 | 16 | |
17 | 17 | trait PHPDocElement |
18 | 18 | { |
19 | - /** |
|
20 | - * @var Link[] |
|
21 | - */ |
|
22 | - public $links = []; |
|
19 | + /** |
|
20 | + * @var Link[] |
|
21 | + */ |
|
22 | + public $links = []; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $phpdoc = ''; |
|
24 | + /** |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $phpdoc = ''; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var See[] |
|
31 | - */ |
|
32 | - public $see = []; |
|
29 | + /** |
|
30 | + * @var See[] |
|
31 | + */ |
|
32 | + public $see = []; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var Since[] |
|
36 | - */ |
|
37 | - public $sinceTags = []; |
|
34 | + /** |
|
35 | + * @var Since[] |
|
36 | + */ |
|
37 | + public $sinceTags = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var Deprecated[] |
|
41 | - */ |
|
42 | - public $deprecatedTags = []; |
|
39 | + /** |
|
40 | + * @var Deprecated[] |
|
41 | + */ |
|
42 | + public $deprecatedTags = []; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var RemovedTag[] |
|
46 | - */ |
|
47 | - public $removedTags = []; |
|
44 | + /** |
|
45 | + * @var RemovedTag[] |
|
46 | + */ |
|
47 | + public $removedTags = []; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @var Param[] |
|
51 | - */ |
|
52 | - public $paramTags = []; |
|
49 | + /** |
|
50 | + * @var Param[] |
|
51 | + */ |
|
52 | + public $paramTags = []; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @var Var_[] |
|
56 | - */ |
|
57 | - public $varTags = []; |
|
54 | + /** |
|
55 | + * @var Var_[] |
|
56 | + */ |
|
57 | + public $varTags = []; |
|
58 | 58 | |
59 | - /** |
|
60 | - * @var string[] |
|
61 | - */ |
|
62 | - public $tagNames = []; |
|
59 | + /** |
|
60 | + * @var string[] |
|
61 | + */ |
|
62 | + public $tagNames = []; |
|
63 | 63 | |
64 | - /** |
|
65 | - * @var bool |
|
66 | - */ |
|
67 | - public $hasInheritDocTag = false; |
|
64 | + /** |
|
65 | + * @var bool |
|
66 | + */ |
|
67 | + public $hasInheritDocTag = false; |
|
68 | 68 | |
69 | - /** |
|
70 | - * @var bool |
|
71 | - */ |
|
72 | - public $hasInternalMetaTag = false; |
|
69 | + /** |
|
70 | + * @var bool |
|
71 | + */ |
|
72 | + public $hasInternalMetaTag = false; |
|
73 | 73 | |
74 | - protected function collectTags(Node $node): void { |
|
75 | - if ($node->getDocComment() !== null) { |
|
76 | - try { |
|
77 | - $text = $node->getDocComment()->getText(); |
|
78 | - $this->phpdoc = $text; |
|
79 | - $phpDoc = DocFactoryProvider::getDocFactory()->create($text); |
|
80 | - $tags = $phpDoc->getTags(); |
|
81 | - foreach ($tags as $tag) { |
|
82 | - $this->tagNames[] = $tag->getName(); |
|
83 | - } |
|
84 | - $this->paramTags = $phpDoc->getTagsByName('param'); |
|
85 | - $this->varTags = $phpDoc->getTagsByName('var'); |
|
86 | - $this->links = $phpDoc->getTagsByName('link'); |
|
87 | - $this->see = $phpDoc->getTagsByName('see'); |
|
88 | - $this->sinceTags = $phpDoc->getTagsByName('since'); |
|
89 | - $this->deprecatedTags = $phpDoc->getTagsByName('deprecated'); |
|
90 | - $this->removedTags = $phpDoc->getTagsByName('removed'); |
|
91 | - $this->hasInternalMetaTag = $phpDoc->hasTag('meta'); |
|
92 | - $this->hasInheritDocTag = $phpDoc->hasTag('inheritdoc') || $phpDoc->hasTag('inheritDoc') || |
|
93 | - stripos($phpDoc->getSummary(), 'inheritdoc') > 0; |
|
94 | - } catch (Exception $e) { |
|
95 | - $this->parseError = $e; |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
74 | + protected function collectTags(Node $node): void { |
|
75 | + if ($node->getDocComment() !== null) { |
|
76 | + try { |
|
77 | + $text = $node->getDocComment()->getText(); |
|
78 | + $this->phpdoc = $text; |
|
79 | + $phpDoc = DocFactoryProvider::getDocFactory()->create($text); |
|
80 | + $tags = $phpDoc->getTags(); |
|
81 | + foreach ($tags as $tag) { |
|
82 | + $this->tagNames[] = $tag->getName(); |
|
83 | + } |
|
84 | + $this->paramTags = $phpDoc->getTagsByName('param'); |
|
85 | + $this->varTags = $phpDoc->getTagsByName('var'); |
|
86 | + $this->links = $phpDoc->getTagsByName('link'); |
|
87 | + $this->see = $phpDoc->getTagsByName('see'); |
|
88 | + $this->sinceTags = $phpDoc->getTagsByName('since'); |
|
89 | + $this->deprecatedTags = $phpDoc->getTagsByName('deprecated'); |
|
90 | + $this->removedTags = $phpDoc->getTagsByName('removed'); |
|
91 | + $this->hasInternalMetaTag = $phpDoc->hasTag('meta'); |
|
92 | + $this->hasInheritDocTag = $phpDoc->hasTag('inheritdoc') || $phpDoc->hasTag('inheritDoc') || |
|
93 | + stripos($phpDoc->getSummary(), 'inheritdoc') > 0; |
|
94 | + } catch (Exception $e) { |
|
95 | + $this->parseError = $e; |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | 99 | } |
@@ -14,8 +14,7 @@ |
||
14 | 14 | use StubTests\Model\Tags\RemovedTag; |
15 | 15 | use StubTests\Parsers\DocFactoryProvider; |
16 | 16 | |
17 | -trait PHPDocElement |
|
18 | -{ |
|
17 | +trait PHPDocElement { |
|
19 | 18 | /** |
20 | 19 | * @var Link[] |
21 | 20 | */ |
@@ -11,43 +11,43 @@ |
||
11 | 11 | |
12 | 12 | class PhpVersions implements ArrayAccess, IteratorAggregate |
13 | 13 | { |
14 | - private static $versions = [5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1]; |
|
15 | - |
|
16 | - public static function getLatest() |
|
17 | - { |
|
18 | - return end(self::$versions); |
|
19 | - } |
|
20 | - |
|
21 | - public static function getFirst(): float |
|
22 | - { |
|
23 | - return self::$versions[0]; |
|
24 | - } |
|
25 | - |
|
26 | - public function offsetExists($offset): bool |
|
27 | - { |
|
28 | - return isset(self::$versions[$offset]); |
|
29 | - } |
|
30 | - |
|
31 | - #[ReturnTypeWillChange] |
|
32 | - public function offsetGet($offset) |
|
33 | - { |
|
34 | - return $this->offsetExists($offset) ? self::$versions[$offset] : null; |
|
35 | - } |
|
36 | - |
|
37 | - #[ReturnTypeWillChange] |
|
38 | - public function offsetSet($offset, $value) |
|
39 | - { |
|
40 | - throw new RuntimeException('Unsupported operation'); |
|
41 | - } |
|
42 | - |
|
43 | - #[ReturnTypeWillChange] |
|
44 | - public function offsetUnset($offset) |
|
45 | - { |
|
46 | - throw new RuntimeException('Unsupported operation'); |
|
47 | - } |
|
48 | - |
|
49 | - public function getIterator(): ArrayIterator |
|
50 | - { |
|
51 | - return new ArrayIterator(self::$versions); |
|
52 | - } |
|
14 | + private static $versions = [5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1]; |
|
15 | + |
|
16 | + public static function getLatest() |
|
17 | + { |
|
18 | + return end(self::$versions); |
|
19 | + } |
|
20 | + |
|
21 | + public static function getFirst(): float |
|
22 | + { |
|
23 | + return self::$versions[0]; |
|
24 | + } |
|
25 | + |
|
26 | + public function offsetExists($offset): bool |
|
27 | + { |
|
28 | + return isset(self::$versions[$offset]); |
|
29 | + } |
|
30 | + |
|
31 | + #[ReturnTypeWillChange] |
|
32 | + public function offsetGet($offset) |
|
33 | + { |
|
34 | + return $this->offsetExists($offset) ? self::$versions[$offset] : null; |
|
35 | + } |
|
36 | + |
|
37 | + #[ReturnTypeWillChange] |
|
38 | + public function offsetSet($offset, $value) |
|
39 | + { |
|
40 | + throw new RuntimeException('Unsupported operation'); |
|
41 | + } |
|
42 | + |
|
43 | + #[ReturnTypeWillChange] |
|
44 | + public function offsetUnset($offset) |
|
45 | + { |
|
46 | + throw new RuntimeException('Unsupported operation'); |
|
47 | + } |
|
48 | + |
|
49 | + public function getIterator(): ArrayIterator |
|
50 | + { |
|
51 | + return new ArrayIterator(self::$versions); |
|
52 | + } |
|
53 | 53 | } |
@@ -13,172 +13,172 @@ |
||
13 | 13 | |
14 | 14 | class PHPMethod extends PHPFunction |
15 | 15 | { |
16 | - /** |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $access; |
|
20 | - /** |
|
21 | - * @var bool |
|
22 | - */ |
|
23 | - public $isStatic; |
|
24 | - /** |
|
25 | - * @var bool |
|
26 | - */ |
|
27 | - public $isFinal; |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $parentName; |
|
16 | + /** |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $access; |
|
20 | + /** |
|
21 | + * @var bool |
|
22 | + */ |
|
23 | + public $isStatic; |
|
24 | + /** |
|
25 | + * @var bool |
|
26 | + */ |
|
27 | + public $isFinal; |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $parentName; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var bool |
|
35 | - */ |
|
36 | - public $isReturnTypeTentative; |
|
33 | + /** |
|
34 | + * @var bool |
|
35 | + */ |
|
36 | + public $isReturnTypeTentative; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param ReflectionMethod $reflectionObject |
|
40 | - * @return static |
|
41 | - */ |
|
42 | - public function readObjectFromReflection($reflectionObject) |
|
43 | - { |
|
44 | - parent::readObjectFromReflection($reflectionObject); |
|
45 | - $this->isStatic = $reflectionObject->isStatic(); |
|
46 | - $this->isFinal = $reflectionObject->isFinal(); |
|
47 | - $this->parentName = $reflectionObject->class; |
|
48 | - if ($reflectionObject->isProtected()) { |
|
49 | - $access = 'protected'; |
|
50 | - } elseif ($reflectionObject->isPrivate()) { |
|
51 | - $access = 'private'; |
|
52 | - } else { |
|
53 | - $access = 'public'; |
|
54 | - } |
|
55 | - $this->access = $access; |
|
56 | - if (method_exists($reflectionObject, 'hasTentativeReturnType')) { |
|
57 | - $this->isReturnTypeTentative = $reflectionObject->hasTentativeReturnType(); |
|
58 | - if ($this->isReturnTypeTentative) { |
|
59 | - $returnTypes = self::getReflectionTypeAsArray($reflectionObject->getTentativeReturnType()); |
|
60 | - if (!empty($returnTypes)) { |
|
61 | - array_push($this->returnTypesFromSignature, ...$returnTypes); |
|
62 | - } |
|
63 | - } |
|
64 | - } else { |
|
65 | - $this->isReturnTypeTentative = false; |
|
66 | - } |
|
67 | - return $this; |
|
68 | - } |
|
38 | + /** |
|
39 | + * @param ReflectionMethod $reflectionObject |
|
40 | + * @return static |
|
41 | + */ |
|
42 | + public function readObjectFromReflection($reflectionObject) |
|
43 | + { |
|
44 | + parent::readObjectFromReflection($reflectionObject); |
|
45 | + $this->isStatic = $reflectionObject->isStatic(); |
|
46 | + $this->isFinal = $reflectionObject->isFinal(); |
|
47 | + $this->parentName = $reflectionObject->class; |
|
48 | + if ($reflectionObject->isProtected()) { |
|
49 | + $access = 'protected'; |
|
50 | + } elseif ($reflectionObject->isPrivate()) { |
|
51 | + $access = 'private'; |
|
52 | + } else { |
|
53 | + $access = 'public'; |
|
54 | + } |
|
55 | + $this->access = $access; |
|
56 | + if (method_exists($reflectionObject, 'hasTentativeReturnType')) { |
|
57 | + $this->isReturnTypeTentative = $reflectionObject->hasTentativeReturnType(); |
|
58 | + if ($this->isReturnTypeTentative) { |
|
59 | + $returnTypes = self::getReflectionTypeAsArray($reflectionObject->getTentativeReturnType()); |
|
60 | + if (!empty($returnTypes)) { |
|
61 | + array_push($this->returnTypesFromSignature, ...$returnTypes); |
|
62 | + } |
|
63 | + } |
|
64 | + } else { |
|
65 | + $this->isReturnTypeTentative = false; |
|
66 | + } |
|
67 | + return $this; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param ClassMethod $node |
|
72 | - * @return static |
|
73 | - * @throws RuntimeException |
|
74 | - */ |
|
75 | - public function readObjectFromStubNode($node) |
|
76 | - { |
|
77 | - $this->parentName = self::getFQN($node->getAttribute('parent')); |
|
78 | - $this->name = $node->name->name; |
|
79 | - $typesFromAttribute = self::findTypesFromAttribute($node->attrGroups); |
|
80 | - $this->isReturnTypeTentative = self::hasTentativeTypeAttribute($node->attrGroups); |
|
81 | - $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
82 | - $this->returnTypesFromAttribute = $typesFromAttribute; |
|
83 | - array_push($this->returnTypesFromSignature, ...self::convertParsedTypeToArray($node->getReturnType())); |
|
84 | - $this->collectTags($node); |
|
85 | - $this->checkDeprecationTag($node); |
|
86 | - $this->checkReturnTag($node); |
|
70 | + /** |
|
71 | + * @param ClassMethod $node |
|
72 | + * @return static |
|
73 | + * @throws RuntimeException |
|
74 | + */ |
|
75 | + public function readObjectFromStubNode($node) |
|
76 | + { |
|
77 | + $this->parentName = self::getFQN($node->getAttribute('parent')); |
|
78 | + $this->name = $node->name->name; |
|
79 | + $typesFromAttribute = self::findTypesFromAttribute($node->attrGroups); |
|
80 | + $this->isReturnTypeTentative = self::hasTentativeTypeAttribute($node->attrGroups); |
|
81 | + $this->availableVersionsRangeFromAttribute = self::findAvailableVersionsRangeFromAttribute($node->attrGroups); |
|
82 | + $this->returnTypesFromAttribute = $typesFromAttribute; |
|
83 | + array_push($this->returnTypesFromSignature, ...self::convertParsedTypeToArray($node->getReturnType())); |
|
84 | + $this->collectTags($node); |
|
85 | + $this->checkDeprecationTag($node); |
|
86 | + $this->checkReturnTag($node); |
|
87 | 87 | |
88 | - if (strncmp($this->name, 'PS_UNRESERVE_PREFIX_', 20) === 0) { |
|
89 | - $this->name = substr($this->name, strlen('PS_UNRESERVE_PREFIX_')); |
|
90 | - } |
|
91 | - $index = 0; |
|
92 | - foreach ($node->getParams() as $parameter) { |
|
93 | - $parsedParameter = (new PHPParameter())->readObjectFromStubNode($parameter); |
|
94 | - if (self::entitySuitsCurrentPhpVersion($parsedParameter)) { |
|
95 | - $parsedParameter->indexInSignature = $index; |
|
96 | - $this->parameters[] = $parsedParameter; |
|
97 | - $index++; |
|
98 | - } |
|
99 | - } |
|
88 | + if (strncmp($this->name, 'PS_UNRESERVE_PREFIX_', 20) === 0) { |
|
89 | + $this->name = substr($this->name, strlen('PS_UNRESERVE_PREFIX_')); |
|
90 | + } |
|
91 | + $index = 0; |
|
92 | + foreach ($node->getParams() as $parameter) { |
|
93 | + $parsedParameter = (new PHPParameter())->readObjectFromStubNode($parameter); |
|
94 | + if (self::entitySuitsCurrentPhpVersion($parsedParameter)) { |
|
95 | + $parsedParameter->indexInSignature = $index; |
|
96 | + $this->parameters[] = $parsedParameter; |
|
97 | + $index++; |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - foreach ($this->parameters as $parameter) { |
|
102 | - $relatedParamTags = array_filter($this->paramTags, function (Param $tag) use ($parameter) { |
|
103 | - return $tag->getVariableName() === $parameter->name; |
|
104 | - }); |
|
105 | - /** @var Param $relatedParamTag */ |
|
106 | - $relatedParamTag = array_pop($relatedParamTags); |
|
107 | - if ($relatedParamTag !== null) { |
|
108 | - $parameter->isOptional = $parameter->isOptional || str_contains((string)$relatedParamTag->getDescription(), '[optional]'); |
|
109 | - } |
|
110 | - } |
|
101 | + foreach ($this->parameters as $parameter) { |
|
102 | + $relatedParamTags = array_filter($this->paramTags, function (Param $tag) use ($parameter) { |
|
103 | + return $tag->getVariableName() === $parameter->name; |
|
104 | + }); |
|
105 | + /** @var Param $relatedParamTag */ |
|
106 | + $relatedParamTag = array_pop($relatedParamTags); |
|
107 | + if ($relatedParamTag !== null) { |
|
108 | + $parameter->isOptional = $parameter->isOptional || str_contains((string)$relatedParamTag->getDescription(), '[optional]'); |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | - $this->isFinal = $node->isFinal(); |
|
113 | - $this->isStatic = $node->isStatic(); |
|
114 | - if ($node->isPrivate()) { |
|
115 | - $this->access = 'private'; |
|
116 | - } elseif ($node->isProtected()) { |
|
117 | - $this->access = 'protected'; |
|
118 | - } else { |
|
119 | - $this->access = 'public'; |
|
120 | - } |
|
121 | - return $this; |
|
122 | - } |
|
112 | + $this->isFinal = $node->isFinal(); |
|
113 | + $this->isStatic = $node->isStatic(); |
|
114 | + if ($node->isPrivate()) { |
|
115 | + $this->access = 'private'; |
|
116 | + } elseif ($node->isProtected()) { |
|
117 | + $this->access = 'protected'; |
|
118 | + } else { |
|
119 | + $this->access = 'public'; |
|
120 | + } |
|
121 | + return $this; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @param stdClass|array $jsonData |
|
126 | - * @throws Exception |
|
127 | - */ |
|
128 | - public function readMutedProblems($jsonData): void |
|
129 | - { |
|
130 | - foreach ($jsonData as $method) { |
|
131 | - if ($method->name === $this->name) { |
|
132 | - if (!empty($method->problems)) { |
|
133 | - foreach ($method->problems as $problem) { |
|
134 | - switch ($problem->description) { |
|
135 | - case 'parameter mismatch': |
|
136 | - $this->mutedProblems[StubProblemType::FUNCTION_PARAMETER_MISMATCH] = $problem->versions; |
|
137 | - break; |
|
138 | - case 'missing method': |
|
139 | - $this->mutedProblems[StubProblemType::STUB_IS_MISSED] = $problem->versions; |
|
140 | - break; |
|
141 | - case 'deprecated method': |
|
142 | - $this->mutedProblems[StubProblemType::FUNCTION_IS_DEPRECATED] = $problem->versions; |
|
143 | - break; |
|
144 | - case 'absent in meta': |
|
145 | - $this->mutedProblems[StubProblemType::ABSENT_IN_META] = $problem->versions; |
|
146 | - break; |
|
147 | - case 'wrong access': |
|
148 | - $this->mutedProblems[StubProblemType::FUNCTION_ACCESS] = $problem->versions; |
|
149 | - break; |
|
150 | - case 'has duplicate in stubs': |
|
151 | - $this->mutedProblems[StubProblemType::HAS_DUPLICATION] = $problem->versions; |
|
152 | - break; |
|
153 | - case 'has nullable typehint': |
|
154 | - $this->mutedProblems[StubProblemType::HAS_NULLABLE_TYPEHINT] = $problem->versions; |
|
155 | - break; |
|
156 | - case 'has union typehint': |
|
157 | - $this->mutedProblems[StubProblemType::HAS_UNION_TYPEHINT] = $problem->versions; |
|
158 | - break; |
|
159 | - case 'wrong return typehint': |
|
160 | - $this->mutedProblems[StubProblemType::WRONG_RETURN_TYPEHINT] = $problem->versions; |
|
161 | - break; |
|
162 | - case 'has type mismatch in signature and phpdoc': |
|
163 | - $this->mutedProblems[StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE] = $problem->versions; |
|
164 | - break; |
|
165 | - case 'has wrong final modifier': |
|
166 | - $this->mutedProblems[StubProblemType::WRONG_FINAL_MODIFIER] = $problem->versions; |
|
167 | - break; |
|
168 | - case 'has wrong static modifier': |
|
169 | - $this->mutedProblems[StubProblemType::WRONG_STATIC_MODIFIER] = $problem->versions; |
|
170 | - break; |
|
171 | - default: |
|
172 | - throw new Exception("Unexpected value $problem->description"); |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - if (!empty($method->parameters)) { |
|
177 | - foreach ($this->parameters as $parameter) { |
|
178 | - $parameter->readMutedProblems($method->parameters); |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - } |
|
183 | - } |
|
124 | + /** |
|
125 | + * @param stdClass|array $jsonData |
|
126 | + * @throws Exception |
|
127 | + */ |
|
128 | + public function readMutedProblems($jsonData): void |
|
129 | + { |
|
130 | + foreach ($jsonData as $method) { |
|
131 | + if ($method->name === $this->name) { |
|
132 | + if (!empty($method->problems)) { |
|
133 | + foreach ($method->problems as $problem) { |
|
134 | + switch ($problem->description) { |
|
135 | + case 'parameter mismatch': |
|
136 | + $this->mutedProblems[StubProblemType::FUNCTION_PARAMETER_MISMATCH] = $problem->versions; |
|
137 | + break; |
|
138 | + case 'missing method': |
|
139 | + $this->mutedProblems[StubProblemType::STUB_IS_MISSED] = $problem->versions; |
|
140 | + break; |
|
141 | + case 'deprecated method': |
|
142 | + $this->mutedProblems[StubProblemType::FUNCTION_IS_DEPRECATED] = $problem->versions; |
|
143 | + break; |
|
144 | + case 'absent in meta': |
|
145 | + $this->mutedProblems[StubProblemType::ABSENT_IN_META] = $problem->versions; |
|
146 | + break; |
|
147 | + case 'wrong access': |
|
148 | + $this->mutedProblems[StubProblemType::FUNCTION_ACCESS] = $problem->versions; |
|
149 | + break; |
|
150 | + case 'has duplicate in stubs': |
|
151 | + $this->mutedProblems[StubProblemType::HAS_DUPLICATION] = $problem->versions; |
|
152 | + break; |
|
153 | + case 'has nullable typehint': |
|
154 | + $this->mutedProblems[StubProblemType::HAS_NULLABLE_TYPEHINT] = $problem->versions; |
|
155 | + break; |
|
156 | + case 'has union typehint': |
|
157 | + $this->mutedProblems[StubProblemType::HAS_UNION_TYPEHINT] = $problem->versions; |
|
158 | + break; |
|
159 | + case 'wrong return typehint': |
|
160 | + $this->mutedProblems[StubProblemType::WRONG_RETURN_TYPEHINT] = $problem->versions; |
|
161 | + break; |
|
162 | + case 'has type mismatch in signature and phpdoc': |
|
163 | + $this->mutedProblems[StubProblemType::TYPE_IN_PHPDOC_DIFFERS_FROM_SIGNATURE] = $problem->versions; |
|
164 | + break; |
|
165 | + case 'has wrong final modifier': |
|
166 | + $this->mutedProblems[StubProblemType::WRONG_FINAL_MODIFIER] = $problem->versions; |
|
167 | + break; |
|
168 | + case 'has wrong static modifier': |
|
169 | + $this->mutedProblems[StubProblemType::WRONG_STATIC_MODIFIER] = $problem->versions; |
|
170 | + break; |
|
171 | + default: |
|
172 | + throw new Exception("Unexpected value $problem->description"); |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + if (!empty($method->parameters)) { |
|
177 | + foreach ($this->parameters as $parameter) { |
|
178 | + $parameter->readMutedProblems($method->parameters); |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + } |
|
183 | + } |
|
184 | 184 | } |
@@ -99,7 +99,7 @@ |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | foreach ($this->parameters as $parameter) { |
102 | - $relatedParamTags = array_filter($this->paramTags, function (Param $tag) use ($parameter) { |
|
102 | + $relatedParamTags = array_filter($this->paramTags, function(Param $tag) use ($parameter) { |
|
103 | 103 | return $tag->getVariableName() === $parameter->name; |
104 | 104 | }); |
105 | 105 | /** @var Param $relatedParamTag */ |
@@ -11,8 +11,7 @@ |
||
11 | 11 | use stdClass; |
12 | 12 | use function strlen; |
13 | 13 | |
14 | -class PHPMethod extends PHPFunction |
|
15 | -{ |
|
14 | +class PHPMethod extends PHPFunction { |
|
16 | 15 | /** |
17 | 16 | * @var string |
18 | 17 | */ |
@@ -9,266 +9,266 @@ |
||
9 | 9 | |
10 | 10 | class StubsContainer |
11 | 11 | { |
12 | - /** |
|
13 | - * @var PHPConst[] |
|
14 | - */ |
|
15 | - private $constants = []; |
|
16 | - /** |
|
17 | - * @var PHPFunction[] |
|
18 | - */ |
|
19 | - private $functions = []; |
|
20 | - /** |
|
21 | - * @var PHPClass[] |
|
22 | - */ |
|
23 | - private $classes = []; |
|
24 | - /** |
|
25 | - * @var PHPInterface[] |
|
26 | - */ |
|
27 | - private $interfaces = []; |
|
12 | + /** |
|
13 | + * @var PHPConst[] |
|
14 | + */ |
|
15 | + private $constants = []; |
|
16 | + /** |
|
17 | + * @var PHPFunction[] |
|
18 | + */ |
|
19 | + private $functions = []; |
|
20 | + /** |
|
21 | + * @var PHPClass[] |
|
22 | + */ |
|
23 | + private $classes = []; |
|
24 | + /** |
|
25 | + * @var PHPInterface[] |
|
26 | + */ |
|
27 | + private $interfaces = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @return PHPConst[] |
|
31 | - */ |
|
32 | - public function getConstants(): array |
|
33 | - { |
|
34 | - return $this->constants; |
|
35 | - } |
|
29 | + /** |
|
30 | + * @return PHPConst[] |
|
31 | + */ |
|
32 | + public function getConstants(): array |
|
33 | + { |
|
34 | + return $this->constants; |
|
35 | + } |
|
36 | 36 | |
37 | - public function getConstant(string $constantName, ?string $sourceFilePath = null): ?PHPConst |
|
38 | - { |
|
39 | - $constants = array_filter($this->constants, function (PHPConst $const) use ($constantName): bool { |
|
40 | - return $const->name === $constantName && $const->duplicateOtherElement === false |
|
41 | - && BasePHPElement::entitySuitsCurrentPhpVersion($const); |
|
42 | - }); |
|
43 | - if (count($constants) === 1) { |
|
44 | - return array_pop($constants); |
|
45 | - } |
|
37 | + public function getConstant(string $constantName, ?string $sourceFilePath = null): ?PHPConst |
|
38 | + { |
|
39 | + $constants = array_filter($this->constants, function (PHPConst $const) use ($constantName): bool { |
|
40 | + return $const->name === $constantName && $const->duplicateOtherElement === false |
|
41 | + && BasePHPElement::entitySuitsCurrentPhpVersion($const); |
|
42 | + }); |
|
43 | + if (count($constants) === 1) { |
|
44 | + return array_pop($constants); |
|
45 | + } |
|
46 | 46 | |
47 | - if ($sourceFilePath !== null) { |
|
48 | - $constants = array_filter($constants, function (PHPConst $constant) use ($sourceFilePath) { |
|
49 | - return $constant->sourceFilePath === $sourceFilePath |
|
50 | - && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
|
51 | - }); |
|
52 | - } |
|
53 | - if (count($constants) > 1) { |
|
54 | - throw new RuntimeException("Multiple constants with name $constantName found"); |
|
55 | - } |
|
56 | - if (!empty($constants)) { |
|
57 | - return array_pop($constants); |
|
58 | - } |
|
59 | - return null; |
|
60 | - } |
|
47 | + if ($sourceFilePath !== null) { |
|
48 | + $constants = array_filter($constants, function (PHPConst $constant) use ($sourceFilePath) { |
|
49 | + return $constant->sourceFilePath === $sourceFilePath |
|
50 | + && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
|
51 | + }); |
|
52 | + } |
|
53 | + if (count($constants) > 1) { |
|
54 | + throw new RuntimeException("Multiple constants with name $constantName found"); |
|
55 | + } |
|
56 | + if (!empty($constants)) { |
|
57 | + return array_pop($constants); |
|
58 | + } |
|
59 | + return null; |
|
60 | + } |
|
61 | 61 | |
62 | - public function addConstant(PHPConst $constant): void |
|
63 | - { |
|
64 | - if (isset($constant->name)) { |
|
65 | - if (array_key_exists($constant->name, $this->constants)) { |
|
66 | - $amount = count(array_filter( |
|
67 | - $this->constants, |
|
68 | - function (PHPConst $nextConstant) use ($constant) { |
|
69 | - return $nextConstant->name === $constant->name; |
|
70 | - } |
|
71 | - )); |
|
72 | - $this->constants[$constant->name . '_duplicated_' . $amount] = $constant; |
|
73 | - } else { |
|
74 | - $this->constants[$constant->name] = $constant; |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
62 | + public function addConstant(PHPConst $constant): void |
|
63 | + { |
|
64 | + if (isset($constant->name)) { |
|
65 | + if (array_key_exists($constant->name, $this->constants)) { |
|
66 | + $amount = count(array_filter( |
|
67 | + $this->constants, |
|
68 | + function (PHPConst $nextConstant) use ($constant) { |
|
69 | + return $nextConstant->name === $constant->name; |
|
70 | + } |
|
71 | + )); |
|
72 | + $this->constants[$constant->name . '_duplicated_' . $amount] = $constant; |
|
73 | + } else { |
|
74 | + $this->constants[$constant->name] = $constant; |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return PHPFunction[] |
|
81 | - */ |
|
82 | - public function getFunctions(): array |
|
83 | - { |
|
84 | - return $this->functions; |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return PHPFunction[] |
|
81 | + */ |
|
82 | + public function getFunctions(): array |
|
83 | + { |
|
84 | + return $this->functions; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $name |
|
89 | - * @param string|null $sourceFilePath |
|
90 | - * @param bool $shouldSuitCurrentPhpVersion |
|
91 | - * @return PHPFunction|null |
|
92 | - * @throws RuntimeException |
|
93 | - */ |
|
94 | - public function getFunction(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPFunction |
|
95 | - { |
|
96 | - $functions = array_filter($this->functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
97 | - return $function->name === $name && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
|
98 | - }); |
|
99 | - if (count($functions) > 1) { |
|
100 | - $functions = array_filter($functions, function (PHPFunction $function): bool { |
|
101 | - return $function->duplicateOtherElement === false; |
|
102 | - }); |
|
103 | - } |
|
104 | - if (count($functions) === 1) { |
|
105 | - return array_pop($functions); |
|
106 | - } |
|
87 | + /** |
|
88 | + * @param string $name |
|
89 | + * @param string|null $sourceFilePath |
|
90 | + * @param bool $shouldSuitCurrentPhpVersion |
|
91 | + * @return PHPFunction|null |
|
92 | + * @throws RuntimeException |
|
93 | + */ |
|
94 | + public function getFunction(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPFunction |
|
95 | + { |
|
96 | + $functions = array_filter($this->functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
97 | + return $function->name === $name && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
|
98 | + }); |
|
99 | + if (count($functions) > 1) { |
|
100 | + $functions = array_filter($functions, function (PHPFunction $function): bool { |
|
101 | + return $function->duplicateOtherElement === false; |
|
102 | + }); |
|
103 | + } |
|
104 | + if (count($functions) === 1) { |
|
105 | + return array_pop($functions); |
|
106 | + } |
|
107 | 107 | |
108 | - if ($sourceFilePath !== null) { |
|
109 | - $functions = array_filter($functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
110 | - return $function->sourceFilePath === $sourceFilePath |
|
111 | - && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
|
112 | - }); |
|
113 | - } |
|
114 | - if (count($functions) > 1) { |
|
115 | - throw new RuntimeException("Multiple functions with name $name found"); |
|
116 | - } |
|
117 | - if (!empty($functions)) { |
|
118 | - return array_pop($functions); |
|
119 | - } |
|
120 | - return null; |
|
121 | - } |
|
108 | + if ($sourceFilePath !== null) { |
|
109 | + $functions = array_filter($functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
110 | + return $function->sourceFilePath === $sourceFilePath |
|
111 | + && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
|
112 | + }); |
|
113 | + } |
|
114 | + if (count($functions) > 1) { |
|
115 | + throw new RuntimeException("Multiple functions with name $name found"); |
|
116 | + } |
|
117 | + if (!empty($functions)) { |
|
118 | + return array_pop($functions); |
|
119 | + } |
|
120 | + return null; |
|
121 | + } |
|
122 | 122 | |
123 | - public function addFunction(PHPFunction $function): void |
|
124 | - { |
|
125 | - if (isset($function->name)) { |
|
126 | - if (array_key_exists($function->name, $this->functions)) { |
|
127 | - $amount = count(array_filter( |
|
128 | - $this->functions, |
|
129 | - function (PHPFunction $nextFunction) use ($function) { |
|
130 | - return $nextFunction->name === $function->name; |
|
131 | - } |
|
132 | - )); |
|
133 | - $function->duplicateOtherElement = true; |
|
134 | - $this->functions[$function->name . '_duplicated_' . $amount] = $function; |
|
135 | - } else { |
|
136 | - $this->functions[$function->name] = $function; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
123 | + public function addFunction(PHPFunction $function): void |
|
124 | + { |
|
125 | + if (isset($function->name)) { |
|
126 | + if (array_key_exists($function->name, $this->functions)) { |
|
127 | + $amount = count(array_filter( |
|
128 | + $this->functions, |
|
129 | + function (PHPFunction $nextFunction) use ($function) { |
|
130 | + return $nextFunction->name === $function->name; |
|
131 | + } |
|
132 | + )); |
|
133 | + $function->duplicateOtherElement = true; |
|
134 | + $this->functions[$function->name . '_duplicated_' . $amount] = $function; |
|
135 | + } else { |
|
136 | + $this->functions[$function->name] = $function; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @return PHPClass[] |
|
143 | - */ |
|
144 | - public function getClasses(): array |
|
145 | - { |
|
146 | - return $this->classes; |
|
147 | - } |
|
141 | + /** |
|
142 | + * @return PHPClass[] |
|
143 | + */ |
|
144 | + public function getClasses(): array |
|
145 | + { |
|
146 | + return $this->classes; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param string $name |
|
151 | - * @param string|null $sourceFilePath |
|
152 | - * @param bool $shouldSuitCurrentPhpVersion |
|
153 | - * @return PHPClass|null |
|
154 | - * @throws RuntimeException |
|
155 | - */ |
|
156 | - public function getClass(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPClass |
|
157 | - { |
|
158 | - $classes = array_filter($this->classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
159 | - return $class->name === $name && |
|
160 | - (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
|
161 | - }); |
|
162 | - if (count($classes) === 1) { |
|
163 | - return array_pop($classes); |
|
164 | - } |
|
149 | + /** |
|
150 | + * @param string $name |
|
151 | + * @param string|null $sourceFilePath |
|
152 | + * @param bool $shouldSuitCurrentPhpVersion |
|
153 | + * @return PHPClass|null |
|
154 | + * @throws RuntimeException |
|
155 | + */ |
|
156 | + public function getClass(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPClass |
|
157 | + { |
|
158 | + $classes = array_filter($this->classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
159 | + return $class->name === $name && |
|
160 | + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
|
161 | + }); |
|
162 | + if (count($classes) === 1) { |
|
163 | + return array_pop($classes); |
|
164 | + } |
|
165 | 165 | |
166 | - if ($sourceFilePath !== null) { |
|
167 | - $classes = array_filter($classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
168 | - return $class->sourceFilePath === $sourceFilePath && |
|
169 | - (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
|
170 | - }); |
|
171 | - } |
|
172 | - if (count($classes) > 1) { |
|
173 | - throw new RuntimeException("Multiple classes with name $name found"); |
|
174 | - } |
|
175 | - if (!empty($classes)) { |
|
176 | - return array_pop($classes); |
|
177 | - } |
|
178 | - return null; |
|
179 | - } |
|
166 | + if ($sourceFilePath !== null) { |
|
167 | + $classes = array_filter($classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
168 | + return $class->sourceFilePath === $sourceFilePath && |
|
169 | + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
|
170 | + }); |
|
171 | + } |
|
172 | + if (count($classes) > 1) { |
|
173 | + throw new RuntimeException("Multiple classes with name $name found"); |
|
174 | + } |
|
175 | + if (!empty($classes)) { |
|
176 | + return array_pop($classes); |
|
177 | + } |
|
178 | + return null; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * @return PHPClass[] |
|
183 | - */ |
|
184 | - public function getCoreClasses(): array |
|
185 | - { |
|
186 | - return array_filter($this->classes, function (PHPClass $class): bool { |
|
187 | - return $class->stubBelongsToCore === true; |
|
188 | - }); |
|
189 | - } |
|
181 | + /** |
|
182 | + * @return PHPClass[] |
|
183 | + */ |
|
184 | + public function getCoreClasses(): array |
|
185 | + { |
|
186 | + return array_filter($this->classes, function (PHPClass $class): bool { |
|
187 | + return $class->stubBelongsToCore === true; |
|
188 | + }); |
|
189 | + } |
|
190 | 190 | |
191 | - public function addClass(PHPClass $class): void |
|
192 | - { |
|
193 | - if (isset($class->name)) { |
|
194 | - if (array_key_exists($class->name, $this->classes)) { |
|
195 | - $amount = count(array_filter( |
|
196 | - $this->classes, |
|
197 | - function (PHPClass $nextClass) use ($class) { |
|
198 | - return $nextClass->name === $class->name; |
|
199 | - } |
|
200 | - )); |
|
201 | - $this->classes[$class->name . '_duplicated_' . $amount] = $class; |
|
202 | - } else { |
|
203 | - $this->classes[$class->name] = $class; |
|
204 | - } |
|
205 | - } |
|
206 | - } |
|
191 | + public function addClass(PHPClass $class): void |
|
192 | + { |
|
193 | + if (isset($class->name)) { |
|
194 | + if (array_key_exists($class->name, $this->classes)) { |
|
195 | + $amount = count(array_filter( |
|
196 | + $this->classes, |
|
197 | + function (PHPClass $nextClass) use ($class) { |
|
198 | + return $nextClass->name === $class->name; |
|
199 | + } |
|
200 | + )); |
|
201 | + $this->classes[$class->name . '_duplicated_' . $amount] = $class; |
|
202 | + } else { |
|
203 | + $this->classes[$class->name] = $class; |
|
204 | + } |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * @param string $name |
|
210 | - * @param string|null $sourceFilePath |
|
211 | - * @param bool $shouldSuitCurrentPhpVersion |
|
212 | - * @return PHPInterface|null |
|
213 | - * @throws RuntimeException |
|
214 | - */ |
|
215 | - public function getInterface(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPInterface |
|
216 | - { |
|
217 | - $interfaces = array_filter($this->interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
218 | - return $interface->name === $name && |
|
219 | - (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
|
220 | - }); |
|
221 | - if (count($interfaces) === 1) { |
|
222 | - return array_pop($interfaces); |
|
223 | - } |
|
208 | + /** |
|
209 | + * @param string $name |
|
210 | + * @param string|null $sourceFilePath |
|
211 | + * @param bool $shouldSuitCurrentPhpVersion |
|
212 | + * @return PHPInterface|null |
|
213 | + * @throws RuntimeException |
|
214 | + */ |
|
215 | + public function getInterface(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPInterface |
|
216 | + { |
|
217 | + $interfaces = array_filter($this->interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
218 | + return $interface->name === $name && |
|
219 | + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
|
220 | + }); |
|
221 | + if (count($interfaces) === 1) { |
|
222 | + return array_pop($interfaces); |
|
223 | + } |
|
224 | 224 | |
225 | - if ($sourceFilePath !== null) { |
|
226 | - $interfaces = array_filter($interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
227 | - return $interface->sourceFilePath === $sourceFilePath && |
|
228 | - (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
|
229 | - }); |
|
230 | - } |
|
231 | - if (count($interfaces) > 1) { |
|
232 | - throw new RuntimeException("Multiple interfaces with name $name found"); |
|
233 | - } |
|
234 | - if (!empty($interfaces)) { |
|
235 | - return array_pop($interfaces); |
|
236 | - } |
|
237 | - return null; |
|
238 | - } |
|
225 | + if ($sourceFilePath !== null) { |
|
226 | + $interfaces = array_filter($interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
227 | + return $interface->sourceFilePath === $sourceFilePath && |
|
228 | + (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
|
229 | + }); |
|
230 | + } |
|
231 | + if (count($interfaces) > 1) { |
|
232 | + throw new RuntimeException("Multiple interfaces with name $name found"); |
|
233 | + } |
|
234 | + if (!empty($interfaces)) { |
|
235 | + return array_pop($interfaces); |
|
236 | + } |
|
237 | + return null; |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * @return PHPInterface[] |
|
242 | - */ |
|
243 | - public function getInterfaces(): array |
|
244 | - { |
|
245 | - return $this->interfaces; |
|
246 | - } |
|
240 | + /** |
|
241 | + * @return PHPInterface[] |
|
242 | + */ |
|
243 | + public function getInterfaces(): array |
|
244 | + { |
|
245 | + return $this->interfaces; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @return PHPInterface[] |
|
250 | - */ |
|
251 | - public function getCoreInterfaces(): array |
|
252 | - { |
|
253 | - return array_filter($this->interfaces, function (PHPInterface $interface): bool { |
|
254 | - return $interface->stubBelongsToCore === true; |
|
255 | - }); |
|
256 | - } |
|
248 | + /** |
|
249 | + * @return PHPInterface[] |
|
250 | + */ |
|
251 | + public function getCoreInterfaces(): array |
|
252 | + { |
|
253 | + return array_filter($this->interfaces, function (PHPInterface $interface): bool { |
|
254 | + return $interface->stubBelongsToCore === true; |
|
255 | + }); |
|
256 | + } |
|
257 | 257 | |
258 | - public function addInterface(PHPInterface $interface): void |
|
259 | - { |
|
260 | - if (isset($interface->name)) { |
|
261 | - if (array_key_exists($interface->name, $this->interfaces)) { |
|
262 | - $amount = count(array_filter( |
|
263 | - $this->interfaces, |
|
264 | - function (PHPInterface $nextInterface) use ($interface) { |
|
265 | - return $nextInterface->name === $interface->name; |
|
266 | - } |
|
267 | - )); |
|
268 | - $this->interfaces[$interface->name . '_duplicated_' . $amount] = $interface; |
|
269 | - } else { |
|
270 | - $this->interfaces[$interface->name] = $interface; |
|
271 | - } |
|
272 | - } |
|
273 | - } |
|
258 | + public function addInterface(PHPInterface $interface): void |
|
259 | + { |
|
260 | + if (isset($interface->name)) { |
|
261 | + if (array_key_exists($interface->name, $this->interfaces)) { |
|
262 | + $amount = count(array_filter( |
|
263 | + $this->interfaces, |
|
264 | + function (PHPInterface $nextInterface) use ($interface) { |
|
265 | + return $nextInterface->name === $interface->name; |
|
266 | + } |
|
267 | + )); |
|
268 | + $this->interfaces[$interface->name . '_duplicated_' . $amount] = $interface; |
|
269 | + } else { |
|
270 | + $this->interfaces[$interface->name] = $interface; |
|
271 | + } |
|
272 | + } |
|
273 | + } |
|
274 | 274 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function getConstant(string $constantName, ?string $sourceFilePath = null): ?PHPConst |
38 | 38 | { |
39 | - $constants = array_filter($this->constants, function (PHPConst $const) use ($constantName): bool { |
|
39 | + $constants = array_filter($this->constants, function(PHPConst $const) use ($constantName) : bool { |
|
40 | 40 | return $const->name === $constantName && $const->duplicateOtherElement === false |
41 | 41 | && BasePHPElement::entitySuitsCurrentPhpVersion($const); |
42 | 42 | }); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | if ($sourceFilePath !== null) { |
48 | - $constants = array_filter($constants, function (PHPConst $constant) use ($sourceFilePath) { |
|
48 | + $constants = array_filter($constants, function(PHPConst $constant) use ($sourceFilePath) { |
|
49 | 49 | return $constant->sourceFilePath === $sourceFilePath |
50 | 50 | && BasePHPElement::entitySuitsCurrentPhpVersion($constant); |
51 | 51 | }); |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | if (array_key_exists($constant->name, $this->constants)) { |
66 | 66 | $amount = count(array_filter( |
67 | 67 | $this->constants, |
68 | - function (PHPConst $nextConstant) use ($constant) { |
|
68 | + function(PHPConst $nextConstant) use ($constant) { |
|
69 | 69 | return $nextConstant->name === $constant->name; |
70 | 70 | } |
71 | 71 | )); |
72 | - $this->constants[$constant->name . '_duplicated_' . $amount] = $constant; |
|
72 | + $this->constants[$constant->name.'_duplicated_'.$amount] = $constant; |
|
73 | 73 | } else { |
74 | 74 | $this->constants[$constant->name] = $constant; |
75 | 75 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getFunction(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPFunction |
95 | 95 | { |
96 | - $functions = array_filter($this->functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
96 | + $functions = array_filter($this->functions, function(PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $name) : bool { |
|
97 | 97 | return $function->name === $name && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
98 | 98 | }); |
99 | 99 | if (count($functions) > 1) { |
100 | - $functions = array_filter($functions, function (PHPFunction $function): bool { |
|
100 | + $functions = array_filter($functions, function(PHPFunction $function): bool { |
|
101 | 101 | return $function->duplicateOtherElement === false; |
102 | 102 | }); |
103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($sourceFilePath !== null) { |
109 | - $functions = array_filter($functions, function (PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
109 | + $functions = array_filter($functions, function(PHPFunction $function) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
110 | 110 | return $function->sourceFilePath === $sourceFilePath |
111 | 111 | && (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($function)); |
112 | 112 | }); |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | if (array_key_exists($function->name, $this->functions)) { |
127 | 127 | $amount = count(array_filter( |
128 | 128 | $this->functions, |
129 | - function (PHPFunction $nextFunction) use ($function) { |
|
129 | + function(PHPFunction $nextFunction) use ($function) { |
|
130 | 130 | return $nextFunction->name === $function->name; |
131 | 131 | } |
132 | 132 | )); |
133 | 133 | $function->duplicateOtherElement = true; |
134 | - $this->functions[$function->name . '_duplicated_' . $amount] = $function; |
|
134 | + $this->functions[$function->name.'_duplicated_'.$amount] = $function; |
|
135 | 135 | } else { |
136 | 136 | $this->functions[$function->name] = $function; |
137 | 137 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getClass(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPClass |
157 | 157 | { |
158 | - $classes = array_filter($this->classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
158 | + $classes = array_filter($this->classes, function(PHPClass $class) use ($shouldSuitCurrentPhpVersion, $name) : bool { |
|
159 | 159 | return $class->name === $name && |
160 | 160 | (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
161 | 161 | }); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | if ($sourceFilePath !== null) { |
167 | - $classes = array_filter($classes, function (PHPClass $class) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
167 | + $classes = array_filter($classes, function(PHPClass $class) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
168 | 168 | return $class->sourceFilePath === $sourceFilePath && |
169 | 169 | (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($class)); |
170 | 170 | }); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function getCoreClasses(): array |
185 | 185 | { |
186 | - return array_filter($this->classes, function (PHPClass $class): bool { |
|
186 | + return array_filter($this->classes, function(PHPClass $class): bool { |
|
187 | 187 | return $class->stubBelongsToCore === true; |
188 | 188 | }); |
189 | 189 | } |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | if (array_key_exists($class->name, $this->classes)) { |
195 | 195 | $amount = count(array_filter( |
196 | 196 | $this->classes, |
197 | - function (PHPClass $nextClass) use ($class) { |
|
197 | + function(PHPClass $nextClass) use ($class) { |
|
198 | 198 | return $nextClass->name === $class->name; |
199 | 199 | } |
200 | 200 | )); |
201 | - $this->classes[$class->name . '_duplicated_' . $amount] = $class; |
|
201 | + $this->classes[$class->name.'_duplicated_'.$amount] = $class; |
|
202 | 202 | } else { |
203 | 203 | $this->classes[$class->name] = $class; |
204 | 204 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getInterface(string $name, ?string $sourceFilePath = null, bool $shouldSuitCurrentPhpVersion = true): ?PHPInterface |
216 | 216 | { |
217 | - $interfaces = array_filter($this->interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $name): bool { |
|
217 | + $interfaces = array_filter($this->interfaces, function(PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $name) : bool { |
|
218 | 218 | return $interface->name === $name && |
219 | 219 | (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
220 | 220 | }); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | if ($sourceFilePath !== null) { |
226 | - $interfaces = array_filter($interfaces, function (PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
226 | + $interfaces = array_filter($interfaces, function(PHPInterface $interface) use ($shouldSuitCurrentPhpVersion, $sourceFilePath) { |
|
227 | 227 | return $interface->sourceFilePath === $sourceFilePath && |
228 | 228 | (!$shouldSuitCurrentPhpVersion || BasePHPElement::entitySuitsCurrentPhpVersion($interface)); |
229 | 229 | }); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function getCoreInterfaces(): array |
252 | 252 | { |
253 | - return array_filter($this->interfaces, function (PHPInterface $interface): bool { |
|
253 | + return array_filter($this->interfaces, function(PHPInterface $interface): bool { |
|
254 | 254 | return $interface->stubBelongsToCore === true; |
255 | 255 | }); |
256 | 256 | } |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | if (array_key_exists($interface->name, $this->interfaces)) { |
262 | 262 | $amount = count(array_filter( |
263 | 263 | $this->interfaces, |
264 | - function (PHPInterface $nextInterface) use ($interface) { |
|
264 | + function(PHPInterface $nextInterface) use ($interface) { |
|
265 | 265 | return $nextInterface->name === $interface->name; |
266 | 266 | } |
267 | 267 | )); |
268 | - $this->interfaces[$interface->name . '_duplicated_' . $amount] = $interface; |
|
268 | + $this->interfaces[$interface->name.'_duplicated_'.$amount] = $interface; |
|
269 | 269 | } else { |
270 | 270 | $this->interfaces[$interface->name] = $interface; |
271 | 271 | } |
@@ -7,8 +7,7 @@ |
||
7 | 7 | use function array_key_exists; |
8 | 8 | use function count; |
9 | 9 | |
10 | -class StubsContainer |
|
11 | -{ |
|
10 | +class StubsContainer { |
|
12 | 11 | /** |
13 | 12 | * @var PHPConst[] |
14 | 13 | */ |