|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +// phpcs:disable WordPress.WP.AlternativeFunctions.parse_url_parse_url |
| 4 | + |
3 | 5 | /**
|
4 | 6 | * Set return type of wp_parse_url().
|
5 | 7 | *
|
|
19 | 21 | use PHPStan\Type\Constant\ConstantIntegerType;
|
20 | 22 | use PHPStan\Type\Constant\ConstantStringType;
|
21 | 23 | use PHPStan\Type\ConstantType;
|
22 |
| -use PHPStan\Type\DynamicFunctionReturnTypeExtension; |
23 | 24 | use PHPStan\Type\IntegerType;
|
24 | 25 | use PHPStan\Type\NullType;
|
25 | 26 | use PHPStan\Type\StringType;
|
|
38 | 39 | use const PHP_URL_SCHEME;
|
39 | 40 | use const PHP_URL_USER;
|
40 | 41 |
|
41 |
| -final class WpParseUrlFunctionDynamicReturnTypeExtension implements DynamicFunctionReturnTypeExtension |
| 42 | +final class WpParseUrlFunctionDynamicReturnTypeExtension implements \PHPStan\Type\DynamicFunctionReturnTypeExtension |
42 | 43 | {
|
43 |
| - |
44 |
| - /** @var array<int,Type>|null */ |
| 44 | + /** @var array<int, \PHPStan\Type\Type>|null */ |
45 | 45 | private $componentTypesPairedConstants = null;
|
46 | 46 |
|
47 |
| - /** @var array<string,Type>|null */ |
| 47 | + /** @var array<string, \PHPStan\Type\Type>|null */ |
48 | 48 | private $componentTypesPairedStrings = null;
|
49 | 49 |
|
50 |
| - /** @var Type|null */ |
| 50 | + /** @var \PHPStan\Type\Type|null */ |
51 | 51 | private $allComponentsTogetherType = null;
|
52 | 52 |
|
53 | 53 | public function isFunctionSupported(FunctionReflection $functionReflection): bool
|
@@ -84,6 +84,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
|
84 | 84 |
|
85 | 85 | if ($urlType instanceof ConstantStringType) {
|
86 | 86 | try {
|
| 87 | + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,Generic.PHP.NoSilencedErrors.Discouraged |
87 | 88 | $result = @parse_url($urlType->getValue(), $componentType->getValue());
|
88 | 89 | } catch (\ValueError $e) {
|
89 | 90 | return new ConstantBooleanType(false);
|
@@ -160,5 +161,4 @@ private function cacheReturnTypes(): void
|
160 | 161 | 'fragment' => $string,
|
161 | 162 | ];
|
162 | 163 | }
|
163 |
| - |
164 | 164 | }
|
0 commit comments