Skip to content

Commit b1c88e0

Browse files
committed
adjust tests
1 parent aca1b66 commit b1c88e0

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

tests/PHPStan/Rules/TooWideTypehints/TooWideFunctionReturnTypehintRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public function testBug13384cPhp82(): void
9494
'Function Bug13384c\doFooPhpdoc2() never returns true so the return type can be changed to false.',
9595
100,
9696
],
97+
[
98+
'Function Bug13384c\callsReturnsTrue() never returns false so the return type can be changed to true.',
99+
122,
100+
],
97101
]);
98102
}
99103

tests/PHPStan/Rules/TooWideTypehints/data/bug-13384c.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Bug13384c;
44

55
function doFoo(): bool {
6-
return false;
6+
return returnsFalse();
77
}
88

99
function doFoo2(): bool {
10-
return true;
10+
return returnsTrue();
1111
}
1212

1313
function doFoo3(): bool {
@@ -20,22 +20,22 @@ function doFoo3(): bool {
2020

2121
class Bug13384c {
2222
public function doBarPublic(): bool {
23-
return false;
23+
return returnsFalse();
2424
}
2525

2626
/**
2727
* @return false
2828
*/
2929
private function doBarPhpdocReturn(): bool {
30-
return false;
30+
return returnsFalse();
3131
}
3232

3333
private function doBar(): bool {
34-
return false;
34+
return returnsFalse();
3535
}
3636

3737
private function doBar2(): bool {
38-
return true;
38+
return returnsTrue();
3939
}
4040

4141
private function doBar3(): bool {
@@ -46,25 +46,25 @@ private function doBar3(): bool {
4646
}
4747

4848
private function doBarMixed() {
49-
return true;
49+
return returnsTrue();
5050
}
5151

5252
/**
5353
* @return bool
5454
*/
5555
private function doBarPhpdoc() {
56-
return true;
56+
return returnsTrue();
5757
}
5858

5959
}
6060

6161
class Bug13384Static {
6262
private static function doBar(): bool {
63-
return false;
63+
return returnsFalse();
6464
}
6565

6666
private static function doBar2(): bool {
67-
return true;
67+
return returnsTrue();
6868
}
6969

7070
private static function doBar3(): bool {
@@ -75,14 +75,14 @@ private static function doBar3(): bool {
7575
}
7676

7777
private static function doBarMixed() {
78-
return true;
78+
return returnsTrue();
7979
}
8080

8181
/**
8282
* @return bool
8383
*/
8484
private static function doBarPhpdoc() {
85-
return true;
85+
return returnsTrue();
8686
}
8787

8888
}
@@ -91,18 +91,18 @@ private static function doBarPhpdoc() {
9191
* @return bool
9292
*/
9393
function doFooPhpdoc() {
94-
return true;
94+
return returnsTrue();
9595
}
9696

9797
/**
9898
* @return bool
9999
*/
100100
function doFooPhpdoc2() {
101-
return false;
101+
return returnsFalse();
102102
}
103103

104104
function doFooMixed() {
105-
return true;
105+
return returnsTrue();
106106
}
107107

108108
/**
@@ -112,6 +112,13 @@ function returnsTrue(): bool {
112112
return true;
113113
}
114114

115+
/**
116+
* @return false
117+
*/
118+
function returnsFalse(): bool {
119+
return false;
120+
}
121+
115122
function callsReturnsTrue(): bool {
116123
return returnsTrue();
117124
}

0 commit comments

Comments
 (0)