Compare commits

...

10 Commits
2.8.3 ... 2.8.4

Author SHA1 Message Date
Grégoire Paris
a588555ecd Merge pull request #8586 from KartaviK/patch-3
Additional psalm param typehint for orderBy argument in findBy method
2021-04-05 20:38:36 +02:00
Grégoire Paris
7de84537f6 Merge pull request #8591 from DmitriiBezborodnikov/case_insensive_parenthesis
Return case insensitive check
2021-04-05 14:40:51 +02:00
Grégoire Paris
97f8325dad Make sure tests are suffixed with Test
They will not be taken into account when running vendor/bin/phpunit
otherwise.
2021-04-05 14:32:40 +02:00
Grégoire Paris
0ebd7052d7 Drop create table at shutdown
It makes tests more isolated from each other: another test relying on
some tables including some of the ones created here may fail creating
the tables it needs because they already exist.
2021-04-05 14:03:49 +02:00
Dmitrii Bezborodnikov
5d73378b92 Return case insensitive check 2021-04-05 14:03:49 +02:00
Grégoire Paris
10572ec441 Merge pull request #8590 from VincentLanglet/patch-2
Fix phpdoc of ClassMetadataInfo::getIdentifierValues
2021-04-04 23:47:09 +02:00
Vincent Langlet
76278d801d Fix phpdoc 2021-04-04 21:19:54 +02:00
Roman Varkuta
ca80830b26 Describe $orderBy parameter as a hash
A list of string is incorrect, it actually looks like this:
['someField' => 'DESC', 'someOtherField' => 'ASC'…]`
2021-04-03 12:45:24 +02:00
Grégoire Paris
bcb4889a2c Merge pull request #8583 from greg0ire/sync-static-analysis-workflows
Synchronize static analysis jobs with upstream
2021-04-02 08:58:50 +02:00
Grégoire Paris
961da8b0cc Synchronize static analysis jobs with upstream 2021-04-01 23:32:04 +02:00
8 changed files with 70 additions and 46 deletions

View File

@@ -1,12 +1,18 @@
name: Static Analysis
name: "Static Analysis"
on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"
jobs:
static-analysis-phpstan:
name: "PHPStan"
runs-on: "ubuntu-latest"
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
strategy:
matrix:
@@ -22,17 +28,18 @@ jobs:
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: cs2pr
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"
- name: "Run a static analysis with phpstan/phpstan"
run: "php vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
run: "vendor/bin/phpstan analyse"
static-analysis-psalm:
name: "Psalm"
runs-on: "ubuntu-latest"
name: "Static Analysis with Psalm"
runs-on: "ubuntu-20.04"
strategy:
matrix:
@@ -51,6 +58,8 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"
- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"

View File

@@ -185,7 +185,7 @@ class EntityRepository implements ObjectRepository, Selectable
* @param int|null $offset
*
* @psalm-param array<string, mixed> $criteria
* @psalm-param list<string>|null $orderBy
* @psalm-param array<string, string>|null $orderBy
* @psalm-return list<T> The objects.
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)

View File

@@ -748,7 +748,7 @@ class ClassMetadataInfo implements ClassMetadata
*
* @param object $entity
*
* @return array<string|int, mixed>
* @return array<string, mixed>
*/
public function getIdentifierValues($entity)
{

View File

@@ -273,8 +273,8 @@ interface EntityPersister
* @param int|null $limit
* @param int|null $offset
*
* @psalm-param list<string>|null $orderBy
* @psalm-param array<string, mixed> $criteria
* @psalm-param array<string, string>|null $orderBy
* @psalm-param array<string, mixed> $criteria
*/
public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = null, $offset = null);

View File

@@ -63,7 +63,7 @@ class Composite extends Base
}
// Fixes DDC-1237: User may have added a where item containing nested expression (with "OR" or "AND")
if (preg_match('/\s(OR|AND)\s/', $queryPart)) {
if (preg_match('/\s(OR|AND)\s/i', $queryPart)) {
return $this->preSeparator . $queryPart . $this->postSeparator;
}

View File

@@ -9,7 +9,6 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\IterableTester;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function assert;
use function count;
@@ -23,19 +22,25 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Type::class),
]
);
} catch (Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
}
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Type::class),
]);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(Phrase::class),
$this->_em->getClassMetadata(PhraseType::class),
$this->_em->getClassMetadata(Definition::class),
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Type::class),
]);
}
public function testIssue(): void

View File

@@ -6,7 +6,7 @@ namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\OrmFunctionalTestCase;
class QueryBuilderParenthesis extends OrmFunctionalTestCase
class QueryBuilderParenthesisTest extends OrmFunctionalTestCase
{
protected function setUp(): void
{
@@ -36,6 +36,7 @@ class QueryBuilderParenthesis extends OrmFunctionalTestCase
$queryBuilder->select('o')->from(QueryBuilderParenthesisEntity::class, 'o');
$queryBuilder->andWhere('o.property3 = :value3')->setParameter('value3', 'x');
$queryBuilder->andWhere('o.property1 = :value1 OR o.property2 = :value2');
$queryBuilder->andWhere('o.property1 = :value1 or o.property2 = :value2');
$queryBuilder->setParameter('value1', 'x');
$queryBuilder->setParameter('value2', 'x');
@@ -46,7 +47,7 @@ class QueryBuilderParenthesis extends OrmFunctionalTestCase
$dql = $query->getDQL();
$this->assertSame(
'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2)',
'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2) AND (o.property1 = :value1 or o.property2 = :value2)',
$dql
);
}

View File

@@ -5,30 +5,34 @@ declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\OrmFunctionalTestCase;
use Exception;
use function assert;
/**
* Functional tests for the Single Table Inheritance mapping strategy.
*/
class AdvancedAssociationTest extends OrmFunctionalTestCase
class DDC69Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Relation::class),
$this->_em->getClassMetadata(RelationType::class),
]
);
} catch (Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
}
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Relation::class),
$this->_em->getClassMetadata(RelationType::class),
]);
}
protected function tearDown(): void
{
parent::tearDown();
$this->_schemaTool->dropSchema([
$this->_em->getClassMetadata(Lemma::class),
$this->_em->getClassMetadata(Relation::class),
$this->_em->getClassMetadata(RelationType::class),
]);
}
public function testIssue(): void
@@ -124,9 +128,8 @@ class Lemma
*/
private $lemma;
/**
* @var kateglo\application\utilities\collections\ArrayCollection
* @var Collection<int, Relation>
* @OneToMany(targetEntity="Relation", mappedBy="parent", cascade={"persist"})
*/
private $relations;
@@ -167,7 +170,10 @@ class Lemma
}
}
public function getRelations(): kateglo\application\utilities\collections\ArrayCollection
/**
* @psalm-return Collection<int, Relation>
*/
public function getRelations(): Collection
{
return $this->relations;
}
@@ -288,7 +294,7 @@ class RelationType
private $abbreviation;
/**
* @var kateglo\application\utilities\collections\ArrayCollection
* @var Collection<int, Relation>
* @OneToMany(targetEntity="Relation", mappedBy="type", cascade={"persist"})
*/
private $relations;
@@ -338,7 +344,10 @@ class RelationType
}
}
public function getRelations(): kateglo\application\utilities\collections\ArrayCollection
/**
* @psalm-return Collection<int, Relation>
*/
public function getRelations(): Collection
{
return $this->relations;
}