diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
index f84b1355411..02fbef3b0e9 100644
--- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
+++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
@@ -294,7 +294,7 @@ protected function hydrateRowData(array $row, array &$result)
/**
* Hydrates all rows from the current statement instance at once.
*
- * @return array
+ * @return mixed[]
*/
abstract protected function hydrateAllData();
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index edefbf8c6bc..f3542e31d14 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -189,4 +189,13 @@
lib/Doctrine/ORM/Tools/EntityGenerator.php
+
+
+
+ tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php
+
+
+
+ tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests*
+
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php
index ec96efdaa29..13e78749a69 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php
@@ -16,9 +16,9 @@ protected function setUp(): void
try {
$this->_schemaTool->createSchema(
[
- $this->_em->getClassMetadata(DDC1209_1::class),
- $this->_em->getClassMetadata(DDC1209_2::class),
- $this->_em->getClassMetadata(DDC1209_3::class),
+ $this->_em->getClassMetadata(DDC1209One::class),
+ $this->_em->getClassMetadata(DDC1209Two::class),
+ $this->_em->getClassMetadata(DDC1209Three::class),
]
);
} catch (Exception $e) {
@@ -30,12 +30,12 @@ protected function setUp(): void
*/
public function testIdentifierCanHaveCustomType(): void
{
- $entity = new DDC1209_3();
+ $entity = new DDC1209Three();
$this->_em->persist($entity);
$this->_em->flush();
- self::assertSame($entity, $this->_em->find(DDC1209_3::class, $entity->date));
+ self::assertSame($entity, $this->_em->find(DDC1209Three::class, $entity->date));
}
/**
@@ -43,12 +43,12 @@ public function testIdentifierCanHaveCustomType(): void
*/
public function testCompositeIdentifierCanHaveCustomType(): void
{
- $future1 = new DDC1209_1();
+ $future1 = new DDC1209One();
$this->_em->persist($future1);
$this->_em->flush();
- $future2 = new DDC1209_2($future1);
+ $future2 = new DDC1209Two($future1);
$this->_em->persist($future2);
$this->_em->flush();
@@ -56,12 +56,12 @@ public function testCompositeIdentifierCanHaveCustomType(): void
self::assertSame(
$future2,
$this->_em->find(
- DDC1209_2::class,
+ DDC1209Two::class,
[
'future1' => $future1,
- 'starting_datetime' => $future2->starting_datetime,
- 'during_datetime' => $future2->during_datetime,
- 'ending_datetime' => $future2->ending_datetime,
+ 'startingDatetime' => $future2->startingDatetime,
+ 'duringDatetime' => $future2->duringDatetime,
+ 'endingDatetime' => $future2->endingDatetime,
]
)
);
@@ -71,12 +71,16 @@ public function testCompositeIdentifierCanHaveCustomType(): void
/**
* @Entity
*/
-class DDC1209_1
+class DDC1209One
{
- /** @Id @GeneratedValue @Column(type="integer") */
+ /**
+ * @var int
+ * @Id
+ * @GeneratedValue @Column(type="integer")
+ */
private $id;
- public function getId()
+ public function getId(): int
{
return $this->id;
}
@@ -85,47 +89,53 @@ public function getId()
/**
* @Entity
*/
-class DDC1209_2
+class DDC1209Two
{
/**
- * @Id
- * @ManyToOne(targetEntity="DDC1209_1")
- * @JoinColumn(referencedColumnName="id", nullable=false)
+ * @var DDC1209One
+ * @Id
+ * @ManyToOne(targetEntity="DDC1209One")
+ * @JoinColumn(referencedColumnName="id", nullable=false)
*/
private $future1;
+
/**
- * @Id
- * @Column(type="datetime", nullable=false)
+ * @var DateTime2
+ * @Id
+ * @Column(type="datetime", nullable=false)
*/
- public $starting_datetime;
+ public $startingDatetime;
/**
- * @Id
- * @Column(type="datetime", nullable=false)
+ * @var DateTime2
+ * @Id
+ * @Column(type="datetime", nullable=false)
*/
- public $during_datetime;
+ public $duringDatetime;
/**
- * @Id
- * @Column(type="datetime", nullable=false)
+ * @var DateTime2
+ * @Id
+ * @Column(type="datetime", nullable=false)
*/
- public $ending_datetime;
+ public $endingDatetime;
- public function __construct(DDC1209_1 $future1)
+ public function __construct(DDC1209One $future1)
{
- $this->future1 = $future1;
- $this->starting_datetime = new DateTime2();
- $this->during_datetime = new DateTime2();
- $this->ending_datetime = new DateTime2();
+ $this->future1 = $future1;
+ $this->startingDatetime = new DateTime2();
+ $this->duringDatetime = new DateTime2();
+ $this->endingDatetime = new DateTime2();
}
}
/**
* @Entity
*/
-class DDC1209_3
+class DDC1209Three
{
/**
+ * @var DateTime2
* @Id
* @Column(type="datetime", name="somedate")
*/
@@ -139,7 +149,7 @@ public function __construct()
class DateTime2 extends DateTime
{
- public function __toString()
+ public function __toString(): string
{
return $this->format('Y');
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php
index 7529d5f2fbb..11a8813a9a8 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\OrmFunctionalTestCase;
final class GH6531Test extends OrmFunctionalTestCase
@@ -85,7 +86,12 @@ public function testJoinTableWithMetadata(): void
*/
class GH6531User
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
}
@@ -94,7 +100,11 @@ class GH6531User
*/
class GH6531Address
{
- /** @Id @OneToOne(targetEntity=GH6531User::class) */
+ /**
+ * @var GH6531User
+ * @Id
+ * @OneToOne(targetEntity=GH6531User::class)
+ */
public $user;
}
@@ -103,10 +113,18 @@ class GH6531Address
*/
class GH6531Article
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
- /** @OneToMany(targetEntity=GH6531ArticleAttribute::class, mappedBy="article", cascade={"ALL"}, indexBy="attribute") */
+ /**
+ * @psalm-var Collection
+ * @OneToMany(targetEntity=GH6531ArticleAttribute::class, mappedBy="article", cascade={"ALL"}, indexBy="attribute")
+ * */
public $attributes;
public function addAttribute(string $name, string $value): void
@@ -120,10 +138,18 @@ public function addAttribute(string $name, string $value): void
*/
class GH6531ArticleAttribute
{
- /** @Id @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") */
+ /**
+ * @var GH6531Article
+ * @Id
+ * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes")
+ */
public $article;
- /** @Id @Column(type="string") */
+ /**
+ * @var string
+ * @Id
+ * @Column(type="string")
+ */
public $attribute;
/**
@@ -145,10 +171,18 @@ public function __construct(string $name, string $value, GH6531Article $article)
*/
class GH6531Order
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
- /** @OneToMany(targetEntity=GH6531OrderItem::class, mappedBy="order", cascade={"ALL"}) */
+ /**
+ * @psalm-var Collection
+ * @OneToMany(targetEntity=GH6531OrderItem::class, mappedBy="order", cascade={"ALL"})
+ */
public $items;
public function __construct()
@@ -167,7 +201,12 @@ public function addItem(GH6531Product $product, int $amount): void
*/
class GH6531Product
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
}
@@ -176,13 +215,23 @@ class GH6531Product
*/
class GH6531OrderItem
{
- /** @Id @ManyToOne(targetEntity=GH6531Order::class) */
+ /**
+ * @var GH6531Order
+ * @Id
+ * @ManyToOne(targetEntity=GH6531Order::class)
+ */
public $order;
- /** @Id @ManyToOne(targetEntity=GH6531Product::class) */
+ /**
+ * @var GH6531Product
+ * @Id @ManyToOne(targetEntity=GH6531Product::class)
+ */
public $product;
- /** @Column(type="integer") */
+ /**
+ * @var int
+ * @Column(type="integer")
+ */
public $amount = 1;
public function __construct(GH6531Order $order, GH6531Product $product, int $amount = 1)
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php
index f1f8309324a..4413abccea5 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php
@@ -4,8 +4,8 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
+use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
-use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\OrmFunctionalTestCase;
use function assert;
@@ -83,6 +83,7 @@ public function testMatchingKeepsOrderOfCriteriaOrderingKeys(): void
class GH7836ParentEntity
{
/**
+ * @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
@@ -90,6 +91,7 @@ class GH7836ParentEntity
private $id;
/**
+ * @var Collection
* @OneToMany(targetEntity=GH7836ChildEntity::class, mappedBy="parent", fetch="EXTRA_LAZY", cascade={"persist"})
* @OrderBy({"position" = "ASC", "name" = "ASC"})
*/
@@ -100,7 +102,10 @@ public function addChild(int $position, string $name): void
$this->children[] = new GH7836ChildEntity($this, $position, $name);
}
- public function getChildren(): PersistentCollection
+ /**
+ * @psalm-return Collection
+ */
+ public function getChildren(): Collection
{
return $this->children;
}
@@ -112,13 +117,17 @@ public function getChildren(): PersistentCollection
class GH7836ChildEntity
{
/**
+ * @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
private $id;
- /** @Column(type="integer") */
+ /**
+ * @var int
+ * @Column(type="integer")
+ */
public $position;
/**
@@ -127,7 +136,10 @@ class GH7836ChildEntity
*/
public $name;
- /** @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") */
+ /**
+ * @var GH7836ParentEntity
+ * @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children")
+ */
private $parent;
public function __construct(GH7836ParentEntity $parent, int $position, string $name)
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php
index e175aab2b4e..c3c92e960b3 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php
@@ -5,6 +5,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
use Doctrine\Tests\OrmFunctionalTestCase;
use function array_values;
@@ -63,7 +64,12 @@ public function testExtraLazyRemoveElement(): void
*/
class GH7864User
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
/**
@@ -72,7 +78,10 @@ class GH7864User
*/
public $name;
- /** @OneToMany(targetEntity="GH7864Tweet", mappedBy="user", fetch="EXTRA_LAZY") */
+ /**
+ * @var Collection
+ * @OneToMany(targetEntity="GH7864Tweet", mappedBy="user", fetch="EXTRA_LAZY")
+ */
public $tweets;
public function __construct()
@@ -92,7 +101,12 @@ public function addTweet(GH7864Tweet $tweet): void
*/
class GH7864Tweet
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
/**
@@ -101,6 +115,9 @@ class GH7864Tweet
*/
public $content;
- /** @ManyToOne(targetEntity="GH7864User", inversedBy="tweets") */
+ /**
+ * @var GH7864User
+ * @ManyToOne(targetEntity="GH7864User", inversedBy="tweets")
+ */
public $user;
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php
index 58beb5b5b80..ded3fa4ca00 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php
@@ -47,10 +47,18 @@ public function testDQLDeferredEagerLoad(): void
*/
class GH7869Appointment
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
- /** @OneToOne(targetEntity="GH7869Patient", inversedBy="appointment", fetch="EAGER") */
+ /**
+ * @var GH7869Patient
+ * @OneToOne(targetEntity="GH7869Patient", inversedBy="appointment", fetch="EAGER")
+ */
public $patient;
}
@@ -59,9 +67,17 @@ class GH7869Appointment
*/
class GH7869Patient
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
- /** @OneToOne(targetEntity="GH7869Appointment", mappedBy="patient") */
+ /**
+ * @var GH7869Appointment
+ * @OneToOne(targetEntity="GH7869Appointment", mappedBy="patient")
+ */
public $appointment;
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php
index e5bfc1a1fd5..c9044b4aa7f 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php
@@ -122,7 +122,12 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(?string $filterRegex, ?
*/
class GH7875MyEntity
{
- /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue(strategy="AUTO")
+ */
public $id;
}
@@ -132,6 +137,11 @@ class GH7875MyEntity
*/
class GH7875MyOtherEntity
{
- /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue(strategy="AUTO")
+ */
public $id;
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php
index 78c3ca2b8f8..04f7ee4bc89 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php
@@ -78,6 +78,7 @@ public function typesShouldBeConvertedForDQLFunctions(): void
class GH7941Product
{
/**
+ * @var int
* @Id
* @GeneratedValue
* @Column(type="integer")
@@ -90,10 +91,16 @@ class GH7941Product
*/
public $name;
- /** @Column(type="decimal") */
+ /**
+ * @var string
+ * @Column(type="decimal")
+ */
public $price;
- /** @Column(type="datetime_immutable") */
+ /**
+ * @var DateTimeImmutable
+ * @Column(type="datetime_immutable")
+ */
public $createdAt;
public function __construct(string $name, string $price)
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php
index b8443f30573..d841d9d3788 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php
@@ -49,6 +49,7 @@ public function testNumericDescriminatorColumn(): void
class GH8055BaseClass
{
/**
+ * @var int
* @Id @GeneratedValue
* @Column(type="integer")
*/
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php
index bbdd3c3b450..19836837638 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php
@@ -35,10 +35,18 @@ public function testConvertToPHPValueSQLForNewObjectExpression(): void
*/
final class GH8061Entity
{
- /** @Id @Column(type="integer") @GeneratedValue */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ * @GeneratedValue
+ */
public $id;
- /** @Column(type="GH8061Type") */
+ /**
+ * @var mixed
+ * @Column(type="GH8061Type")
+ */
public $field;
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php
index 301efa0e94e..ca323613b9f 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php
@@ -43,6 +43,7 @@ public function testEmptyInsert(): void
class Ticket2481Product
{
/**
+ * @var int
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php
index 9b53457d34c..b89a8c647e4 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php
@@ -45,6 +45,7 @@ public function testInstanceOf(): void
abstract class PersonTicket4646Abstract
{
/**
+ * @var int
* @Id()
* @GeneratedValue()
* @Column(type="integer")
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php
index aea0f5cd13c..4fae6d8bb0d 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php
@@ -50,6 +50,7 @@ public function testInstanceOf(): void
class PersonTicket4646MultiLevel
{
/**
+ * @var int
* @Id()
* @GeneratedValue()
* @Column(type="integer")
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php
index d592e15aa76..ee07f9771c8 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php
@@ -48,6 +48,7 @@ public function testInstanceOf(): void
class PersonTicket4646Parametric
{
/**
+ * @var int
* @Id()
* @GeneratedValue()
* @Column(type="integer")
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php
index cfa02b08c68..16f042fe8ad 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php
@@ -47,6 +47,7 @@ public function testInstanceOf(): void
class PersonTicket4646
{
/**
+ * @var int
* @Id()
* @GeneratedValue()
* @Column(type="integer")
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php
index d2412af78a6..feb12cd61c8 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php
@@ -53,13 +53,14 @@ public function testInstanceOf(): void
class PersonTicket4646Multiple
{
/**
+ * @var int
* @Id()
* @GeneratedValue()
* @Column(type="integer")
*/
private $id;
- public function getId()
+ public function getId(): int
{
return $this->id;
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php
index 057c0afeb51..9196eecaa52 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php
@@ -190,7 +190,7 @@ class Relation
private $id;
/**
- * @var Lemma
+ * @var Lemma|null
* @ManyToOne(targetEntity="Lemma", inversedBy="relations")
* @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id")
*/
@@ -223,7 +223,6 @@ public function getParent(): Phrase
public function removeParent(): void
{
if ($this->lemma !== null) {
- /** @var Lemma $phrase */
$lemma = $this->parent;
$this->parent = null;
$lemma->removeRelation($this);
@@ -253,7 +252,6 @@ public function getType(): RelationType
public function removeType(): void
{
if ($this->type !== null) {
- /** @var RelationType $phrase */
$type = $this->type;
$this->type = null;
$type->removeRelation($this);
diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php
index 21e262a9213..12b737bb13a 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php
@@ -19,7 +19,10 @@
class ArrayHydratorTest extends HydrationTestCase
{
- public function provideDataForUserEntityResult()
+ /**
+ * @psalm-return list
+ */
+ public function provideDataForUserEntityResult(): array
{
return [
[0],
@@ -54,7 +57,7 @@ public function testSimpleEntityQuery(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -98,7 +101,7 @@ public function testSimpleEntityWithScalarQuery($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -146,7 +149,7 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -193,7 +196,7 @@ public function testSimpleMultipleRootEntityQuery(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(4, count($result));
@@ -243,7 +246,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(4, count($result));
@@ -297,7 +300,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(4, count($result));
@@ -351,7 +354,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(4, count($result));
@@ -406,7 +409,7 @@ public function testMixedQueryNormalJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -470,7 +473,7 @@ public function testMixedQueryFetchJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -543,7 +546,7 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -657,7 +660,7 @@ public function testMixedQueryMultipleFetchJoin(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -796,7 +799,7 @@ public function testMixedQueryMultipleDeepMixedFetchJoin(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -910,7 +913,7 @@ public function testEntityQueryCustomResultSetOrder(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
@@ -973,7 +976,7 @@ public function testChainedJoinWithScalars($entityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(3, count($result));
@@ -1022,7 +1025,7 @@ public function testResultIteration(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$iterator = $hydrator->iterate($stmt, $rsm);
$rowNum = 0;
@@ -1067,7 +1070,7 @@ public function testResultIterationWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$iterator = $hydrator->iterate($stmt, $rsm);
$rowNum = 0;
@@ -1112,7 +1115,7 @@ public function testSkipUnknownColumns(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(1, count($result));
@@ -1163,7 +1166,7 @@ public function testMissingIdForRootEntity($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(4, count($result), 'Should hydrate four results.');
@@ -1213,7 +1216,7 @@ public function testIndexByAndMixedResult($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ArrayHydrator($this->_em);
+ $hydrator = new ArrayHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result));
diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php
index 6f8329fda06..8bdb6e21edb 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php
@@ -23,6 +23,9 @@ public function testCustomHydrator(): void
class CustomHydrator extends AbstractHydrator
{
+ /**
+ * {@inheritDoc}
+ */
protected function hydrateAllData()
{
return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
diff --git a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php
index 17e44527f27..0b3de7a1fe2 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php
@@ -4,28 +4,17 @@
namespace Doctrine\Tests\ORM\Hydration;
-use Doctrine\ORM\Query\ParserResult;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Tests\OrmTestCase;
class HydrationTestCase extends OrmTestCase
{
- protected $_em;
+ /** @var EntityManagerInterface */
+ protected $entityManager;
protected function setUp(): void
{
parent::setUp();
- $this->_em = $this->getTestEntityManager();
- }
-
- /** Helper method */
- protected function _createParserResult($resultSetMapping, $isMixedQuery = false)
- {
- $parserResult = new ParserResult();
- $parserResult->setResultSetMapping($resultSetMapping);
- //$parserResult->setDefaultQueryComponentAlias(key($queryComponents));
- //$parserResult->setTableAliasMap($tableToClassAliasMap);
- $parserResult->setMixedQuery($isMixedQuery);
-
- return $parserResult;
+ $this->entityManager = $this->getTestEntityManager();
}
}
diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
index e11d5cc1323..b440a24eecf 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
@@ -32,7 +32,10 @@
class ObjectHydratorTest extends HydrationTestCase
{
- public function provideDataForUserEntityResult()
+ /**
+ * @psalm-return list
+ */
+ public function provideDataForUserEntityResult(): array
{
return [
[0],
@@ -40,7 +43,10 @@ public function provideDataForUserEntityResult()
];
}
- public function provideDataForMultipleRootEntityResult()
+ /**
+ * @psalm-return list
+ */
+ public function provideDataForMultipleRootEntityResult(): array
{
return [
[0, 0],
@@ -50,7 +56,10 @@ public function provideDataForMultipleRootEntityResult()
];
}
- public function provideDataForProductEntityResult()
+ /**
+ * @psalm-return list
+ */
+ public function provideDataForProductEntityResult(): array
{
return [
[0],
@@ -82,7 +91,7 @@ public function testSimpleEntityQuery(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -121,7 +130,7 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -170,7 +179,7 @@ public function testSimpleMultipleRootEntityQuery(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(4, count($result));
@@ -224,7 +233,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(4, count($result));
@@ -285,7 +294,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(4, count($result));
@@ -346,7 +355,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(4, count($result));
@@ -408,7 +417,7 @@ public function testMixedQueryNormalJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -472,7 +481,7 @@ public function testMixedQueryFetchJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -552,7 +561,7 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -666,7 +675,7 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -796,7 +805,7 @@ public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -909,7 +918,7 @@ public function testEntityQueryCustomResultSetOrder(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -952,7 +961,7 @@ public function testSkipUnknownColumns(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(1, count($result));
@@ -985,7 +994,7 @@ public function testScalarQueryWithoutResultVariables($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1034,14 +1043,14 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void
->with($this->equalTo(ECommerceShipping::class), ['id' => 42])
->will($this->returnValue($proxyInstance));
- $this->_em->setProxyFactory($proxyFactory);
+ $this->entityManager->setProxyFactory($proxyFactory);
// configuring lazy loading
- $metadata = $this->_em->getClassMetadata(ECommerceProduct::class);
+ $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class);
$metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY;
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(1, count($result));
@@ -1083,14 +1092,14 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE
->with($this->equalTo(ECommerceShipping::class), ['id' => 42])
->will($this->returnValue($proxyInstance));
- $this->_em->setProxyFactory($proxyFactory);
+ $this->entityManager->setProxyFactory($proxyFactory);
// configuring lazy loading
- $metadata = $this->_em->getClassMetadata(ECommerceProduct::class);
+ $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class);
$metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY;
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(1, count($result));
@@ -1150,7 +1159,7 @@ public function testChainedJoinWithEmptyCollections(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1213,7 +1222,7 @@ public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1251,7 +1260,7 @@ public function testResultIteration(): void
],
];
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$iterableResult = $hydrator->iterate(
new HydratorMockStatement($resultSet),
@@ -1326,7 +1335,7 @@ public function testResultIterationWithAliasedUserEntity(): void
],
];
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$rowNum = 0;
$iterableResult = $hydrator->iterate(
new HydratorMockStatement($resultSet),
@@ -1490,7 +1499,7 @@ public function testManyToManyHydration(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1613,7 +1622,7 @@ public function testManyToManyHydrationWithAliasedUserEntity(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1671,7 +1680,7 @@ public function testMissingIdForRootEntity($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(4, count($result), 'Should hydrate four results.');
@@ -1741,7 +1750,7 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1795,7 +1804,7 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1837,7 +1846,7 @@ public function testIndexByAndMixedResult($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(2, count($result));
@@ -1871,7 +1880,7 @@ public function testIndexByScalarsOnly($userEntityKey): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
$this->assertEquals(
@@ -1905,7 +1914,7 @@ public function testMissingMetaMappingException(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$hydrator->hydrateAll($stmt, $rsm);
}
@@ -1938,7 +1947,7 @@ public function testMissingDiscriminatorColumnException(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$hydrator->hydrateAll($stmt, $rsm);
}
@@ -1966,7 +1975,7 @@ public function testInvalidDiscriminatorValueException(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$hydrator->hydrateAll($stmt, $rsm);
}
@@ -1987,7 +1996,7 @@ public function testFetchJoinCollectionValuedAssociationWithDefaultArrayValue():
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ObjectHydrator($this->_em);
+ $hydrator = new ObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertCount(1, $result);
diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php
index c4b8f11fd58..7d64b2d0311 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php
@@ -34,7 +34,7 @@ public function testNewHydrationSimpleEntityQuery(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ScalarHydrator($this->_em);
+ $hydrator = new ScalarHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
@@ -65,7 +65,7 @@ public function testHydrateScalarResults(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ScalarHydrator($this->_em);
+ $hydrator = new ScalarHydrator($this->entityManager);
self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm));
}
@@ -95,7 +95,7 @@ public function testSkipUnknownColumns(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new ScalarHydrator($this->_em);
+ $hydrator = new ScalarHydrator($this->entityManager);
self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm));
}
diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
index 023d3e8518f..52c31272806 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php
@@ -36,7 +36,7 @@ public function testMissingDiscriminatorColumnException(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new SimpleObjectHydrator($this->_em);
+ $hydrator = new SimpleObjectHydrator($this->entityManager);
$hydrator->hydrateAll($stmt, $rsm);
}
@@ -59,7 +59,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void
$expectedEntity->city = 'Cracow';
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new SimpleObjectHydrator($this->_em);
+ $hydrator = new SimpleObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals($result[0], $expectedEntity);
}
@@ -89,7 +89,7 @@ public function testInvalidDiscriminatorValueException(): void
];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new SimpleObjectHydrator($this->_em);
+ $hydrator = new SimpleObjectHydrator($this->entityManager);
$hydrator->hydrateAll($stmt, $rsm);
}
@@ -118,7 +118,7 @@ public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInherita
$expectedEntity->tags = ['tag1', 'tag2'];
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new SimpleObjectHydrator($this->_em);
+ $hydrator = new SimpleObjectHydrator($this->entityManager);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals($result[0], $expectedEntity);
}
diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
index 0d7dc1b380d..82d0b5161e9 100644
--- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
@@ -66,7 +66,7 @@ public function testHydrateSingleScalar($name, $resultSet): void
$rsm->addFieldResult('u', 'u__name', 'name');
$stmt = new HydratorMockStatement($resultSet);
- $hydrator = new SingleScalarHydrator($this->_em);
+ $hydrator = new SingleScalarHydrator($this->entityManager);
if ($name === 'result1') {
$result = $hydrator->hydrateAll($stmt, $rsm);
diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php
index 015ac665c3a..58b2670cf5a 100644
--- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php
@@ -61,15 +61,28 @@ public function testCorrectIdGeneration(): void
/** @Entity */
class AssignedSingleIdEntity
{
- /** @Id @Column(type="integer") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ */
public $myId;
}
/** @Entity */
class AssignedCompositeIdEntity
{
- /** @Id @Column(type="integer") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ */
public $myId1;
- /** @Id @Column(type="integer") */
+
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ */
public $myId2;
}
diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php
index 28b1a280557..be130235072 100644
--- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php
+++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php
@@ -123,8 +123,6 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void
*/
public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void
{
- /** @var ClassMetadata $metadata1 */
- /** @var ClassMetadata $metadata2 */
$metadata1 = $this->createMock(ClassMetadata::class);
$metadata2 = $this->createMock(ClassMetadata::class);
$entity1 = new stdClass();
@@ -179,7 +177,10 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi
$this->handler->hydrationComplete();
}
- public function invocationFlagProvider()
+ /**
+ * @psalm-return list
+ */
+ public function invocationFlagProvider(): array
{
return [
[ListenersInvoker::INVOKE_LISTENERS],
diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
index a21e0e22715..d30d99f32da 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php
@@ -243,18 +243,26 @@ class EntitySubClass extends TransientBaseClass
/** @MappedSuperclass */
class MappedSuperclassBase
{
- /** @Column(type="integer") */
+ /**
+ * @var int
+ * @Column(type="integer")
+ */
private $mapped1;
+
/**
* @var string
* @Column(type="string")
*/
private $mapped2;
+
/**
+ * @var MappedSuperclassRelated1
* @OneToOne(targetEntity="MappedSuperclassRelated1")
* @JoinColumn(name="related1_id", referencedColumnName="id")
*/
private $mappedRelated1;
+
+ /** @var mixed */
private $transient;
}
class MappedSuperclassRelated1
@@ -264,8 +272,13 @@ class MappedSuperclassRelated1
/** @Entity */
class EntitySubClass2 extends MappedSuperclassBase
{
- /** @Id @Column(type="integer") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ */
private $id;
+
/**
* @var string
* @Column(type="string")
@@ -297,8 +310,13 @@ class MappedSuperclassBaseIndex
/** @Entity @Table(uniqueConstraints={@UniqueConstraint(name="IDX_NAME_INDEX",columns={"name"})}) */
class EntityIndexSubClass extends MappedSuperclassBaseIndex
{
- /** @Id @Column(type="integer") */
+ /**
+ * @var int
+ * @Id
+ * @Column(type="integer")
+ */
private $id;
+
/**
* @var string
* @Column(type="string")
@@ -385,7 +403,10 @@ class SuperclassEntity extends SuperclassBase
abstract class SuperclassBase
{
/**
- * @Column(type="integer") @Id @GeneratedValue(strategy="SEQUENCE")
+ * @var int
+ * @Column(type="integer")
+ * @Id
+ * @GeneratedValue(strategy="SEQUENCE")
* @SequenceGenerator(sequenceName="foo", initialValue=10)
*/
public $id;
diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
index 4cd8434b25a..58898a89e9a 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php
@@ -44,12 +44,18 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
class LoadEventTestEntity
{
/**
+ * @var int
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
- /** @Column(type="string", length=255) */
+
+ /**
+ * @var string
+ * @Column(type="string", length=255)
+ */
private $name;
+ /** @var mixed */
private $about;
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
index b972d6bb443..dcead9095d1 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
@@ -1291,7 +1291,10 @@ public function testInlineEmbeddable(): void
*/
class DDC2700MappedSuperClass
{
- /** @Column */
+ /**
+ * @var mixed
+ * @Column
+ */
private $foo;
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
index 23e94563ab6..b6a6b1c1727 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
@@ -23,9 +23,11 @@
use function array_filter;
use function array_map;
+use function assert;
use function count;
use function glob;
use function in_array;
+use function is_array;
use function pathinfo;
use const DIRECTORY_SEPARATOR;
@@ -171,16 +173,20 @@ public function testValidateXmlSchema(string $xmlMappingFile): void
$this->assertTrue($dom->schemaValidate($xsdSchemaFile));
}
- public static function dataValidSchema()
+ /**
+ * @psalm-return list
+ */
+ public static function dataValidSchema(): array
{
$list = glob(__DIR__ . '/xml/*.xml');
$invalid = ['Doctrine.Tests.Models.DDC889.DDC889Class.dcm'];
+ assert(is_array($list));
- $list = array_filter($list, static function ($item) use ($invalid) {
+ $list = array_filter($list, static function (string $item) use ($invalid): bool {
return ! in_array(pathinfo($item, PATHINFO_FILENAME), $invalid);
});
- return array_map(static function ($item) {
+ return array_map(static function (string $item) {
return [$item];
}, $list);
}
@@ -229,6 +235,7 @@ public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses():
class CTI
{
+ /** @var int */
public $id;
}
@@ -244,9 +251,12 @@ class CTIBaz extends CTI
class XMLSLC
{
+ /** @var mixed */
public $foo;
}
+
class XMLSLCFoo
{
+ /** @var int */
public $id;
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
index ce5a6e97b46..53df0578b22 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
@@ -98,9 +98,12 @@ public function testDeprecation(): void
class DDC2069Entity
{
+ /** @var int */
public $id;
+ /** @var string */
public $name;
+ /** @var mixed */
public $value;
}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php
index 6f2cb73b445..46d2a25a2db 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php
@@ -5,7 +5,6 @@
use Doctrine\ORM\Mapping\ClassMetadata;
/** @var ClassMetadata $metadata */
-
$metadata->setPrimaryTable(
[
'name' => 'explicit_table',
diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php
index 7b3ccb8295c..ff318fd2079 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php
@@ -5,7 +5,6 @@
use Doctrine\ORM\Mapping\ClassMetadata;
/** @var ClassMetadata $metadata */
-
$metadata->setPrimaryTable(
['name' => 'implicit_schema.implicit_table']
);
diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php
index 8ace5f185b6..3683395cf39 100644
--- a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php
+++ b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php
@@ -15,6 +15,7 @@
use function microtime;
use function number_format;
use function printf;
+use function sprintf;
use function str_repeat;
use const PHP_EOL;
@@ -127,7 +128,7 @@ public function testQueryEntityWithCache(): void
$this->assertEquals(503, $this->countQuery($em));
}
- private function queryEntity(EntityManagerInterface $em, $label): void
+ private function queryEntity(EntityManagerInterface $em, string $label): void
{
$times = 100;
$size = 500;
@@ -136,7 +137,7 @@ private function queryEntity(EntityManagerInterface $em, $label): void
echo PHP_EOL . $label;
for ($i = 0; $i < $size; $i++) {
- $em->persist(new Country("Country $i"));
+ $em->persist(new Country(sprintf('Country %d', $i)));
}
$em->flush();
@@ -158,7 +159,7 @@ private function queryEntity(EntityManagerInterface $em, $label): void
printf("\n%s\n", str_repeat('-', 50));
}
- public function findEntityOneToMany(EntityManagerInterface $em, $label): void
+ public function findEntityOneToMany(EntityManagerInterface $em, string $label): void
{
$times = 50;
$size = 30;
@@ -173,7 +174,7 @@ public function findEntityOneToMany(EntityManagerInterface $em, $label): void
$em->flush();
for ($i = 0; $i < $size / 2; $i++) {
- $state = new State("State $i", $country);
+ $state = new State(sprintf('State %d', $i), $country);
$em->persist($state);
@@ -184,7 +185,7 @@ public function findEntityOneToMany(EntityManagerInterface $em, $label): void
foreach ($states as $key => $state) {
for ($i = 0; $i < $size; $i++) {
- $city = new City("City $key - $i", $state);
+ $city = new City(sprintf('City %s - %d', $key, $i), $state);
$em->persist($city);
@@ -225,7 +226,7 @@ private function findEntity(EntityManagerInterface $em, $label): void
echo PHP_EOL . $label;
for ($i = 0; $i < $size; $i++) {
- $country = new Country("Country $i");
+ $country = new Country(sprintf('Country %d', $i));
$em->persist($country);
@@ -250,7 +251,7 @@ private function findEntity(EntityManagerInterface $em, $label): void
printf("\n%s\n", str_repeat('-', 50));
}
- private function findAllEntity(EntityManagerInterface $em, $label): void
+ private function findAllEntity(EntityManagerInterface $em, string $label): void
{
$times = 100;
$size = 50;
@@ -260,7 +261,7 @@ private function findAllEntity(EntityManagerInterface $em, $label): void
echo PHP_EOL . $label;
for ($i = 0; $i < $size; $i++) {
- $em->persist(new Country("Country $i"));
+ $em->persist(new Country(sprintf('Country %d', $i)));
}
$em->flush();
diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
index 1397b1ce33b..576a1abcfed 100644
--- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
+++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php
@@ -15,22 +15,22 @@
class BasicEntityPersisterCompositeTypeParametersTest extends OrmTestCase
{
/** @var BasicEntityPersister */
- protected $_persister;
+ protected $persister;
/** @var EntityManager */
- protected $_em;
+ protected $entityManager;
protected function setUp(): void
{
parent::setUp();
- $this->_em = $this->getTestEntityManager();
+ $this->entityManager = $this->getTestEntityManager();
- $this->_em->getClassMetadata(Country::class);
- $this->_em->getClassMetadata(Admin1::class);
- $this->_em->getClassMetadata(Admin1AlternateName::class);
+ $this->entityManager->getClassMetadata(Country::class);
+ $this->entityManager->getClassMetadata(Admin1::class);
+ $this->entityManager->getClassMetadata(Admin1AlternateName::class);
- $this->_persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata(Admin1AlternateName::class));
+ $this->persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(Admin1AlternateName::class));
}
public function testExpandParametersWillExpandCompositeEntityKeys(): void
@@ -38,7 +38,7 @@ public function testExpandParametersWillExpandCompositeEntityKeys(): void
$country = new Country('IT', 'Italy');
$admin1 = new Admin1(10, 'Rome', $country);
- [$values, $types] = $this->_persister->expandParameters(['admin1' => $admin1]);
+ [$values, $types] = $this->persister->expandParameters(['admin1' => $admin1]);
$this->assertEquals(['integer', 'string'], $types);
$this->assertEquals([10, 'IT'], $values);
@@ -52,7 +52,7 @@ public function testExpandCriteriaParametersWillExpandCompositeEntityKeys(): voi
$criteria = Criteria::create();
$criteria->andWhere(Criteria::expr()->eq('admin1', $admin1));
- [$values, $types] = $this->_persister->expandCriteriaParameters($criteria);
+ [$values, $types] = $this->persister->expandCriteriaParameters($criteria);
$this->assertEquals(['integer', 'string'], $types);
$this->assertEquals([10, 'IT'], $values);
diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
index b59ede6eacc..d3c88654520 100644
--- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
+++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php
@@ -13,40 +13,40 @@
class BasicEntityPersisterCompositeTypeSqlTest extends OrmTestCase
{
/** @var BasicEntityPersister */
- protected $_persister;
+ protected $persister;
/** @var EntityManager */
- protected $_em;
+ protected $entityManager;
protected function setUp(): void
{
parent::setUp();
- $this->_em = $this->getTestEntityManager();
- $this->_persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata(Admin1AlternateName::class));
+ $this->entityManager = $this->getTestEntityManager();
+ $this->persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(Admin1AlternateName::class));
}
public function testSelectConditionStatementEq(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('admin1', 1, [], Comparison::EQ);
+ $statement = $this->persister->getSelectConditionStatementSQL('admin1', 1, [], Comparison::EQ);
$this->assertEquals('t0.admin1 = ? AND t0.country = ?', $statement);
}
public function testSelectConditionStatementEqNull(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::IS);
+ $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::IS);
$this->assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement);
}
public function testSelectConditionStatementNeqNull(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::NEQ);
+ $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::NEQ);
$this->assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement);
}
public function testSelectConditionStatementIn(): void
{
$this->expectException('Doctrine\ORM\ORMException');
- $this->_persister->getSelectConditionStatementSQL('admin1', [], [], Comparison::IN);
+ $this->persister->getSelectConditionStatementSQL('admin1', [], [], Comparison::IN);
}
}
diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
index c6d0c6634eb..2daf5bce2ef 100644
--- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
+++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php
@@ -18,10 +18,10 @@
class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase
{
/** @var BasicEntityPersister */
- protected $_persister;
+ protected $persister;
/** @var EntityManager */
- protected $_em;
+ protected $entityManager;
protected function setUp(): void
{
@@ -39,17 +39,17 @@ protected function setUp(): void
DBALType::addType('upper_case_string', '\Doctrine\Tests\DbalTypes\UpperCaseStringType');
}
- $this->_em = $this->getTestEntityManager();
+ $this->entityManager = $this->getTestEntityManager();
- $this->_persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata(CustomTypeParent::class));
+ $this->persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(CustomTypeParent::class));
}
public function testGetInsertSQLUsesTypeValuesSQL(): void
{
- $method = new ReflectionMethod($this->_persister, 'getInsertSQL');
+ $method = new ReflectionMethod($this->persister, 'getInsertSQL');
$method->setAccessible(true);
- $sql = $method->invoke($this->_persister);
+ $sql = $method->invoke($this->persister);
$this->assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql);
}
@@ -62,25 +62,25 @@ public function testUpdateUsesTypeValuesSQL(): void
$parent->customInteger = 1;
$parent->child = $child;
- $this->_em->getUnitOfWork()->registerManaged($parent, ['id' => 1], ['customInteger' => 0, 'child' => null]);
- $this->_em->getUnitOfWork()->registerManaged($child, ['id' => 1], []);
+ $this->entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], ['customInteger' => 0, 'child' => null]);
+ $this->entityManager->getUnitOfWork()->registerManaged($child, ['id' => 1], []);
- $this->_em->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1);
- $this->_em->getUnitOfWork()->propertyChanged($parent, 'child', null, $child);
+ $this->entityManager->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1);
+ $this->entityManager->getUnitOfWork()->propertyChanged($parent, 'child', null, $child);
- $this->_persister->update($parent);
+ $this->persister->update($parent);
- $executeUpdates = $this->_em->getConnection()->getExecuteUpdates();
+ $executeUpdates = $this->entityManager->getConnection()->getExecuteUpdates();
$this->assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeUpdates[0]['query']);
}
public function testGetSelectConditionSQLUsesTypeValuesSQL(): void
{
- $method = new ReflectionMethod($this->_persister, 'getSelectConditionSQL');
+ $method = new ReflectionMethod($this->persister, 'getSelectConditionSQL');
$method->setAccessible(true);
- $sql = $method->invoke($this->_persister, ['customInteger' => 1, 'child' => 1]);
+ $sql = $method->invoke($this->persister, ['customInteger' => 1, 'child' => 1]);
$this->assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql);
}
@@ -90,7 +90,7 @@ public function testGetSelectConditionSQLUsesTypeValuesSQL(): void
*/
public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): void
{
- $persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata(NonAlphaColumnsEntity::class));
+ $persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(NonAlphaColumnsEntity::class));
$method = new ReflectionMethod($persister, 'getSelectColumnsSQL');
$method->setAccessible(true);
@@ -102,19 +102,19 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi
*/
public function testSelectConditionStatementIsNull(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS);
+ $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS);
$this->assertEquals('test IS NULL', $statement);
}
public function testSelectConditionStatementEqNull(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('test', null, [], Comparison::EQ);
+ $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::EQ);
$this->assertEquals('test IS NULL', $statement);
}
public function testSelectConditionStatementNeqNull(): void
{
- $statement = $this->_persister->getSelectConditionStatementSQL('test', null, [], Comparison::NEQ);
+ $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::NEQ);
$this->assertEquals('test IS NOT NULL', $statement);
}
@@ -125,23 +125,23 @@ public function testSelectConditionStatementWithMultipleValuesContainingNull():
{
$this->assertEquals(
'(t0.id IN (?) OR t0.id IS NULL)',
- $this->_persister->getSelectConditionStatementSQL('id', [null])
+ $this->persister->getSelectConditionStatementSQL('id', [null])
);
$this->assertEquals(
'(t0.id IN (?) OR t0.id IS NULL)',
- $this->_persister->getSelectConditionStatementSQL('id', [null, 123])
+ $this->persister->getSelectConditionStatementSQL('id', [null, 123])
);
$this->assertEquals(
'(t0.id IN (?) OR t0.id IS NULL)',
- $this->_persister->getSelectConditionStatementSQL('id', [123, null])
+ $this->persister->getSelectConditionStatementSQL('id', [123, null])
);
}
public function testCountCondition(): void
{
- $persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata(NonAlphaColumnsEntity::class));
+ $persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(NonAlphaColumnsEntity::class));
// Using a criteria as array
$statement = $persister->getCountSQL(['value' => 'bar']);
@@ -155,6 +155,6 @@ public function testCountCondition(): void
public function testCountEntities(): void
{
- $this->assertEquals(0, $this->_persister->count());
+ $this->assertEquals(0, $this->persister->count());
}
}
diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
index 9a42cda11be..f4dd6a12e29 100644
--- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
+++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php
@@ -4,6 +4,7 @@
namespace Doctrine\Tests\ORM\Query;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsUser;
@@ -17,6 +18,7 @@
*/
class CustomTreeWalkersJoinTest extends OrmTestCase
{
+ /** @var EntityManagerInterface */
private $em;
protected function setUp(): void
@@ -24,7 +26,7 @@ protected function setUp(): void
$this->em = $this->getTestEntityManager();
}
- public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed): void
+ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfirmed): void
{
try {
$query = $this->em->createQuery($dqlToBeTested);
diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php
index 64729cc062a..95332788e6b 100644
--- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php
+++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php
@@ -7,6 +7,8 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\QueryException;
+use Doctrine\ORM\Query\SqlWalker;
+use Doctrine\ORM\Query\TreeWalker;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmTestCase;
@@ -30,7 +32,11 @@ protected function setUp(): void
$this->entityManager = $this->getTestEntityManager();
}
- public function generateSql($dqlToBeTested, $treeWalkers, $outputWalker)
+ /**
+ * @param list> $treeWalkers
+ * @param class-string|null $outputWalker
+ */
+ public function generateSql(string $dqlToBeTested, array $treeWalkers, ?string $outputWalker): string
{
$query = $this->entityManager->createQuery($dqlToBeTested);
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $treeWalkers)
@@ -43,8 +49,16 @@ public function generateSql($dqlToBeTested, $treeWalkers, $outputWalker)
return $query->getSql();
}
- public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed, $treeWalkers = [], $outputWalker = null): void
- {
+ /**
+ * @param list> $treeWalkers
+ * @param class-string|null $outputWalker
+ */
+ public function assertSqlGeneration(
+ string $dqlToBeTested,
+ string $sqlToBeConfirmed,
+ array $treeWalkers = [],
+ ?string $outputWalker = null
+ ): void {
try {
$this->assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker));
} catch (Exception $e) {
@@ -140,7 +154,8 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement):
$factors[] = $factor;
}
- if (($whereClause = $selectStatement->whereClause) !== null) {
+ $whereClause = $selectStatement->whereClause;
+ if ($whereClause !== null) {
// There is already a WHERE clause, so append the conditions
$condExpr = $whereClause->conditionalExpression;