File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
tests/PHPStan/Analyser/data Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -269,8 +269,8 @@ public function specifyTypesInCondition(
269269 && $ leftType ->isInteger ()->yes ()
270270 ) {
271271 if (
272- $ context ->truthy () && (IntegerRangeType::createAllGreaterThanOrEqualTo (1 - $ offset )->isSuperTypeOf ($ leftType )->yes ())
273- || ($ context ->falsey () && (new ConstantIntegerType (1 - $ offset ))->isSuperTypeOf ($ leftType )->yes ())
272+ $ context ->true () && (IntegerRangeType::createAllGreaterThanOrEqualTo (1 - $ offset )->isSuperTypeOf ($ leftType )->yes ())
273+ || ($ context ->false () && (new ConstantIntegerType (1 - $ offset ))->isSuperTypeOf ($ leftType )->yes ())
274274 ) {
275275 $ argType = $ scope ->getType ($ expr ->right ->getArgs ()[0 ]->value );
276276 if ($ argType ->isString ()->yes ()) {
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug10952c ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ class HelloWorld
8+ {
9+ public function getString (): string
10+ {
11+ return 'hallo ' ;
12+ }
13+
14+ public function test (): void
15+ {
16+ $ string = $ this ->getString ();
17+
18+ if ((strlen ($ string ) > 1 ) === true ) {
19+ assertType ('non-empty-string ' , $ string );
20+ } else {
21+ assertType ("string " , $ string );
22+ }
23+
24+ match (true ) {
25+ (strlen ($ string ) > 1 ) => assertType ('non-empty-string ' , $ string ),
26+ default => assertType ("string " , $ string ),
27+ };
28+
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments