File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,11 @@ public function specifyTypesInCondition(
376376 && $ expr ->left ->name instanceof Name
377377 && strtolower ((string ) $ expr ->left ->name ) === 'count '
378378 && $ rightType instanceof ConstantIntegerType
379+ && (
380+ !$ expr ->right instanceof FuncCall
381+ || !$ expr ->right ->name instanceof Name
382+ || strtolower ((string ) $ expr ->right ->name ) !== 'count '
383+ )
379384 ) {
380385 $ inverseOperator = $ expr instanceof Node \Expr \BinaryOp \Smaller
381386 ? new Node \Expr \BinaryOp \SmallerOrEqual ($ expr ->right , $ expr ->left )
Original file line number Diff line number Diff line change @@ -291,6 +291,14 @@ public function testBug4097(): void
291291 $ this ->assertCount (0 , $ errors );
292292 }
293293
294+ public function testBug4300 (): void
295+ {
296+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-4300.php ' );
297+ $ this ->assertCount (1 , $ errors );
298+ $ this ->assertSame ('Comparison operation ">" between 0 and 0 is always false. ' , $ errors [0 ]->getMessage ());
299+ $ this ->assertSame (13 , $ errors [0 ]->getLine ());
300+ }
301+
294302 /**
295303 * @param string $file
296304 * @return \PHPStan\Analyser\Error[]
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Bug4300 ;
4+
5+ class Widget
6+ {
7+
8+ public function getDefault (): int
9+ {
10+ $ column1 = [];
11+ $ column2 = [];
12+
13+ $ column = count ($ column1 ) > count ($ column2 ) ? 2 : 1 ;
14+
15+ return $ column ;
16+ }
17+
18+ }
You can’t perform that action at this time.
0 commit comments