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()
4141 {
4242 }
4343
44+ public function getConstantScalarTypes (): array
45+ {
46+ return [new ConstantBooleanType (true ), new ConstantBooleanType (false )];
47+ }
48+
4449 public function getConstantStrings (): array
4550 {
46- return [];
51+ return [new ConstantStringType ('1 ' ), new ConstantStringType ('0 ' )];
52+ }
53+
54+ public function getConstantScalarValues (): array
55+ {
56+ return [true , false ];
4757 }
4858
4959 public function describe (VerbosityLevel $ level ): string
Original file line number Diff line number Diff line change 55use PhpParser \Node \Expr \FuncCall ;
66use PHPStan \Analyser \Scope ;
77use PHPStan \Reflection \FunctionReflection ;
8- use PHPStan \Type \BooleanType ;
9- use PHPStan \Type \Constant \ConstantBooleanType ;
108use PHPStan \Type \Constant \ConstantIntegerType ;
119use PHPStan \Type \Constant \ConstantStringType ;
1210use PHPStan \Type \DynamicFunctionReturnTypeExtension ;
@@ -44,16 +42,7 @@ public function getTypeFromFunctionCall(
4442 }
4543
4644 $ 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 ();
5746
5847 $ lengths = [];
5948 foreach ($ constantScalars as $ constantScalar ) {
Original file line number Diff line number Diff line change @@ -53,4 +53,4 @@ function returnsBool(): bool {
5353assertType ("' 1' " , $ s );
5454
5555$ 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