File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 99use PHPStan \Type \ErrorType ;
1010use PHPStan \Type \IntersectionType ;
1111use PHPStan \Type \MixedType ;
12+ use PHPStan \Type \NeverType ;
1213use PHPStan \Type \ObjectType ;
1314use PHPStan \Type \StringType ;
1415use PHPStan \Type \Type ;
@@ -30,6 +31,10 @@ final class QuerySimulation
3031 */
3132 public static function simulateParamValueType (Type $ paramType , bool $ preparedParam ): ?string
3233 {
34+ if ($ paramType instanceof NeverType) {
35+ return null ;
36+ }
37+
3338 if ($ paramType instanceof ConstantScalarType) {
3439 return (string ) $ paramType ->getValue ();
3540 }
Original file line number Diff line number Diff line change 77use PHPStan \Type \Constant \ConstantArrayTypeBuilder ;
88use PHPStan \Type \FloatType ;
99use PHPStan \Type \IntegerType ;
10+ use PHPStan \Type \NeverType ;
1011use PHPStan \Type \StringType ;
1112use PHPUnit \Framework \TestCase ;
1213use staabm \PHPStanDba \QueryReflection \QuerySimulation ;
@@ -44,6 +45,17 @@ public function testIntersectionTypeMix()
4445 self ::assertNotNull ($ simulatedValue );
4546 }
4647
48+ /**
49+ * Prevent endless loop.
50+ *
51+ * see https://github.com/yakamara/ydeploy/pull/101
52+ */
53+ public function testNeverType ()
54+ {
55+ self ::assertNull (QuerySimulation::simulateParamValueType (new NeverType (), true ));
56+ self ::assertNull (QuerySimulation::simulateParamValueType (new NeverType (), false ));
57+ }
58+
4759 /**
4860 * @dataProvider provideQueriesWithComments
4961 */
You can’t perform that action at this time.
0 commit comments