Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS batch 7/an estimated 30 #8474

Merged
merged 4 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
9 changes: 9 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,13 @@
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">
<exclude-pattern>lib/Doctrine/ORM/Tools/EntityGenerator.php</exclude-pattern>
</rule>

<rule ref="Squiz.Commenting.FunctionComment.WrongStyle">
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/1961 -->
<exclude-pattern>tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.NoAssignment">
<exclude-pattern>tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests*</exclude-pattern>
</rule>
</ruleset>
78 changes: 44 additions & 34 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -30,38 +30,38 @@ 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));
}

/**
* @group DDC-1209
*/
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();

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,
]
)
);
Expand All @@ -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;
}
Expand All @@ -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")
*/
Expand All @@ -139,7 +149,7 @@ public function __construct()

class DateTime2 extends DateTime
{
public function __toString()
public function __toString(): string
{
return $this->format('Y');
}
Expand Down
73 changes: 61 additions & 12 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,7 +86,12 @@ public function testJoinTableWithMetadata(): void
*/
class GH6531User
{
/** @Id @Column(type="integer") @GeneratedValue */
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
}

Expand All @@ -94,7 +100,11 @@ class GH6531User
*/
class GH6531Address
{
/** @Id @OneToOne(targetEntity=GH6531User::class) */
/**
* @var GH6531User
* @Id
* @OneToOne(targetEntity=GH6531User::class)
*/
public $user;
}

Expand All @@ -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<string, GH6531ArticleAttribute>
* @OneToMany(targetEntity=GH6531ArticleAttribute::class, mappedBy="article", cascade={"ALL"}, indexBy="attribute")
* */
public $attributes;

public function addAttribute(string $name, string $value): void
Expand All @@ -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;

/**
Expand All @@ -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<int, GH6531OrderItem>
* @OneToMany(targetEntity=GH6531OrderItem::class, mappedBy="order", cascade={"ALL"})
*/
public $items;

public function __construct()
Expand All @@ -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;
}

Expand All @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,13 +83,15 @@ public function testMatchingKeepsOrderOfCriteriaOrderingKeys(): void
class GH7836ParentEntity
{
/**
* @var int
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
private $id;

/**
* @var Collection<int, GH7836ChildEntity>
* @OneToMany(targetEntity=GH7836ChildEntity::class, mappedBy="parent", fetch="EXTRA_LAZY", cascade={"persist"})
* @OrderBy({"position" = "ASC", "name" = "ASC"})
*/
Expand All @@ -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<int, GH7836ChildEntity>
*/
public function getChildren(): Collection
{
return $this->children;
}
Expand All @@ -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;

/**
Expand All @@ -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)
Expand Down
Loading