mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 15:02:22 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27c33cf88d | ||
|
|
6068b61a0d | ||
|
|
00024f7d88 | ||
|
|
331f8b52cb | ||
|
|
b2faba62b7 | ||
|
|
da426a0036 | ||
|
|
1891a76f13 |
10
.github/workflows/continuous-integration.yml
vendored
10
.github/workflows/continuous-integration.yml
vendored
@@ -150,7 +150,7 @@ jobs:
|
||||
ENABLE_NATIVE_LAZY_OBJECTS: ${{ matrix.native_lazy }}
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v6"
|
||||
uses: "actions/upload-artifact@v7"
|
||||
with:
|
||||
name: "phpunit-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.deps }}-${{ matrix.stability }}-${{ matrix.native_lazy }}-coverage"
|
||||
path: "coverage*.xml"
|
||||
@@ -265,7 +265,7 @@ jobs:
|
||||
run: "vendor/bin/phpunit -c ci/github/phpunit/pdo_pgsql.xml --coverage-clover=coverage.xml"
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v6"
|
||||
uses: "actions/upload-artifact@v7"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.postgres-version }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-${{ matrix.extension }}-coverage"
|
||||
path: "coverage.xml"
|
||||
@@ -339,7 +339,7 @@ jobs:
|
||||
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
|
||||
|
||||
- name: "Upload coverage file"
|
||||
uses: "actions/upload-artifact@v6"
|
||||
uses: "actions/upload-artifact@v7"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.mariadb-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
path: "coverage.xml"
|
||||
@@ -442,7 +442,7 @@ jobs:
|
||||
ENABLE_SECOND_LEVEL_CACHE: 1
|
||||
|
||||
- name: "Upload coverage files"
|
||||
uses: "actions/upload-artifact@v6"
|
||||
uses: "actions/upload-artifact@v7"
|
||||
with:
|
||||
name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage"
|
||||
path: "coverage*.xml"
|
||||
@@ -465,7 +465,7 @@ jobs:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: "Download coverage files"
|
||||
uses: "actions/download-artifact@v7"
|
||||
uses: "actions/download-artifact@v8"
|
||||
with:
|
||||
path: "reports"
|
||||
|
||||
|
||||
@@ -2580,30 +2580,12 @@ parameters:
|
||||
count: 1
|
||||
path: src/Query/Exec/SingleTableDeleteUpdateExecutor.php
|
||||
|
||||
-
|
||||
message: '#^PHPDoc type array\<string\> of property Doctrine\\ORM\\Query\\Expr\\Andx\:\:\$allowedClasses is not covariant with PHPDoc type list\<class\-string\> of overridden property Doctrine\\ORM\\Query\\Expr\\Base\:\:\$allowedClasses\.$#'
|
||||
identifier: property.phpDocType
|
||||
count: 1
|
||||
path: src/Query/Expr/Andx.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Query\\Expr\\Func\:\:getArguments\(\) should return list\<mixed\> but returns array\<mixed\>\.$#'
|
||||
identifier: return.type
|
||||
count: 1
|
||||
path: src/Query/Expr/Func.php
|
||||
|
||||
-
|
||||
message: '#^PHPDoc type array\<string\> of property Doctrine\\ORM\\Query\\Expr\\Orx\:\:\$allowedClasses is not covariant with PHPDoc type list\<class\-string\> of overridden property Doctrine\\ORM\\Query\\Expr\\Base\:\:\$allowedClasses\.$#'
|
||||
identifier: property.phpDocType
|
||||
count: 1
|
||||
path: src/Query/Expr/Orx.php
|
||||
|
||||
-
|
||||
message: '#^PHPDoc type array\<string\> of property Doctrine\\ORM\\Query\\Expr\\Select\:\:\$allowedClasses is not covariant with PHPDoc type list\<class\-string\> of overridden property Doctrine\\ORM\\Query\\Expr\\Base\:\:\$allowedClasses\.$#'
|
||||
identifier: property.phpDocType
|
||||
count: 1
|
||||
path: src/Query/Expr/Select.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Query\\ParameterTypeInferer\:\:inferType\(\) never returns int so it can be removed from the return type\.$#'
|
||||
identifier: return.unusedType
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Query\Expr;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Expression class for building DQL and parts.
|
||||
*
|
||||
@@ -13,7 +15,7 @@ class Andx extends Composite
|
||||
{
|
||||
protected string $separator = ' AND ';
|
||||
|
||||
/** @var string[] */
|
||||
/** @var list<class-string<Stringable>> */
|
||||
protected array $allowedClasses = [
|
||||
Comparison::class,
|
||||
Func::class,
|
||||
|
||||
@@ -13,6 +13,7 @@ use function get_debug_type;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_object;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
@@ -27,7 +28,7 @@ abstract class Base implements Stringable
|
||||
protected string $separator = ', ';
|
||||
protected string $postSeparator = ')';
|
||||
|
||||
/** @var list<class-string> */
|
||||
/** @var list<class-string<Stringable>> */
|
||||
protected array $allowedClasses = [];
|
||||
|
||||
/** @var list<string|Stringable> */
|
||||
@@ -58,6 +59,8 @@ abstract class Base implements Stringable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Stringable|null $arg
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -66,7 +69,8 @@ abstract class Base implements Stringable
|
||||
{
|
||||
if ($arg !== null && (! $arg instanceof self || $arg->count() > 0)) {
|
||||
// If we decide to keep Expr\Base instances, we can use this check
|
||||
if (! is_string($arg) && ! in_array($arg::class, $this->allowedClasses, true)) {
|
||||
// @phpstan-ignore function.alreadyNarrowedType (input validation)
|
||||
if (! is_string($arg) && ! (is_object($arg) && in_array($arg::class, $this->allowedClasses, true))) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
"Expression of type '%s' not allowed in this context.",
|
||||
get_debug_type($arg),
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Query\Expr;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Expression class for building DQL OR clauses.
|
||||
*
|
||||
@@ -13,7 +15,7 @@ class Orx extends Composite
|
||||
{
|
||||
protected string $separator = ' OR ';
|
||||
|
||||
/** @var string[] */
|
||||
/** @var list<class-string<Stringable>> */
|
||||
protected array $allowedClasses = [
|
||||
Comparison::class,
|
||||
Func::class,
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\ORM\Query\Expr;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Expression class for building DQL select statements.
|
||||
*
|
||||
@@ -14,7 +16,7 @@ class Select extends Base
|
||||
protected string $preSeparator = '';
|
||||
protected string $postSeparator = '';
|
||||
|
||||
/** @var string[] */
|
||||
/** @var list<class-string<Stringable>> */
|
||||
protected array $allowedClasses = [Func::class];
|
||||
|
||||
/** @phpstan-var list<string|Func> */
|
||||
|
||||
@@ -374,11 +374,27 @@ class ExprTest extends OrmTestCase
|
||||
|
||||
public function testAddThrowsException(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$orExpr = $this->expr->orX();
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$orExpr->add($this->expr->quot(5, 2));
|
||||
}
|
||||
|
||||
#[DataProvider('provideInvalidTypesForAdd')]
|
||||
public function testAddThrowsExceptionOnInvalidType(mixed $arg): void
|
||||
{
|
||||
$orExpr = $this->expr->orX();
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$orExpr->add($arg);
|
||||
}
|
||||
|
||||
/** @return Generator<string, array{mixed}> */
|
||||
public static function provideInvalidTypesForAdd(): Generator
|
||||
{
|
||||
yield 'integer 1' => [1];
|
||||
yield 'object' => [(object) ['foo' => 'bar']];
|
||||
yield 'array' => [['foo' => 'bar']];
|
||||
}
|
||||
|
||||
#[Group('DDC-1683')]
|
||||
public function testBooleanLiteral(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user