Skip to content

Commit 64851ee

Browse files
author
Xavier Marchegay
committed
fix phpcsfixer
1 parent 5b82d09 commit 64851ee

19 files changed

+89
-93
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/composer.lock
22
/vendor
3+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->exclude('var')
6+
;
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@Symfony' => true,
11+
])
12+
->setFinder($finder)
13+
;

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
SHELL := /bin/bash
33

44
linter: #[Linter]
5-
vendor/bin/php-cs-fixer fix src
6-
vendor/bin/rector process
7-
vendor/bin/phpstan
5+
vendor/bin/php-cs-fixer fix
6+
phpstan: #[Phpstan]
7+
vendor/bin/phpstan

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$rectorConfig->importNames();
1414
$rectorConfig->importShortClasses();
1515

16-
$rectorConfig->paths([__DIR__ . '/src']);
16+
$rectorConfig->paths([__DIR__.'/src']);
1717

1818
$rectorConfig->sets([
1919
SetList::TYPE_DECLARATION,

src/CleverAgeDoctrineProcessBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\HttpKernel\Bundle\Bundle;
1717

1818
/**
19-
* Class CleverAgeDoctrineProcessBundle
19+
* Class CleverAgeDoctrineProcessBundle.
2020
*
2121
* @author Valentin Clavreul <[email protected]>
2222
* @author Vincent Chalnot <[email protected]>

src/DependencyInjection/CleverAgeDoctrineProcessExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CleverAgeDoctrineProcessExtension extends Extension
2727
{
2828
public function load(array $configs, ContainerBuilder $container): void
2929
{
30-
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
30+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
3131
$loader->load('services.yaml');
3232
}
3333
}

src/Task/Database/DatabaseReaderTask.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use Symfony\Component\OptionsResolver\OptionsResolver;
2626

2727
/**
28-
* Fetch entities from doctrine
28+
* Fetch entities from doctrine.
2929
*/
3030
class DatabaseReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface
3131
{
@@ -42,11 +42,11 @@ public function __construct(
4242
/**
4343
* Moves the internal pointer to the next element,
4444
* return true if the task has a next element
45-
* return false if the task has terminated it's iteration
45+
* return false if the task has terminated it's iteration.
4646
*/
4747
public function next(ProcessState $state): bool
4848
{
49-
if (! $this->statement) {
49+
if (!$this->statement) {
5050
return false;
5151
}
5252

@@ -58,20 +58,20 @@ public function next(ProcessState $state): bool
5858
public function execute(ProcessState $state): void
5959
{
6060
$options = $this->getOptions($state);
61-
if (! $this->statement) {
61+
if (!$this->statement) {
6262
$this->statement = $this->initializeStatement($state);
6363
}
6464

6565
// Check if the next item has been stored by the next() call
66-
if ($this->nextItem !== null) {
66+
if (null !== $this->nextItem) {
6767
$result = $this->nextItem;
6868
$this->nextItem = null;
6969
} else {
7070
$result = $this->statement->fetchAssociative();
7171
}
7272

7373
// Handle empty results
74-
if ($result === false) {
74+
if (false === $result) {
7575
$logContext = [
7676
'options' => $options,
7777
];
@@ -82,10 +82,10 @@ public function execute(ProcessState $state): void
8282
return;
8383
}
8484

85-
if ($options['paginate'] !== null) {
85+
if (null !== $options['paginate']) {
8686
$results = [];
8787
$i = 0;
88-
while ($result !== false && $i++ < $options['paginate']) {
88+
while (false !== $result && $i++ < $options['paginate']) {
8989
$results[] = $result;
9090
$result = $this->statement->fetchAssociative();
9191
}
@@ -106,7 +106,7 @@ protected function initializeStatement(ProcessState $state): Result
106106
$connection = $this->getConnection($state);
107107
$sql = $options['sql'];
108108

109-
if ($sql === null) {
109+
if (null === $sql) {
110110
$qb = $connection->createQueryBuilder();
111111
$qb
112112
->select('tbl.*')
@@ -172,7 +172,7 @@ protected function configureOptions(OptionsResolver $resolver): void
172172

173173
protected function getConnection(ProcessState $state): Connection
174174
{
175-
/** @noinspection PhpIncompatibleReturnTypeInspection */
175+
/* @noinspection PhpIncompatibleReturnTypeInspection */
176176
return $this->doctrine->getConnection($this->getOption($state, 'connection'));
177177
}
178178
}

src/Task/Database/DatabaseUpdaterTask.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
use Doctrine\Persistence\ManagerRegistry;
2121
use Psr\Log\LoggerInterface;
2222
use Symfony\Component\OptionsResolver\OptionsResolver;
23-
use UnexpectedValueException;
2423

2524
/**
26-
* Execute an update/delete in the database from a SQL statement
25+
* Execute an update/delete in the database from a SQL statement.
2726
*
2827
* @see https://www.doctrine-project.org/projects/doctrine-dbal/en/2.9/reference/data-retrieval-and-manipulation.html#list-of-parameters-conversion
2928
*/
@@ -43,7 +42,8 @@ public function execute(ProcessState $state): void
4342
}
4443

4544
/**
46-
* @return integer The number of affected rows.
45+
* @return int the number of affected rows
46+
*
4747
* @throws Exception
4848
*/
4949
protected function initializeStatement(ProcessState $state): int
@@ -56,8 +56,8 @@ protected function initializeStatement(ProcessState $state): int
5656
} else {
5757
$params = $options['params'];
5858
}
59-
if (! is_array($params)) {
60-
throw new UnexpectedValueException('Expecting an array of params');
59+
if (!is_array($params)) {
60+
throw new \UnexpectedValueException('Expecting an array of params');
6161
}
6262

6363
return $connection->executeStatement($options['sql'], $params, $options['types']);
@@ -81,7 +81,7 @@ protected function configureOptions(OptionsResolver $resolver): void
8181

8282
protected function getConnection(ProcessState $state): Connection
8383
{
84-
/** @noinspection PhpIncompatibleReturnTypeInspection */
84+
/* @noinspection PhpIncompatibleReturnTypeInspection */
8585
return $this->doctrine->getConnection($this->getOption($state, 'connection'));
8686
}
8787
}

src/Task/EntityManager/AbstractDoctrineQueryTask.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
use Doctrine\ORM\QueryBuilder;
1818
use Psr\Log\LogLevel;
1919
use Symfony\Component\OptionsResolver\OptionsResolver;
20-
use UnexpectedValueException;
21-
22-
use function is_array;
2320

2421
/**
25-
* Easily extendable task to query entities in their repository
22+
* Easily extendable task to query entities in their repository.
2623
*/
2724
abstract class AbstractDoctrineQueryTask extends AbstractDoctrineTask
2825
{
@@ -63,34 +60,34 @@ protected function getQueryBuilder(
6360
EntityRepository $repository,
6461
array $criteria,
6562
array $orderBy,
66-
?int $limit = null,
67-
?int $offset = null
63+
int $limit = null,
64+
int $offset = null
6865
): QueryBuilder {
6966
$qb = $repository->createQueryBuilder('e');
7067
foreach ($criteria as $field => $value) {
7168
if (preg_match('/[^a-zA-Z0-9]/', $field)) {
72-
throw new UnexpectedValueException("Forbidden field name '{$field}'");
69+
throw new \UnexpectedValueException("Forbidden field name '{$field}'");
7370
}
7471
$parameterName = uniqid('param', true);
75-
if ($value === null) {
72+
if (null === $value) {
7673
$qb->andWhere("e.{$field} IS null");
7774
} else {
78-
if (is_array($value)) {
75+
if (\is_array($value)) {
7976
$qb->andWhere("e.{$field} IN (:{$parameterName})");
8077
} else {
8178
$qb->andWhere("e.{$field} = :{$parameterName}");
8279
}
8380
$qb->setParameter($parameterName, $value);
8481
}
8582
}
86-
/** @noinspection ForeachSourceInspection */
83+
/* @noinspection ForeachSourceInspection */
8784
foreach ($orderBy as $field => $order) {
8885
$qb->addOrderBy("e.{$field}", $order);
8986
}
90-
if ($limit !== null) {
87+
if (null !== $limit) {
9188
$qb->setMaxResults($limit);
9289
}
93-
if ($offset !== null) {
90+
if (null !== $offset) {
9491
$qb->setFirstResult($offset);
9592
}
9693

src/Task/EntityManager/AbstractDoctrineTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\OptionsResolver\OptionsResolver;
2121

2222
/**
23-
* Base logic for doctrine related tasks
23+
* Base logic for doctrine related tasks.
2424
*/
2525
abstract class AbstractDoctrineTask extends AbstractConfigurableTask
2626
{

0 commit comments

Comments
 (0)