Skip to content

Commit 4fe224a

Browse files
committed
Migrate ClassMetadata to PHP 8 syntax
1 parent 7036485 commit 4fe224a

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

lib/Doctrine/ORM/Mapping/ClassMetadata.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable
766766

767767
private InstantiatorInterface|null $instantiator = null;
768768

769-
private TypedFieldMapper $typedFieldMapper;
769+
private readonly TypedFieldMapper $typedFieldMapper;
770770

771771
/**
772772
* Initializes a new ClassMetadata instance that will hold the object-relational mapping
@@ -1162,7 +1162,7 @@ public function validateLifecycleCallbacks(ReflectionService $reflService): void
11621162
*
11631163
* Can return null when using static reflection, in violation of the LSP
11641164
*/
1165-
public function getReflectionClass()
1165+
public function getReflectionClass(): ReflectionClass|null
11661166
{
11671167
return $this->reflClass;
11681168
}
@@ -1486,7 +1486,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): array
14861486
*
14871487
* @throws MappingException If something is wrong with the mapping.
14881488
*/
1489-
protected function _validateAndCompleteAssociationMapping(array $mapping)
1489+
protected function _validateAndCompleteAssociationMapping(array $mapping): array
14901490
{
14911491
if (! isset($mapping['mappedBy'])) {
14921492
$mapping['mappedBy'] = null;
@@ -1640,7 +1640,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping)
16401640
* @throws RuntimeException
16411641
* @throws MappingException
16421642
*/
1643-
protected function _validateAndCompleteOneToOneMapping(array $mapping)
1643+
protected function _validateAndCompleteOneToOneMapping(array $mapping): array
16441644
{
16451645
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
16461646

@@ -1745,7 +1745,7 @@ protected function _validateAndCompleteOneToOneMapping(array $mapping)
17451745
* @throws MappingException
17461746
* @throws InvalidArgumentException
17471747
*/
1748-
protected function _validateAndCompleteOneToManyMapping(array $mapping)
1748+
protected function _validateAndCompleteOneToManyMapping(array $mapping): array
17491749
{
17501750
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
17511751

@@ -1795,7 +1795,7 @@ protected function _validateAndCompleteOneToManyMapping(array $mapping)
17951795
*
17961796
* @throws InvalidArgumentException
17971797
*/
1798-
protected function _validateAndCompleteManyToManyMapping(array $mapping)
1798+
protected function _validateAndCompleteManyToManyMapping(array $mapping): array
17991799
{
18001800
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
18011801

@@ -1970,7 +1970,7 @@ public function getColumnNames(array|null $fieldNames = null): array
19701970
return array_keys($this->fieldNames);
19711971
}
19721972

1973-
return array_values(array_map([$this, 'getColumnName'], $fieldNames));
1973+
return array_values(array_map($this->getColumnName(...), $fieldNames));
19741974
}
19751975

19761976
/**

phpstan-baseline.neon

-5
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ parameters:
145145
count: 2
146146
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
147147

148-
-
149-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
150-
count: 1
151-
path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php
152-
153148
-
154149
message: "#^Empty array passed to foreach\\.$#"
155150
count: 1

psalm-baseline.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
<code>$overrideMapping</code>
332332
</InvalidArgument>
333333
<InvalidNullableReturnType>
334-
<code>getReflectionClass</code>
334+
<code>ReflectionClass|null</code>
335335
<code>string</code>
336336
</InvalidNullableReturnType>
337337
<InvalidPropertyAssignmentValue>

0 commit comments

Comments
 (0)