diff --git a/.github/workflows/ci-2.x.yml b/.github/workflows/ci-2.x.yml
index 513dfa82..e5c69ddf 100644
--- a/.github/workflows/ci-2.x.yml
+++ b/.github/workflows/ci-2.x.yml
@@ -30,11 +30,7 @@ jobs:
run: composer install --no-progress --ansi --working-dir=tools/php-cs-fixer
- name: Run PHP-CS-Fixer
- run: |
- sed -i "s/'phpdoc_to_return_type' => true/'phpdoc_to_return_type' => false/g" .php-cs-fixer.php
- sed -i "s/'phpdoc_to_param_type' => true/'phpdoc_to_param_type' => false/g" .php-cs-fixer.php
- sed -i "s/'phpdoc_to_property_type' => true/'phpdoc_to_property_type' => false/g" .php-cs-fixer.php
- composer cs-check
+ run: composer cs-check
- name: Validate composer
run: composer validate --strict --no-check-lock
diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index 6f222d30..f8217009 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -33,9 +33,10 @@
'php_unit_size_class' => true,
'php_unit_test_class_requires_covers' => false,
'phpdoc_types' => true,
- 'phpdoc_to_param_type' => true,
- 'phpdoc_to_property_type' => true,
- 'phpdoc_to_return_type' => true,
+ 'phpdoc_to_param_type' => false,
+ 'phpdoc_to_property_type' => false,
+ 'phpdoc_to_return_type' => false,
+ 'new_with_parentheses' => false,
'regular_callable_call' => true,
'self_static_accessor' => true,
'simplified_if_return' => true,
diff --git a/src/Auditor.php b/src/Auditor.php
index d2ef719d..21378788 100644
--- a/src/Auditor.php
+++ b/src/Auditor.php
@@ -71,7 +71,7 @@ public function getProviders(): array
public function getProvider(string $name): ProviderInterface
{
if (!$this->hasProvider($name)) {
- throw new InvalidArgumentException(sprintf('Unknown provider "%s"', $name));
+ throw new InvalidArgumentException(\sprintf('Unknown provider "%s"', $name));
}
return $this->providers[$name];
@@ -88,7 +88,7 @@ public function hasProvider(string $name): bool
public function registerProvider(ProviderInterface $provider): self
{
if (!$provider->supportsStorage() && !$provider->supportsAuditing()) {
- throw new ProviderException(sprintf('Provider "%s" does not support storage and auditing.', \get_class($provider)));
+ throw new ProviderException(\sprintf('Provider "%s" does not support storage and auditing.', \get_class($provider)));
}
$this->providers[\get_class($provider)] = $provider;
@@ -111,7 +111,7 @@ public function registerProvider(ProviderInterface $provider): self
public function enableStorage(ProviderInterface $provider): self
{
if (!$provider->supportsStorage()) {
- throw new ProviderException(sprintf('Provider "%s" does not support storage.', \get_class($provider)));
+ throw new ProviderException(\sprintf('Provider "%s" does not support storage.', \get_class($provider)));
}
$this->storageProviders[\get_class($provider)] = $provider;
@@ -125,7 +125,7 @@ public function enableStorage(ProviderInterface $provider): self
public function disableStorage(ProviderInterface $provider): self
{
if (!$provider->supportsStorage()) {
- throw new ProviderException(sprintf('Provider "%s" does not support storage.', \get_class($provider)));
+ throw new ProviderException(\sprintf('Provider "%s" does not support storage.', \get_class($provider)));
}
if (1 === \count($this->storageProviders)) {
@@ -144,7 +144,7 @@ public function isStorageEnabled(ProviderInterface $provider): bool
{
$key = \get_class($provider);
if (!$this->hasProvider($key)) {
- throw new InvalidArgumentException(sprintf('Unknown provider "%s"', $key));
+ throw new InvalidArgumentException(\sprintf('Unknown provider "%s"', $key));
}
return \array_key_exists($key, $this->storageProviders);
@@ -156,7 +156,7 @@ public function isStorageEnabled(ProviderInterface $provider): bool
public function enableAuditing(ProviderInterface $provider): self
{
if (!$provider->supportsAuditing()) {
- throw new ProviderException(sprintf('Provider "%s" does not support audit hooks.', \get_class($provider)));
+ throw new ProviderException(\sprintf('Provider "%s" does not support audit hooks.', \get_class($provider)));
}
$this->auditProviders[\get_class($provider)] = $provider;
@@ -170,7 +170,7 @@ public function enableAuditing(ProviderInterface $provider): self
public function disableAuditing(ProviderInterface $provider): self
{
if (!$provider->supportsAuditing()) {
- throw new ProviderException(sprintf('Provider "%s" does not support audit hooks.', \get_class($provider)));
+ throw new ProviderException(\sprintf('Provider "%s" does not support audit hooks.', \get_class($provider)));
}
if (1 === \count($this->auditProviders)) {
@@ -189,7 +189,7 @@ public function isAuditingEnabled(ProviderInterface $provider): bool
{
$key = \get_class($provider);
if (!$this->hasProvider($key)) {
- throw new InvalidArgumentException(sprintf('Unknown provider "%s"', $key));
+ throw new InvalidArgumentException(\sprintf('Unknown provider "%s"', $key));
}
return \array_key_exists($key, $this->auditProviders);
diff --git a/src/Provider/AbstractProvider.php b/src/Provider/AbstractProvider.php
index 95b2d3e2..8ecab9fc 100644
--- a/src/Provider/AbstractProvider.php
+++ b/src/Provider/AbstractProvider.php
@@ -58,7 +58,7 @@ public function registerStorageService(StorageServiceInterface $service): Provid
}
if (\array_key_exists($service->getName(), $this->storageServices)) {
- throw new ProviderException(sprintf('A storage service named "%s" is already registered.', $service->getName()));
+ throw new ProviderException(\sprintf('A storage service named "%s" is already registered.', $service->getName()));
}
$this->storageServices[$service->getName()] = $service;
@@ -80,7 +80,7 @@ public function registerAuditingService(AuditingServiceInterface $service): Prov
}
if (\array_key_exists($service->getName(), $this->auditingServices)) {
- throw new ProviderException(sprintf('An auditing service named "%s" is already registered.', $service->getName()));
+ throw new ProviderException(\sprintf('An auditing service named "%s" is already registered.', $service->getName()));
}
$this->auditingServices[$service->getName()] = $service;
diff --git a/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php b/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php
index 6e76f361..52d5c6e7 100644
--- a/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php
+++ b/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php
@@ -33,7 +33,7 @@ private function id(EntityManagerInterface $entityManager, object $entity)
try {
$pk = $meta->getSingleIdentifierFieldName();
} catch (ORMMappingException $e) {
- throw new MappingException(sprintf('Composite primary keys are not supported (%s).', \get_class($entity)));
+ throw new MappingException(\sprintf('Composite primary keys are not supported (%s).', \get_class($entity)));
}
if (isset($meta->fieldMappings[$pk])) {
diff --git a/src/Provider/Doctrine/DoctrineProvider.php b/src/Provider/Doctrine/DoctrineProvider.php
index 1fe95f14..f5a82385 100644
--- a/src/Provider/Doctrine/DoctrineProvider.php
+++ b/src/Provider/Doctrine/DoctrineProvider.php
@@ -75,7 +75,7 @@ public function getAuditingServiceForEntity(string $entity): AuditingServiceInte
}
}
- throw new InvalidArgumentException(sprintf('Auditing service not found for "%s".', $entity));
+ throw new InvalidArgumentException(\sprintf('Auditing service not found for "%s".', $entity));
}
public function getStorageServiceForEntity(string $entity): StorageServiceInterface
@@ -120,7 +120,7 @@ public function persist(LifecycleEvent $event): void
'created_at' => ':created_at',
];
- $query = sprintf(
+ $query = \sprintf(
'INSERT INTO %s (%s) VALUES (%s)',
$auditTable,
implode(', ', array_keys($fields)),
diff --git a/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php b/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php
index 10a306fd..dd510ac6 100644
--- a/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php
+++ b/src/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommand.php
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$count += \count($entities);
}
- $message = sprintf(
+ $message = \sprintf(
"You are about to clean audits created before %s: %d classes involved.\n Do you want to proceed?",
$until->format(self::UNTIL_DATE_FORMAT),
$count
@@ -173,7 +173,7 @@ private function validateKeepArgument(string $keep, SymfonyStyle $io): ?DateTime
try {
$dateInterval = new DateInterval($keep);
} catch (Exception $e) {
- $io->error(sprintf("'keep' argument must be a valid ISO 8601 date interval, '%s' given.", (string) $keep));
+ $io->error(\sprintf("'keep' argument must be a valid ISO 8601 date interval, '%s' given.", (string) $keep));
$this->release();
return null;
diff --git a/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php b/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php
index 189e9dc2..f0afa804 100644
--- a/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php
+++ b/src/Provider/Doctrine/Persistence/Command/UpdateSchemaCommand.php
@@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($sqls as $name => $queries) {
foreach ($queries as $index => $sql) {
- $io->text(sprintf(' %s;', $sql));
+ $io->text(\sprintf(' %s;', $sql));
}
}
}
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$pluralization = (1 === $count) ? 'query was' : 'queries were';
- $io->text(sprintf(' %s %s executed', $count, $pluralization));
+ $io->text(\sprintf(' %s %s executed', $count, $pluralization));
$io->success('Database schema updated successfully!');
}
@@ -121,12 +121,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->caution('This operation should not be executed in a production environment!');
$io->text(
[
- sprintf('The Schema-Tool would execute "%s" queries to update the database.', $count),
+ \sprintf('The Schema-Tool would execute "%s" queries to update the database.', $count),
'',
'Please run the operation by passing one - or both - of the following options:',
'',
- sprintf(' %s --force to execute the command', $this->getName()),
- sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()),
+ \sprintf(' %s --force to execute the command', $this->getName()),
+ \sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()),
]
);
diff --git a/src/Provider/Doctrine/Persistence/Event/CreateSchemaListener.php b/src/Provider/Doctrine/Persistence/Event/CreateSchemaListener.php
index a574a351..41b132dd 100644
--- a/src/Provider/Doctrine/Persistence/Event/CreateSchemaListener.php
+++ b/src/Provider/Doctrine/Persistence/Event/CreateSchemaListener.php
@@ -37,7 +37,7 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
ClassMetadataInfo::INHERITANCE_TYPE_JOINED,
ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE,
], true)) {
- throw new Exception(sprintf('Inheritance type "%s" is not yet supported', $metadata->inheritanceType));
+ throw new Exception(\sprintf('Inheritance type "%s" is not yet supported', $metadata->inheritanceType));
}
$targetEntity = $metadata->name;
diff --git a/src/Provider/Doctrine/Persistence/Helper/DoctrineHelper.php b/src/Provider/Doctrine/Persistence/Helper/DoctrineHelper.php
index 1d56d4ba..fdf8645e 100644
--- a/src/Provider/Doctrine/Persistence/Helper/DoctrineHelper.php
+++ b/src/Provider/Doctrine/Persistence/Helper/DoctrineHelper.php
@@ -65,7 +65,7 @@ public static function getRealClassName($subject): string
public static function getDoctrineType(string $type): string
{
if (!\defined(Types::class.'::'.$type)) {
- throw new InvalidArgumentException(sprintf('Undefined Doctrine type "%s"', $type));
+ throw new InvalidArgumentException(\sprintf('Undefined Doctrine type "%s"', $type));
}
\assert(\is_string(\constant(Types::class.'::'.$type)));
diff --git a/src/Provider/Doctrine/Persistence/Reader/Filter/DateRangeFilter.php b/src/Provider/Doctrine/Persistence/Reader/Filter/DateRangeFilter.php
index ed2dea04..83097786 100644
--- a/src/Provider/Doctrine/Persistence/Reader/Filter/DateRangeFilter.php
+++ b/src/Provider/Doctrine/Persistence/Reader/Filter/DateRangeFilter.php
@@ -42,12 +42,12 @@ public function getSQL(): array
$params = [];
if (null !== $this->minValue) {
- $sqls[] = sprintf('%s >= :min_%s', $this->name, $this->name);
+ $sqls[] = \sprintf('%s >= :min_%s', $this->name, $this->name);
$params['min_'.$this->name] = $this->minValue->format('Y-m-d H:i:s');
}
if (null !== $this->maxValue) {
- $sqls[] = sprintf('%s <= :max_%s', $this->name, $this->name);
+ $sqls[] = \sprintf('%s <= :max_%s', $this->name, $this->name);
$params['max_'.$this->name] = $this->maxValue->format('Y-m-d H:i:s');
}
diff --git a/src/Provider/Doctrine/Persistence/Reader/Filter/RangeFilter.php b/src/Provider/Doctrine/Persistence/Reader/Filter/RangeFilter.php
index a1e55c14..83e5a08d 100644
--- a/src/Provider/Doctrine/Persistence/Reader/Filter/RangeFilter.php
+++ b/src/Provider/Doctrine/Persistence/Reader/Filter/RangeFilter.php
@@ -64,12 +64,12 @@ public function getSQL(): array
$params = [];
if (null !== $this->minValue) {
- $sqls[] = sprintf('%s >= :min_%s', $this->name, $this->name);
+ $sqls[] = \sprintf('%s >= :min_%s', $this->name, $this->name);
$params['min_'.$this->name] = $this->minValue;
}
if (null !== $this->maxValue) {
- $sqls[] = sprintf('%s <= :max_%s', $this->name, $this->name);
+ $sqls[] = \sprintf('%s <= :max_%s', $this->name, $this->name);
$params['max_'.$this->name] = $this->maxValue;
}
diff --git a/src/Provider/Doctrine/Persistence/Reader/Filter/SimpleFilter.php b/src/Provider/Doctrine/Persistence/Reader/Filter/SimpleFilter.php
index f3a12ad6..19597253 100644
--- a/src/Provider/Doctrine/Persistence/Reader/Filter/SimpleFilter.php
+++ b/src/Provider/Doctrine/Persistence/Reader/Filter/SimpleFilter.php
@@ -39,12 +39,12 @@ public function getSQL(): array
{
if (\is_array($this->value) && 1 < \count($this->value)) {
$data = [
- 'sql' => sprintf('%s IN (:%s)', $this->name, $this->name),
+ 'sql' => \sprintf('%s IN (:%s)', $this->name, $this->name),
'params' => [$this->name => $this->value],
];
} else {
$data = [
- 'sql' => sprintf('%s = :%s', $this->name, $this->name),
+ 'sql' => \sprintf('%s = :%s', $this->name, $this->name),
'params' => [$this->name => (\is_array($this->value) ? $this->value[0] : $this->value)],
];
}
diff --git a/src/Provider/Doctrine/Persistence/Reader/Query.php b/src/Provider/Doctrine/Persistence/Reader/Query.php
index e18fccca..be40c236 100644
--- a/src/Provider/Doctrine/Persistence/Reader/Query.php
+++ b/src/Provider/Doctrine/Persistence/Reader/Query.php
@@ -286,7 +286,7 @@ private function buildLimit(QueryBuilder $queryBuilder): QueryBuilder
private function checkFilter(string $filter): void
{
if (!\in_array($filter, $this->getSupportedFilters(), true)) {
- throw new InvalidArgumentException(sprintf('Unsupported "%s" filter, allowed filters: %s.', $filter, implode(', ', $this->getSupportedFilters())));
+ throw new InvalidArgumentException(\sprintf('Unsupported "%s" filter, allowed filters: %s.', $filter, implode(', ', $this->getSupportedFilters())));
}
}
}
diff --git a/src/Provider/Doctrine/Persistence/Reader/Reader.php b/src/Provider/Doctrine/Persistence/Reader/Reader.php
index 93a6958f..d172ef61 100644
--- a/src/Provider/Doctrine/Persistence/Reader/Reader.php
+++ b/src/Provider/Doctrine/Persistence/Reader/Reader.php
@@ -183,7 +183,7 @@ public function getEntityAuditTableName(string $entity): string
$schema = $entityManager->getClassMetadata($entity)->getSchemaName().'.';
}
- return sprintf(
+ return \sprintf(
'%s%s%s%s',
$schema,
$configuration->getTablePrefix(),
diff --git a/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php b/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php
index dfbb5686..324306d7 100644
--- a/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php
+++ b/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php
@@ -264,8 +264,8 @@ public function resolveAuditTableName(string $entity, Configuration $configurati
public function computeAuditTablename(string $entityTableName, Configuration $configuration): ?string
{
return preg_replace(
- sprintf('#^([^\.]+\.)?(%s)$#', preg_quote($entityTableName, '#')),
- sprintf(
+ \sprintf('#^([^\.]+\.)?(%s)$#', preg_quote($entityTableName, '#')),
+ \sprintf(
'$1%s$2%s',
preg_quote($configuration->getTablePrefix(), '#'),
preg_quote($configuration->getTableSuffix(), '#')
diff --git a/tests/Provider/Doctrine/Fixtures/Issue37/User.php b/tests/Provider/Doctrine/Fixtures/Issue37/User.php
index bd72c5e0..706ae3dd 100644
--- a/tests/Provider/Doctrine/Fixtures/Issue37/User.php
+++ b/tests/Provider/Doctrine/Fixtures/Issue37/User.php
@@ -103,8 +103,6 @@ public function getLocaleId(): ?string
/**
* Set Locale entity (many to one).
- *
- * @param ?Locale $locale
*/
public function setLocale(?Locale $locale): self
{
@@ -115,8 +113,6 @@ public function setLocale(?Locale $locale): self
/**
* Get Locale entity (many to one).
- *
- * @return ?Locale
*/
public function getLocale(): ?Locale
{
diff --git a/tests/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommandTest.php b/tests/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommandTest.php
index 92108127..d980d216 100644
--- a/tests/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommandTest.php
+++ b/tests/Provider/Doctrine/Persistence/Command/CleanAuditLogsCommandTest.php
@@ -43,7 +43,7 @@ public function testExecuteFailsWithKeepWrongFormat(): void
// the output of the command in the console
$output = $commandTester->getDisplay();
- self::assertStringContainsString(sprintf("[ERROR] 'keep' argument must be a valid ISO 8601 date interval, '%s' given.", $keep), $output);
+ self::assertStringContainsString(\sprintf("[ERROR] 'keep' argument must be a valid ISO 8601 date interval, '%s' given.", $keep), $output);
}
public function testDumpSQL(): void