Skip to content

Commit

Permalink
Merge branch '2.14.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.14.x:
  Bump coding standard to v11 (doctrine#10295)
  PHPStan 1.9.3 (doctrine#10298)
  Rename AbstractCommandTest (doctrine#10294)
  • Loading branch information
derrabus committed Dec 13, 2022
2 parents 2bfcb6e + 9b14786 commit 8212ba8
Show file tree
Hide file tree
Showing 204 changed files with 393 additions and 99 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"symfony/console": "^5.4 || ^6.0"
},
"require-dev": {
"doctrine/coding-standard": "^10.0",
"doctrine/coding-standard": "^11.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "1.9.2",
"phpstan/phpstan": "1.9.3",
"phpunit/phpunit": "^9.5",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.1",
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/CollectionCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
ksort($ownerIdentifier);

$this->ownerIdentifier = $ownerIdentifier;

parent::__construct(str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association);
}
}
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Cache/EntityCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct(
ksort($identifier);

$this->identifier = $identifier;

parent::__construct(str_replace('\\', '.', strtolower($entityClass) . '_' . implode(' ', $identifier)));
}
}
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SimplifiedXmlDriver extends XmlDriver
public function __construct($prefixes, $fileExtension = self::DEFAULT_FILE_EXTENSION)
{
$locator = new SymfonyFileLocator((array) $prefixes, $fileExtension);

parent::__construct($locator, $fileExtension);
}
}
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ parameters:
message: '~^Match expression does not handle remaining values:~'
path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php

# https://github.com/phpstan/phpstan/issues/7292
-
message: '#^Offset class\-string on non\-empty\-array\<class\-string, array\<string, mixed\>\> in isset\(\) always exists and is not nullable\.$#'
path: lib/Doctrine/ORM/UnitOfWork.php

# DBAL 4 compatibility
-
message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~'
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/CMS/CmsAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
class CmsAddress
{
/** @var int */
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
public $id;

/** @var string */
Expand Down
19 changes: 14 additions & 5 deletions tests/Doctrine/Tests/Models/Cache/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,34 @@
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\ClassMetadata;

#[ORM\Entity, ORM\Table(name: 'cache_city'), ORM\Cache]
#[ORM\Entity]
#[ORM\Table(name: 'cache_city')]
#[ORM\Cache]
class City
{
/** @var int */
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
protected $id;

/** @var Collection<int, Travel> */
#[ORM\ManyToMany(targetEntity: 'Travel', mappedBy: 'visitedCities')]
public $travels;

/** @psalm-var Collection<int, Attraction> */
#[ORM\Cache, ORM\OrderBy(['name' => 'ASC'])]
#[ORM\Cache]
#[ORM\OrderBy(['name' => 'ASC'])]
#[ORM\OneToMany(targetEntity: 'Attraction', mappedBy: 'city')]
public $attractions;

public function __construct(
#[ORM\Column(unique: true)] protected string $name,
#[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'cities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected State|null $state = null,
#[ORM\Column(unique: true)]
protected string $name,
#[ORM\Cache]
#[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'cities')]
#[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')]
protected State|null $state = null,
) {
$this->travels = new ArrayCollection();
$this->attractions = new ArrayCollection();
Expand Down
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/Models/Company/CompanyContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;

#[ORM\Entity, ORM\Table(name: 'company_contracts')]
#[ORM\Entity]
#[ORM\Table(name: 'company_contracts')]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
#[ORM\DiscriminatorMap(['fix' => 'CompanyFixContract', 'flexible' => 'CompanyFlexContract', 'flexultra' => 'CompanyFlexUltraContract'])]
#[ORM\EntityListeners(['CompanyContractListener'])]
abstract class CompanyContract
{
#[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue]
private int $id;

#[ManyToOne(targetEntity: 'CompanyEmployee', inversedBy: 'soldContracts')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
class DDC1476EntityWithDefaultFieldType
{
/** @var int */
#[ORM\Id, ORM\Column, ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Id]
#[ORM\Column]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected $id;

/** @var string */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity, ORM\Table(name: 'explicit_table', schema: 'explicit_schema')]
#[ORM\Entity]
#[ORM\Table(name: 'explicit_table', schema: 'explicit_schema')]
class ExplicitSchemaAndTable
{
/** @var int */
#[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
public $id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
* Quoted column name to check that sequence names are
* correctly handled
*/
#[ORM\Entity, ORM\Table(name: 'implicit_schema.implicit_table')]
#[ORM\Entity]
#[ORM\Table(name: 'implicit_schema.implicit_table')]
class SchemaAndTableInTableName
{
/** @var int */
#[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
public $id;
}
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#[Entity]
class DDC3579Group
{
#[Id, GeneratedValue, Column(type: 'integer')]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer')]
#[GeneratedValue]
private int $id;

Expand All @@ -24,7 +26,8 @@ class DDC3579Group
private $admins;

public function __construct(
#[Column] private string|null $name = null,
#[Column]
private string|null $name = null,
) {
$this->admins = new ArrayCollection();
}
Expand Down
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
class DDC3579User
{
/** @var int */
#[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer', name: 'user_id', length: 150)]
protected $id;

/** @var ArrayCollection */
#[ManyToMany(targetEntity: DDC3579Group::class)]
protected $groups;

public function __construct(
#[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null,
#[Column(name: 'user_name', nullable: true, unique: false, length: 250)]
protected string|null $name = null,
) {
$this->groups = new ArrayCollection();
}
Expand Down
1 change: 1 addition & 0 deletions tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DDC3597Image extends DDC3597Media
public function __construct(string $distributionHash)
{
parent::__construct($distributionHash);

$this->dimension = new DDC3597Dimension();
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
class DDC5934BaseContract
{
/** @var int */
#[Id, Column, GeneratedValue]
#[Id]
#[Column]
#[GeneratedValue]
public $id;

/** @psalm-var Collection<int, DDC5934Member> */
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
class DDC869Payment
{
/** @var int */
#[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue]
protected $id;

/** @var float */
Expand Down
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/Models/DDC964/DDC964User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
class DDC964User
{
/** @var int */
#[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer', name: 'user_id', length: 150)]
protected $id;

/** @psalm-var Collection<int, DDC964Group> */
Expand All @@ -37,7 +39,8 @@ class DDC964User
protected $address;

public function __construct(
#[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null,
#[Column(name: 'user_name', nullable: true, unique: false, length: 250)]
protected string|null $name = null,
) {
$this->groups = new ArrayCollection();
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
class Card
{
/** @var int */
#[Id, GeneratedValue, Column(type: 'integer')]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer')]
public $id;

/** @var Suit */
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/CardWithDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#[Entity]
class CardWithDefault
{
#[Id, Column]
#[Id]
#[Column]
public string $id;

#[Column(options: ['default' => Suit::Hearts])]
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/CardWithNullable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
class CardWithNullable
{
/** @var int */
#[Id, GeneratedValue, Column(type: 'integer')]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer')]
public $id;

/** @var ?Suit */
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#[Entity]
class Product
{
#[Id, GeneratedValue, Column(type: 'integer')]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer')]
public int $id;

#[Embedded(class: Quantity::class)]
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/Scale.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
class Scale
{
/** @var int */
#[Id, GeneratedValue, Column(type: 'integer')]
#[Id]
#[GeneratedValue]
#[Column(type: 'integer')]
public $id;

/** @var Unit[] */
Expand Down
4 changes: 3 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/TypedCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#[Entity]
class TypedCard
{
#[Id, GeneratedValue, Column]
#[Id]
#[GeneratedValue]
#[Column]
public int $id;

#[Column]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#[Entity]
class TypedCardEnumCompositeId
{
#[Id, Column(type: 'string', enumType: Suit::class)]
#[Id]
#[Column(type: 'string', enumType: Suit::class)]
public Suit $suit;

#[Id, Column(type: 'string', enumType: Unit::class)]
#[Id]
#[Column(type: 'string', enumType: Unit::class)]
public Unit $unit;
}
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#[Entity]
class TypedCardEnumId
{
#[Id, Column(type: 'string', enumType: Suit::class)]
#[Id]
#[Column(type: 'string', enumType: Suit::class)]
public Suit $suit;
}
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Models/GH10132/Complex.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#[Entity]
class Complex
{
#[Id, Column(type: 'string', enumType: Suit::class)]
#[Id]
#[Column(type: 'string', enumType: Suit::class)]
protected Suit $type;

#[OneToMany(targetEntity: ComplexChild::class, mappedBy: 'complex', cascade: ['persist'])]
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Models/GH10132/ComplexChild.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class ComplexChild
#[JoinColumn(name: 'complexType', referencedColumnName: 'type', nullable: false)]
protected Complex $complex;

#[Id, Column(type: 'string', enumType: Suit::class)]
#[Id]
#[Column(type: 'string', enumType: Suit::class)]
protected Suit $complexType;

public function setComplex(Complex $complex): void
Expand Down
7 changes: 5 additions & 2 deletions tests/Doctrine/Tests/Models/ReadonlyProperties/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;

#[Entity, Table(name: 'author')]
#[Entity]
#[Table(name: 'author')]
class Author
{
#[Column, Id, GeneratedValue(strategy: 'IDENTITY')]
#[Column]
#[Id]
#[GeneratedValue(strategy: 'IDENTITY')]
private readonly int $id;

#[Column]
Expand Down
Loading

0 comments on commit 8212ba8

Please sign in to comment.