File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,19 @@ public function __construct()
41
41
{
42
42
}
43
43
44
+ public function getConstantScalarTypes (): array
45
+ {
46
+ return [new ConstantBooleanType (true ), new ConstantBooleanType (false )];
47
+ }
48
+
44
49
public function getConstantStrings (): array
45
50
{
46
- return [];
51
+ return [new ConstantStringType ('1 ' ), new ConstantStringType ('0 ' )];
52
+ }
53
+
54
+ public function getConstantScalarValues (): array
55
+ {
56
+ return [true , false ];
47
57
}
48
58
49
59
public function describe (VerbosityLevel $ level ): string
Original file line number Diff line number Diff line change 5
5
use PhpParser \Node \Expr \FuncCall ;
6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Reflection \FunctionReflection ;
8
- use PHPStan \Type \BooleanType ;
9
- use PHPStan \Type \Constant \ConstantBooleanType ;
10
8
use PHPStan \Type \Constant \ConstantIntegerType ;
11
9
use PHPStan \Type \Constant \ConstantStringType ;
12
10
use PHPStan \Type \DynamicFunctionReturnTypeExtension ;
@@ -44,16 +42,7 @@ public function getTypeFromFunctionCall(
44
42
}
45
43
46
44
$ argType = $ scope ->getType ($ args [0 ]->value );
47
-
48
- if ($ argType ->isSuperTypeOf (new BooleanType ())->yes ()) {
49
- $ constantScalars = TypeCombinator::remove ($ argType , new BooleanType ())->getConstantScalarTypes ();
50
- if (count ($ constantScalars ) > 0 ) {
51
- $ constantScalars [] = new ConstantBooleanType (true );
52
- $ constantScalars [] = new ConstantBooleanType (false );
53
- }
54
- } else {
55
- $ constantScalars = $ argType ->getConstantScalarTypes ();
56
- }
45
+ $ constantScalars = $ argType ->getConstantScalarTypes ();
57
46
58
47
$ lengths = [];
59
48
foreach ($ constantScalars as $ constantScalar ) {
Original file line number Diff line number Diff line change @@ -53,4 +53,4 @@ function returnsBool(): bool {
53
53
assertType ("' 1' " , $ s );
54
54
55
55
$ s = sprintf ('%20s ' , returnsBool ());
56
- assertType ("lowercase-string&non-falsy-string " , $ s );
56
+ assertType ("' '|' 1' " , $ s );
You can’t perform that action at this time.
0 commit comments