Skip to content

Commit

Permalink
Use typed properties where possible
Browse files Browse the repository at this point in the history
This includes:
- private properties
- public properties of final classes

protected properties must have the same type or lack thereof as their
parent.
  • Loading branch information
greg0ire committed Apr 4, 2022
1 parent b98f242 commit f5887f0
Show file tree
Hide file tree
Showing 54 changed files with 160 additions and 297 deletions.
5 changes: 2 additions & 3 deletions lib/Doctrine/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ abstract class AbstractMigration
/** @var AbstractPlatform */
protected $platform;

/** @var LoggerInterface */
private $logger;
private LoggerInterface $logger;

/** @var Query[] */
private $plannedSql = [];
private array $plannedSql = [];

public function __construct(Connection $connection, LoggerInterface $logger)
{
Expand Down
37 changes: 13 additions & 24 deletions lib/Doctrine/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,32 @@ final class Configuration
public const VERSIONS_ORGANIZATION_BY_YEAR_AND_MONTH = 'year_and_month';

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

/** @var string[] */
private $migrationClasses = [];
private array $migrationClasses = [];

/** @var bool */
private $migrationsAreOrganizedByYear = false;
private bool $migrationsAreOrganizedByYear = false;

/** @var bool */
private $migrationsAreOrganizedByYearAndMonth = false;
private bool $migrationsAreOrganizedByYearAndMonth = false;

/** @var string|null */
private $customTemplate;
private ?string $customTemplate = null;

/** @var bool */
private $isDryRun = false;
private bool $isDryRun = false;

/** @var bool */
private $allOrNothing = false;
private bool $allOrNothing = false;

/** @var bool */
private $transactional = true;
private bool $transactional = true;

/** @var string|null */
private $connectionName;
private ?string $connectionName = null;

/** @var string|null */
private $entityManagerName;
private ?string $entityManagerName = null;

/** @var bool */
private $checkDbPlatform = true;
private bool $checkDbPlatform = true;

/** @var MetadataStorageConfiguration */
private $metadataStorageConfiguration;
private ?MetadataStorageConfiguration $metadataStorageConfiguration = null;

/** @var bool */
private $frozen = false;
private bool $frozen = false;

public function freeze(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
final class ConfigurationFile implements ConnectionLoader
{
/** @var string */
private $filename;
private string $filename;

public function __construct(string $filename)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

final class ConnectionRegistryConnection implements ConnectionLoader
{
/** @var ConnectionRegistry */
private $registry;
private ConnectionRegistry $registry;

/** @var string|null */
private $defaultConnectionName;
private ?string $defaultConnectionName = null;

public static function withSimpleDefault(ConnectionRegistry $registry, ?string $connectionName = null): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

final class ExistingConnection implements ConnectionLoader
{
/** @var Connection */
private $connection;
private Connection $connection;

public function __construct(Connection $connection)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
final class ConfigurationFile implements EntityManagerLoader
{
/** @var string */
private $filename;
private string $filename;

public function __construct(string $filename)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

final class ExistingEntityManager implements EntityManagerLoader
{
/** @var EntityManagerInterface */
private $entityManager;
private EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

final class ManagerRegistryEntityManager implements EntityManagerLoader
{
/** @var ManagerRegistry */
private $registry;
private ManagerRegistry $registry;

/** @var string|null */
private $defaultManagerName;
private ?string $defaultManagerName = null;

public static function withSimpleDefault(ManagerRegistry $registry, ?string $managerName = null): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
final class ConfigurationArray implements ConfigurationLoader
{
/** @var array<string,mixed> */
private $configurations;
private array $configurations;

/**
* @param array<string,mixed> $configurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
final class ConfigurationFileWithFallback implements ConfigurationLoader
{
/** @var string|null */
private $file;
private ?string $file = null;

public function __construct(?string $file = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

final class ExistingConfiguration implements ConfigurationLoader
{
/** @var Configuration */
private $configurations;
private Configuration $configurations;

public function __construct(Configuration $configurations)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class FormattedFile extends ConfigurationFile
{
/** @var callable[] */
private $loaders = [];
private array $loaders = [];

private function setDefaultLoaders(): void
{
Expand Down
15 changes: 5 additions & 10 deletions lib/Doctrine/Migrations/DbalMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@
*/
class DbalMigrator implements Migrator
{
/** @var Stopwatch */
private $stopwatch;
private Stopwatch $stopwatch;

/** @var LoggerInterface */
private $logger;
private LoggerInterface $logger;

/** @var Executor */
private $executor;
private Executor $executor;

/** @var Connection */
private $connection;
private Connection $connection;

/** @var EventDispatcher */
private $dispatcher;
private EventDispatcher $dispatcher;

public function __construct(
Connection $connection,
Expand Down
25 changes: 9 additions & 16 deletions lib/Doctrine/Migrations/DependencyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,25 @@ class DependencyFactory
/** @psalm-var array<string, bool> */
private $inResolution = [];

/** @var Configuration */
private $configuration;
private ?Configuration $configuration = null;

/** @var object[]|callable[] */
private $dependencies = [];
private array $dependencies = [];

/** @var Connection */
private $connection;
private ?Connection $connection = null;

/** @var EntityManagerInterface|null */
private $em;
private ?EntityManagerInterface $em = null;

/** @var bool */
private $frozen = false;
private bool $frozen = false;

/** @var ConfigurationLoader */
private $configurationLoader;
private ConfigurationLoader $configurationLoader;

/** @var ConnectionLoader */
private $connectionLoader;
private ConnectionLoader $connectionLoader;

/** @var EntityManagerLoader|null */
private $emLoader;
private ?EntityManagerLoader $emLoader = null;

/** @var callable[] */
private $factories = [];
private array $factories = [];

public static function fromConnection(
ConfigurationLoader $configurationLoader,
Expand Down
9 changes: 3 additions & 6 deletions lib/Doctrine/Migrations/Event/MigrationsEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
*/
final class MigrationsEventArgs extends EventArgs
{
/** @var Connection */
private $connection;
private Connection $connection;

/** @var MigrationPlanList */
private $plan;
private MigrationPlanList $plan;

/** @var MigratorConfiguration */
private $migratorConfiguration;
private MigratorConfiguration $migratorConfiguration;

public function __construct(
Connection $connection,
Expand Down
9 changes: 3 additions & 6 deletions lib/Doctrine/Migrations/Event/MigrationsVersionEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
*/
final class MigrationsVersionEventArgs extends EventArgs
{
/** @var Connection */
private $connection;
private Connection $connection;

/** @var MigrationPlan */
private $plan;
private MigrationPlan $plan;

/** @var MigratorConfiguration */
private $migratorConfiguration;
private MigratorConfiguration $migratorConfiguration;

public function __construct(
Connection $connection,
Expand Down
6 changes: 2 additions & 4 deletions lib/Doctrine/Migrations/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class EventDispatcher
{
/** @var EventManager */
private $eventManager;
private EventManager $eventManager;

/** @var Connection */
private $connection;
private Connection $connection;

public function __construct(Connection $connection, EventManager $eventManager)
{
Expand Down
6 changes: 2 additions & 4 deletions lib/Doctrine/Migrations/FileQueryWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
*/
final class FileQueryWriter implements QueryWriter
{
/** @var FileBuilder */
private $migrationFileBuilder;
private FileBuilder $migrationFileBuilder;

/** @var LoggerInterface */
private $logger;
private LoggerInterface $logger;

public function __construct(
FileBuilder $migrationFileBuilder,
Expand Down
13 changes: 5 additions & 8 deletions lib/Doctrine/Migrations/FilesystemMigrationsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@
*/
class FilesystemMigrationsRepository implements MigrationsRepository
{
/** @var bool */
private $migrationsLoaded = false;
private bool $migrationsLoaded = false;

/** @var array<string, string> */
private $migrationDirectories;
private array $migrationDirectories;

/** @var MigrationFinder */
private $migrationFinder;
private MigrationFinder $migrationFinder;

/** @var MigrationFactory */
private $versionFactory;
private MigrationFactory $versionFactory;

/** @var AvailableMigration[] */
private $migrations = [];
private array $migrations = [];

/**
* @param string[] $classes
Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
final class RecursiveRegexFinder extends Finder
{
/** @var string */
private $pattern;
private string $pattern;

public function __construct(?string $pattern = null)
{
Expand Down
20 changes: 7 additions & 13 deletions lib/Doctrine/Migrations/Generator/DiffGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,20 @@
*/
class DiffGenerator
{
/** @var DBALConfiguration */
private $dbalConfiguration;
private DBALConfiguration $dbalConfiguration;

/** @var AbstractSchemaManager<AbstractPlatform> */
private $schemaManager;
private AbstractSchemaManager $schemaManager;

/** @var SchemaProvider */
private $schemaProvider;
private SchemaProvider $schemaProvider;

/** @var AbstractPlatform */
private $platform;
private AbstractPlatform $platform;

/** @var Generator */
private $migrationGenerator;
private Generator $migrationGenerator;

/** @var SqlGenerator */
private $migrationSqlGenerator;
private SqlGenerator $migrationSqlGenerator;

/** @var SchemaProvider */
private $emptySchemaProvider;
private SchemaProvider $emptySchemaProvider;

/**
* @param AbstractSchemaManager<AbstractPlatform> $schemaManager
Expand Down
6 changes: 2 additions & 4 deletions lib/Doctrine/Migrations/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ public function down(Schema $schema): void
TEMPLATE;

/** @var Configuration */
private $configuration;
private Configuration $configuration;

/** @var string|null */
private $template;
private ?string $template = null;

public function __construct(Configuration $configuration)
{
Expand Down
Loading

0 comments on commit f5887f0

Please sign in to comment.