Skip to content

Commit

Permalink
upgraded to Doctrine coding standard v12
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Aug 3, 2023
1 parent 63a7e3e commit af60a93
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 148 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@
"symfony/var-dumper": "^5.4.26 || ^6.3.2"
},
"require-dev": {
"doctrine/coding-standard": "^9.0.2",
"doctrine/coding-standard": "^12.0.0",
"doctrine/persistence": "^2.5.7 || ^3.2.0",
"jangregor/phpstan-prophecy": "^1.0.0",
"laminas/laminas-developer-tools": "^2.8.0",
"laminas/laminas-hydrator": "^4.13.0",
"laminas/laminas-session": "^2.16.0",
"phpspec/prophecy-phpunit": "^2.0.2",
"phpstan/phpstan": "^1.9.1",
"phpunit/phpunit": "^9.5.26",
"phpstan/phpstan": "^1.10.26",
"phpunit/phpunit": "^9.6.10",
"vimeo/psalm": "^4.30.0"
},
"suggest": {
Expand Down
12 changes: 2 additions & 10 deletions src/Collector/MongoLoggerCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ class MongoLoggerCollector implements CollectorInterface, AutoHideInterface
*/
public const PRIORITY = 10;

protected DebugStack $mongoLogger;

protected string $name;

public function __construct(DebugStack $mongoLogger, string $name)
public function __construct(protected DebugStack $mongoLogger, protected string $name)
{
$this->mongoLogger = $mongoLogger;
$this->name = $name;
}

public function getName(): string
Expand All @@ -58,9 +52,7 @@ public function getQueryCount(): int
return count($this->mongoLogger->queries);
}

/**
* @return mixed[]
*/
/** @return mixed[] */
public function getQueries(): array
{
return $this->mongoLogger->queries;
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/EchoLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function commandStarted(CommandStartedEvent $event): void
[
'command' => $event->getCommand(),
'db' => $event->getDatabaseName(),
]
],
);
}

Expand Down
16 changes: 6 additions & 10 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function init(ModuleManagerInterface $manager): void
throw new InvalidArgumentException(sprintf(
'Expected %s, but received %s.',
ModuleManager::class,
$manager::class
$manager::class,
));
}

Expand Down Expand Up @@ -64,8 +64,8 @@ public function loadCli(EventInterface $event): void
'documentmanager',
null,
InputOption::VALUE_OPTIONAL,
'The name of the documentmanager to use. If none is provided, it will use odm_default.'
)
'The name of the documentmanager to use. If none is provided, it will use odm_default.',
),
);
}

Expand All @@ -74,7 +74,7 @@ public function loadCli(EventInterface $event): void
throw new InvalidArgumentException(sprintf(
'Expected %s as event target, received %s.',
Application::class,
$cli::class
$cli::class,
));
}

Expand All @@ -89,17 +89,13 @@ public function loadCli(EventInterface $event): void
$cli->getHelperSet()->set($documentHelper, 'dm');
}

/**
* @return array<array-key,mixed>
*/
/** @return array<array-key,mixed> */
public function getConfig(): array
{
return include __DIR__ . '/../config/module.config.php';
}

/**
* @return array<array-key,mixed>
*/
/** @return array<array-key,mixed> */
public function getServiceConfig(): array
{
return [
Expand Down
78 changes: 29 additions & 49 deletions src/Options/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ final class Configuration extends AbstractOptions
/**
* Persistent collection factory service name.
*/
protected ?string $persistentCollectionFactory = null;
protected string|null $persistentCollectionFactory = null;

/**
* Persistent collection generator service name.
*/
protected ?string $persistentCollectionGenerator = null;
protected string|null $persistentCollectionGenerator = null;

protected ?string $driver = null;
protected string|null $driver = null;

protected ?string $defaultDb = null;
protected string|null $defaultDb = null;

/**
* An array of filters. Array should be in the form
Expand All @@ -96,11 +96,11 @@ final class Configuration extends AbstractOptions
/**
* service name of the Logger
*/
protected ?string $logger = null;
protected string|null $logger = null;

protected ?string $classMetadataFactoryName = null;
protected string|null $classMetadataFactoryName = null;

protected ?string $repositoryFactory = null;
protected string|null $repositoryFactory = null;

protected string $defaultDocumentRepositoryClassName = DefaultDocumentRepository::class;

Expand All @@ -124,19 +124,15 @@ public function getDriver(): string
return 'doctrine.driver.' . $this->driver;
}

/**
* @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateProxies
*/
/** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateProxies */
public function setGenerateProxies(int $generateProxies): self
{
$this->generateProxies = $generateProxies;

return $this;
}

/**
* @psalm-return MongoDbConfiguration::AUTOGENERATE_*
*/
/** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */
public function getGenerateProxies(): int
{
return $this->generateProxies;
Expand Down Expand Up @@ -178,17 +174,13 @@ public function getProxyNamespace(): string
return $this->proxyNamespace;
}

/**
* @psalm-return MongoDbConfiguration::AUTOGENERATE_*
*/
/** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */
public function getGenerateHydrators(): int
{
return $this->generateHydrators;
}

/**
* @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateHydrators
*/
/** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateHydrators */
public function setGenerateHydrators(int $generateHydrators): self
{
$this->generateHydrators = $generateHydrators;
Expand Down Expand Up @@ -220,17 +212,13 @@ public function setHydratorNamespace(string $hydratorNamespace): self
return $this;
}

/**
* @psalm-return MongoDbConfiguration::AUTOGENERATE_*
*/
/** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */
public function getGeneratePersistentCollections(): int
{
return $this->generatePersistentCollections;
}

/**
* @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generatePersistentCollections
*/
/** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generatePersistentCollections */
public function setGeneratePersistentCollections(int $generatePersistentCollections): self
{
$this->generatePersistentCollections = (int) $generatePersistentCollections;
Expand Down Expand Up @@ -262,104 +250,96 @@ public function setPersistentCollectionNamespace(string $persistentCollectionNam
return $this;
}

public function getPersistentCollectionFactory(): ?string
public function getPersistentCollectionFactory(): string|null
{
return $this->persistentCollectionFactory;
}

public function setPersistentCollectionFactory(?string $persistentCollectionFactory): self
public function setPersistentCollectionFactory(string|null $persistentCollectionFactory): self
{
$this->persistentCollectionFactory = $persistentCollectionFactory;

return $this;
}

public function getPersistentCollectionGenerator(): ?string
public function getPersistentCollectionGenerator(): string|null
{
return $this->persistentCollectionGenerator;
}

public function setPersistentCollectionGenerator(?string $persistentCollectionGenerator): self
public function setPersistentCollectionGenerator(string|null $persistentCollectionGenerator): self
{
$this->persistentCollectionGenerator = (string) $persistentCollectionGenerator;

return $this;
}

public function getDefaultDb(): ?string
public function getDefaultDb(): string|null
{
return $this->defaultDb;
}

public function setDefaultDb(?string $defaultDb): self
public function setDefaultDb(string|null $defaultDb): self
{
$this->defaultDb = $defaultDb;

return $this;
}

/**
* @return mixed[]
*/
/** @return mixed[] */
public function getFilters(): array
{
return $this->filters;
}

/**
* @param mixed[] $filters
*/
/** @param mixed[] $filters */
public function setFilters(array $filters): self
{
$this->filters = $filters;

return $this;
}

public function setLogger(?string $logger): self
public function setLogger(string|null $logger): self
{
$this->logger = $logger;

return $this;
}

public function getLogger(): ?string
public function getLogger(): string|null
{
return $this->logger;
}

public function getClassMetadataFactoryName(): ?string
public function getClassMetadataFactoryName(): string|null
{
return $this->classMetadataFactoryName;
}

public function setClassMetadataFactoryName(?string $classMetadataFactoryName): void
public function setClassMetadataFactoryName(string|null $classMetadataFactoryName): void
{
$this->classMetadataFactoryName = (string) $classMetadataFactoryName;
}

/**
* @param mixed[] $types
*/
/** @param mixed[] $types */
public function setTypes(array $types): void
{
$this->types = $types;
}

/**
* @return mixed[]
*/
/** @return mixed[] */
public function getTypes(): array
{
return $this->types;
}

public function getRepositoryFactory(): ?string
public function getRepositoryFactory(): string|null
{
return $this->repositoryFactory;
}

public function setRepositoryFactory(?string $repositoryFactory): Configuration
public function setRepositoryFactory(string|null $repositoryFactory): Configuration
{
$this->repositoryFactory = (string) $repositoryFactory;

Expand Down
Loading

0 comments on commit af60a93

Please sign in to comment.