Skip to content

Commit eb6e8eb

Browse files
committed
Merge remote-tracking branch 'origin/1.3.x' into 1.4.x
2 parents ffb83c1 + 68fc764 commit eb6e8eb

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

src/Type/Doctrine/QueryBuilder/Expr/BaseExpressionDynamicReturnTypeExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1212
use PHPStan\Type\Type;
1313
use function get_class;
14+
use function in_array;
1415
use function is_object;
1516
use function method_exists;
1617

@@ -34,7 +35,7 @@ public function getClass(): string
3435

3536
public function isMethodSupported(MethodReflection $methodReflection): bool
3637
{
37-
return true;
38+
return in_array($methodReflection->getName(), ['add', 'addMultiple'], true);
3839
}
3940

4041
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Type\Doctrine\QueryBuilder\Expr;
4+
5+
use PHPStan\Testing\TypeInferenceTestCase;
6+
7+
class BaseExpressionDynamicReturnTypeExtensionTest extends TypeInferenceTestCase
8+
{
9+
10+
/** @return iterable<mixed> */
11+
public function dataFileAsserts(): iterable
12+
{
13+
yield from $this->gatherAssertTypes(__DIR__ . '/../../data/QueryResult/baseExpressionAndOr.php');
14+
}
15+
16+
/**
17+
* @dataProvider dataFileAsserts
18+
* @param mixed ...$args
19+
*/
20+
public function testFileAsserts(
21+
string $assertType,
22+
string $file,
23+
...$args
24+
): void
25+
{
26+
$this->assertFileAsserts($assertType, $file, ...$args);
27+
}
28+
29+
/** @return string[] */
30+
public static function getAdditionalConfigFiles(): array
31+
{
32+
return [__DIR__ . '/../../data/QueryResult/config.neon'];
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace QueryResult\CreateQuery;
4+
5+
use Doctrine\ORM\Query\Expr\Andx;
6+
use function PHPStan\Testing\assertType;
7+
8+
$and = new Andx();
9+
$count1 = $and->count();
10+
assertType("int<0, max>", $count1);
11+
12+
$modifiedAnd = $and->add('a = b');
13+
assertType("Doctrine\ORM\Query\Expr\Andx", $modifiedAnd);
14+
15+
$string = $and->__toString();
16+
assertType("string", $string);

0 commit comments

Comments
 (0)