Skip to content

Commit 5f8daa5

Browse files
committed
Migrate classes with the fewest changes to PHP 8
1 parent 601948b commit 5f8daa5

16 files changed

+27
-62
lines changed

lib/Doctrine/ORM/EntityNotFoundException.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ class EntityNotFoundException extends RuntimeException implements ORMException
1818
/**
1919
* Static constructor.
2020
*
21-
* @param string $className
2221
* @param string[] $id
23-
*
24-
* @return self
2522
*/
26-
public static function fromClassNameAndIdentifier($className, array $id)
23+
public static function fromClassNameAndIdentifier(string $className, array $id): self
2724
{
2825
$ids = [];
2926

lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
1717
{
1818
/**
1919
* Retrieve associated EntityManager.
20-
*
21-
* @return EntityManagerInterface
2220
*/
23-
public function getEntityManager()
21+
public function getEntityManager(): EntityManagerInterface
2422
{
2523
return $this->getObjectManager();
2624
}

lib/Doctrine/ORM/Event/OnFlushEventArgs.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class OnFlushEventArgs extends ManagerEventArgs
2121
* Retrieve associated EntityManager.
2222
*
2323
* @deprecated 2.13. Use {@see getObjectManager} instead.
24-
*
25-
* @return EntityManagerInterface
2624
*/
27-
public function getEntityManager()
25+
public function getEntityManager(): EntityManagerInterface
2826
{
2927
Deprecation::trigger(
3028
'doctrine/orm',

lib/Doctrine/ORM/Event/PostFlushEventArgs.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class PostFlushEventArgs extends ManagerEventArgs
2121
* Retrieves associated EntityManager.
2222
*
2323
* @deprecated 2.13. Use {@see getObjectManager} instead.
24-
*
25-
* @return EntityManagerInterface
2624
*/
27-
public function getEntityManager()
25+
public function getEntityManager(): EntityManagerInterface
2826
{
2927
Deprecation::trigger(
3028
'doctrine/orm',

lib/Doctrine/ORM/Event/PreFlushEventArgs.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
*/
1818
class PreFlushEventArgs extends ManagerEventArgs
1919
{
20-
/**
21-
* @deprecated 2.13. Use {@see getObjectManager} instead.
22-
*
23-
* @return EntityManagerInterface
24-
*/
25-
public function getEntityManager()
20+
/** @deprecated 2.13. Use {@see getObjectManager} instead. */
21+
public function getEntityManager(): EntityManagerInterface
2622
{
2723
Deprecation::trigger(
2824
'doctrine/orm',

lib/Doctrine/ORM/Event/PreUpdateEventArgs.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class PreUpdateEventArgs extends LifecycleEventArgs
1818
{
1919
/** @var array<string, array{mixed, mixed}|PersistentCollection> */
20-
private $entityChangeSet;
20+
private array $entityChangeSet;
2121

2222
/**
2323
* @param object $entity
@@ -37,31 +37,25 @@ public function __construct($entity, EntityManagerInterface $em, array &$changeS
3737
* @return mixed[][]
3838
* @psalm-return array<string, array{mixed, mixed}|PersistentCollection>
3939
*/
40-
public function getEntityChangeSet()
40+
public function getEntityChangeSet(): array
4141
{
4242
return $this->entityChangeSet;
4343
}
4444

4545
/**
4646
* Checks if field has a changeset.
47-
*
48-
* @param string $field
49-
*
50-
* @return bool
5147
*/
52-
public function hasChangedField($field)
48+
public function hasChangedField(string $field): bool
5349
{
5450
return isset($this->entityChangeSet[$field]);
5551
}
5652

5753
/**
5854
* Gets the old value of the changeset of the changed field.
5955
*
60-
* @param string $field
61-
*
6256
* @return mixed
6357
*/
64-
public function getOldValue($field)
58+
public function getOldValue(string $field)
6559
{
6660
$this->assertValidField($field);
6761

@@ -71,11 +65,9 @@ public function getOldValue($field)
7165
/**
7266
* Gets the new value of the changeset of the changed field.
7367
*
74-
* @param string $field
75-
*
7668
* @return mixed
7769
*/
78-
public function getNewValue($field)
70+
public function getNewValue(string $field)
7971
{
8072
$this->assertValidField($field);
8173

@@ -84,13 +76,8 @@ public function getNewValue($field)
8476

8577
/**
8678
* Sets the new value of this field.
87-
*
88-
* @param string $field
89-
* @param mixed $value
90-
*
91-
* @return void
9279
*/
93-
public function setNewValue($field, $value)
80+
public function setNewValue(string $field, mixed $value): void
9481
{
9582
$this->assertValidField($field);
9683

lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
final class EntityMissingAssignedId extends LogicException implements ORMException
1212
{
13-
/** @param object $entity */
14-
public static function forField($entity, string $field): self
13+
public static function forField(object $entity, string $field): self
1514
{
1615
return new self('Entity of type ' . get_debug_type($entity) . " is missing an assigned ID for field '" . $field . "'. " .
1716
'The identifier generation strategy for this entity requires the ID field to be populated before ' .

lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use function class_exists;
2121
use function constant;
2222
use function defined;
23-
use function get_class;
2423

2524
class AttributeDriver implements MappingDriver
2625
{
@@ -31,7 +30,7 @@ class AttributeDriver implements MappingDriver
3130
Mapping\MappedSuperclass::class => 2,
3231
];
3332

34-
private AttributeReader $reader;
33+
private readonly AttributeReader $reader;
3534

3635
/** @param array<string> $paths */
3736
public function __construct(array $paths)
@@ -46,7 +45,7 @@ public function isTransient(string $className): bool
4645

4746
foreach ($classAttributes as $a) {
4847
$attr = $a instanceof RepeatableAttributeCollection ? $a[0] : $a;
49-
if (isset(self::ENTITY_ATTRIBUTE_CLASSES[get_class($attr)])) {
48+
if (isset(self::ENTITY_ATTRIBUTE_CLASSES[$attr::class])) {
5049
return false;
5150
}
5251
}

lib/Doctrine/ORM/PessimisticLockException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
class PessimisticLockException extends RuntimeException implements ORMException
1111
{
12-
/** @return PessimisticLockException */
13-
public static function lockFailed()
12+
public static function lockFailed(): self
1413
{
1514
return new self('The pessimistic lock failed.');
1615
}

lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ public function __construct(SelectStatement $AST, SqlWalker $sqlWalker)
2323

2424
/**
2525
* {@inheritDoc}
26-
*
27-
* @return Result
2826
*/
29-
public function execute(Connection $conn, array $params, array $types)
27+
public function execute(Connection $conn, array $params, array $types): Result
3028
{
3129
return $conn->executeQuery($this->_sqlStatements, $params, $types, $this->queryCacheProfile);
3230
}

0 commit comments

Comments
 (0)