@@ -77,6 +77,17 @@ public function narrowedExpressionsExamples(): mixed
7777 'nullableString === variableOfTypeNull ' , $ variableIsNull
7878 ],
7979
80+ 'nullableString && true ' => [
81+ 'nullableString && true ' ,
82+ $ variableIsString
83+ ],
84+
85+ 'FALSY:: nullableString && true ' => [
86+ 'nullableString && true ' ,
87+ NarrowedTypes::empty (),
88+ TypeNarrowerContext::FALSY
89+ ],
90+
8091 'nullableString === true ' => [
8192 'nullableString === true ' ,
8293 NarrowedTypes::empty ()
@@ -88,8 +99,11 @@ public function narrowedExpressionsExamples(): mixed
8899 * @dataProvider narrowedExpressionsExamples
89100 * @test
90101 */
91- public function narrowedExpressions (string $ expressionAsString , NarrowedTypes $ expectedTypes ): void
92- {
102+ public function narrowedExpressions (
103+ string $ expressionAsString ,
104+ NarrowedTypes $ expectedTypes ,
105+ TypeNarrowerContext $ context = TypeNarrowerContext::TRUTHY
106+ ): void {
93107 $ expressionTypeNarrower = new ExpressionTypeNarrower (
94108 scope: new DummyScope ([
95109 'nullableString ' => UnionType::of (StringType::get (), NullType::get ()),
@@ -99,7 +113,7 @@ public function narrowedExpressions(string $expressionAsString, NarrowedTypes $e
99113
100114 $ expressionNode = ExpressionNode::fromString ($ expressionAsString );
101115
102- $ actualTypes = $ expressionTypeNarrower ->narrowTypesOfSymbolsIn ($ expressionNode , TypeNarrowerContext:: TRUTHY );
116+ $ actualTypes = $ expressionTypeNarrower ->narrowTypesOfSymbolsIn ($ expressionNode , $ context );
103117
104118 $ this ->assertEqualsCanonicalizing (
105119 $ expectedTypes ->toArray (),
0 commit comments