Skip to content

Commit 1c34d8d

Browse files
committed
[BCB] Removed MissingClosureNativeReturnTypehintRule, no longer needed thanks to type inference
1 parent 1baa294 commit 1c34d8d

8 files changed

+60
-286
lines changed

composer.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conf/config.level0.neon

-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
parameters:
22
customRulesetUsed: false
3-
missingClosureNativeReturnCheckObjectTypehint: false
43

54
conditionalTags:
65
PHPStan\Rules\Api\ApiInstantiationRule:
@@ -23,18 +22,13 @@ conditionalTags:
2322
phpstan.rules.rule: %featureToggles.classConstants%
2423
PHPStan\Rules\Functions\ClosureUsesThisRule:
2524
phpstan.rules.rule: %featureToggles.closureUsesThis%
26-
PHPStan\Rules\Missing\MissingClosureNativeReturnTypehintRule:
27-
phpstan.rules.rule: %checkMissingClosureNativeReturnTypehintRule%
2825
PHPStan\Rules\Whitespace\FileWhitespaceRule:
2926
phpstan.rules.rule: %featureToggles.fileWhitespace%
3027
PHPStan\Rules\Properties\UninitializedPropertyRule:
3128
phpstan.rules.rule: %checkUninitializedProperties%
3229
PHPStan\Rules\Properties\OverridingPropertyRule:
3330
phpstan.rules.rule: %featureToggles.overridingProperty%
3431

35-
parametersSchema:
36-
missingClosureNativeReturnCheckObjectTypehint: bool()
37-
3832
rules:
3933
- PHPStan\Rules\Arrays\DuplicateKeysInLiteralArraysRule
4034
- PHPStan\Rules\Arrays\EmptyArrayItemRule
@@ -162,11 +156,6 @@ services:
162156
tags:
163157
- phpstan.rules.rule
164158

165-
-
166-
class: PHPStan\Rules\Missing\MissingClosureNativeReturnTypehintRule
167-
arguments:
168-
checkObjectTypehint: %missingClosureNativeReturnCheckObjectTypehint%
169-
170159
-
171160
class: PHPStan\Rules\Missing\MissingReturnRule
172161
arguments:

conf/config.neon

-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ parameters:
7373
checkPhpDocMissingReturn: false
7474
checkPhpDocMethodSignatures: false
7575
checkExtraArguments: false
76-
checkMissingClosureNativeReturnTypehintRule: false
7776
checkMissingTypehints: false
7877
checkTooWideReturnTypesInProtectedAndPublicMethods: false
7978
checkUninitializedProperties: false
@@ -255,7 +254,6 @@ parametersSchema:
255254
checkPhpDocMissingReturn: bool()
256255
checkPhpDocMethodSignatures: bool()
257256
checkExtraArguments: bool()
258-
checkMissingClosureNativeReturnTypehintRule: bool()
259257
checkMissingTypehints: bool()
260258
checkTooWideReturnTypesInProtectedAndPublicMethods: bool()
261259
checkUninitializedProperties: bool()

src/Rules/Missing/MissingClosureNativeReturnTypehintRule.php

-137
This file was deleted.

tests/PHPStan/Analyser/NodeScopeResolverTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ public function dataFileAsserts(): iterable
504504
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5615.php');
505505
yield from $this->gatherAssertTypes(__DIR__ . '/data/array_map_multiple.php');
506506
yield from $this->gatherAssertTypes(__DIR__ . '/data/range-numeric-string.php');
507+
yield from $this->gatherAssertTypes(__DIR__ . '/data/missing-closure-native-return-typehint.php');
507508
}
508509

509510
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace MissingClosureNativeReturnTypehint;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo()
9+
{
10+
\PHPStan\Testing\assertType('void', (function () {
11+
12+
})());
13+
\PHPStan\Testing\assertType('void', (function () {
14+
return;
15+
})());
16+
\PHPStan\Testing\assertType('Generator<int, 1, mixed, void>', (function (bool $bool) {
17+
if ($bool) {
18+
return;
19+
} else {
20+
yield 1;
21+
}
22+
})());
23+
\PHPStan\Testing\assertType('1|null', (function (bool $bool) {
24+
if ($bool) {
25+
return;
26+
} else {
27+
return 1;
28+
}
29+
})());
30+
\PHPStan\Testing\assertType('1', (function (): int {
31+
return 1;
32+
})());
33+
\PHPStan\Testing\assertType('1|null', (function (bool $bool) {
34+
if ($bool) {
35+
return null;
36+
} else {
37+
return 1;
38+
}
39+
})());
40+
\PHPStan\Testing\assertType('1', (function (bool $bool) {
41+
if ($bool) {
42+
return 1;
43+
}
44+
})());
45+
46+
\PHPStan\Testing\assertType('array(\'foo\' => \'bar\')', (function () {
47+
$array = [
48+
'foo' => 'bar',
49+
];
50+
51+
return $array;
52+
})());
53+
}
54+
55+
}

tests/PHPStan/Rules/Missing/MissingClosureNativeReturnTypehintRuleTest.php

-77
This file was deleted.

0 commit comments

Comments
 (0)