Skip to content

Commit

Permalink
Migrate files with the least changes to PHP 8
Browse files Browse the repository at this point in the history
These are the lowest hanging fruits I could find after running Rector: I
looked for files with a diff of 2 lines.
I did not include some changes that I find controversial, such as
marking some constants as final when we should maybe consider making
classes themselves final.
  • Loading branch information
greg0ire committed Jan 3, 2023
1 parent 8b1c353 commit 7e379f6
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setFileLockRegionDirectory(string $fileLockRegionDirectory): voi
$this->fileLockRegionDirectory = $fileLockRegionDirectory;
}

public function getFileLockRegionDirectory(): string
public function getFileLockRegionDirectory(): string|null
{
return $this->fileLockRegionDirectory;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected function getClassMetadata(): ClassMetadata
*
* @psalm-return AbstractLazyCollection<int, T>&Selectable<int, T>
*/
public function matching(Criteria $criteria): AbstractLazyCollection
public function matching(Criteria $criteria): AbstractLazyCollection&Selectable
{
$persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName);

Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ORM/Id/AssignedGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Exception\EntityMissingAssignedId;

use function get_class;

/**
* Special generator for application-assigned identifiers (doesn't really generate anything).
*/
Expand All @@ -23,7 +21,7 @@ class AssignedGenerator extends AbstractIdGenerator
*/
public function generateId(EntityManagerInterface $em, object|null $entity): array
{
$class = $em->getClassMetadata(get_class($entity));
$class = $em->getClassMetadata($entity::class);
$idFields = $class->getIdentifierFieldNames();
$identifier = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ObjectHydrator extends AbstractHydrator
private array $initializedCollections = [];

/** @var array<string, PersistentCollection> */
private $uninitializedCollections = [];
private array $uninitializedCollections = [];

/** @var mixed[] */
private array $existingCollections = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ChainTypedFieldMapper implements TypedFieldMapper
* @readonly
* @var TypedFieldMapper[] $typedFieldMappers
*/
private array $typedFieldMappers;
private readonly array $typedFieldMappers;

public function __construct(TypedFieldMapper ...$typedFieldMappers)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio

protected function getDriver(): MappingDriver
{
assert($this->driver !== null);

return $this->driver;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getPropertyAttributes(ReflectionProperty $property): array
*
* @template T of MappingAttribute
*/
public function getPropertyAttribute(ReflectionProperty $property, $attributeName)
public function getPropertyAttribute(ReflectionProperty $property, string $attributeName)
{
if ($this->isRepeatable($attributeName)) {
throw new LogicException(sprintf(
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Query/Filter/SQLFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query\ParameterTypeInferer;
use InvalidArgumentException;
use Stringable;

use function array_map;
use function implode;
Expand All @@ -23,7 +24,7 @@
*
* @abstract
*/
abstract class SQLFilter
abstract class SQLFilter implements Stringable
{
/**
* Parameters for the filter.
Expand Down

0 comments on commit 7e379f6

Please sign in to comment.