Skip to content

Commit 8af6cb6

Browse files
committed
Enforce trailing slash on native functions invocation
1 parent 8d22335 commit 8af6cb6

File tree

49 files changed

+177
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+177
-172
lines changed

ecs.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
66
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
77
use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
8+
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
89
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
910
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
1011
use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer;
@@ -51,4 +52,8 @@
5152
$ecsConfig->ruleWithConfiguration(FunctionDeclarationFixer::class, [
5253
'closure_fn_spacing' => 'none',
5354
]);
55+
$ecsConfig->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [
56+
'scope' => 'namespaced',
57+
'include' => ['@all'],
58+
]);
5459
};

src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class DoctrineDBALJobExecutionStorage implements
4444
*/
4545
public function __construct(ConnectionRegistry $doctrine, array $options)
4646
{
47-
$options = array_filter($options) + self::DEFAULT_OPTIONS;
47+
$options = \array_filter($options) + self::DEFAULT_OPTIONS;
4848
$options['connection'] ??= $doctrine->getDefaultConnectionName();
4949

5050
$this->table = $options['table'];
@@ -64,26 +64,26 @@ public function setup(): void
6464
fn(string $tableName) => $tableName === $this->table,
6565
);
6666

67-
$schemaManager = method_exists($this->connection, 'createSchemaManager')
67+
$schemaManager = \method_exists($this->connection, 'createSchemaManager')
6868
? $this->connection->createSchemaManager()
6969
: $this->connection->getSchemaManager();
70-
$comparator = method_exists($schemaManager, 'createComparator')
70+
$comparator = \method_exists($schemaManager, 'createComparator')
7171
? $schemaManager->createComparator()
7272
: new Comparator();
73-
$fromSchema = method_exists($schemaManager, 'introspectSchema')
73+
$fromSchema = \method_exists($schemaManager, 'introspectSchema')
7474
? $schemaManager->introspectSchema()
7575
: $schemaManager->createSchema();
7676
$toSchema = $this->getSchema();
77-
$schemaDiff = method_exists($comparator, 'compareSchemas')
77+
$schemaDiff = \method_exists($comparator, 'compareSchemas')
7878
? $comparator->compareSchemas($fromSchema, $toSchema)
7979
: $comparator->compare($fromSchema, $toSchema);
8080
$platform = $this->connection->getDatabasePlatform();
81-
$schemaDiffQueries = method_exists($platform, 'getAlterSchemaSQL')
81+
$schemaDiffQueries = \method_exists($platform, 'getAlterSchemaSQL')
8282
? $platform->getAlterSchemaSQL($schemaDiff)
8383
: $schemaDiff->toSaveSql($platform);
8484

8585
foreach ($schemaDiffQueries as $sql) {
86-
if (method_exists($this->connection, 'executeStatement')) {
86+
if (\method_exists($this->connection, 'executeStatement')) {
8787
$this->connection->executeStatement($sql);
8888
} else {
8989
$this->connection->exec($sql);
@@ -173,21 +173,21 @@ public function query(Query $query): iterable
173173
->from($this->table);
174174

175175
$names = $query->jobs();
176-
if (count($names) > 0) {
176+
if (\count($names) > 0) {
177177
$qb->andWhere($qb->expr()->in('job_name', ':jobNames'));
178178
$queryParameters['jobNames'] = $names;
179179
$queryTypes['jobNames'] = Connection::PARAM_STR_ARRAY;
180180
}
181181

182182
$ids = $query->ids();
183-
if (count($ids) > 0) {
183+
if (\count($ids) > 0) {
184184
$qb->andWhere($qb->expr()->in('id', ':ids'));
185185
$queryParameters['ids'] = $ids;
186186
$queryTypes['ids'] = Connection::PARAM_STR_ARRAY;
187187
}
188188

189189
$statuses = $query->statuses();
190-
if (count($statuses) > 0) {
190+
if (\count($statuses) > 0) {
191191
$qb->andWhere($qb->expr()->in('status', ':statuses'));
192192
$queryParameters['statuses'] = $statuses;
193193
$queryTypes['statuses'] = Connection::PARAM_INT_ARRAY;

src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public function toRow(JobExecution $jobExecution): array
3737
'id' => $jobExecution->getId(),
3838
'job_name' => $jobExecution->getJobName(),
3939
'status' => $jobExecution->getStatus()->getValue(),
40-
'parameters' => iterator_to_array($jobExecution->getParameters()),
40+
'parameters' => \iterator_to_array($jobExecution->getParameters()),
4141
'start_time' => $jobExecution->getStartTime(),
4242
'end_time' => $jobExecution->getEndTime(),
4343
'summary' => $jobExecution->getSummary()->all(),
44-
'failures' => array_map([$this, 'failureToArray'], $jobExecution->getFailures()),
45-
'warnings' => array_map([$this, 'warningToArray'], $jobExecution->getWarnings()),
46-
'child_executions' => array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()),
44+
'failures' => \array_map([$this, 'failureToArray'], $jobExecution->getFailures()),
45+
'warnings' => \array_map([$this, 'warningToArray'], $jobExecution->getWarnings()),
46+
'child_executions' => \array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()),
4747
'logs' => $jobExecution->getParentExecution() === null ? (string)$jobExecution->getLogs() : null,
4848
];
4949
}
@@ -55,15 +55,15 @@ public function toRow(JobExecution $jobExecution): array
5555
*/
5656
public function fromRow(array $data, JobExecution $parent = null): JobExecution
5757
{
58-
$data['status'] = intval($data['status']);
58+
$data['status'] = \intval($data['status']);
5959
$data['parameters'] = $this->jsonFromString($data['parameters']);
6060
$data['summary'] = $this->jsonFromString($data['summary']);
6161
$data['failures'] = $this->jsonFromString($data['failures']);
6262
$data['warnings'] = $this->jsonFromString($data['warnings']);
6363
$data['child_executions'] = $this->jsonFromString($data['child_executions']);
6464

6565
$name = $data['job_name'];
66-
$status = new BatchStatus(intval($data['status']));
66+
$status = new BatchStatus(\intval($data['status']));
6767
$parameters = new JobParameters($data['parameters']);
6868
$summary = new Summary($data['summary']);
6969

@@ -106,13 +106,13 @@ private function toChildRow(JobExecution $jobExecution): array
106106
return [
107107
'job_name' => $jobExecution->getJobName(),
108108
'status' => $jobExecution->getStatus()->getValue(),
109-
'parameters' => iterator_to_array($jobExecution->getParameters()),
109+
'parameters' => \iterator_to_array($jobExecution->getParameters()),
110110
'start_time' => $this->toDateString($jobExecution->getStartTime()),
111111
'end_time' => $this->toDateString($jobExecution->getEndTime()),
112112
'summary' => $jobExecution->getSummary()->all(),
113-
'failures' => array_map([$this, 'failureToArray'], $jobExecution->getFailures()),
114-
'warnings' => array_map([$this, 'warningToArray'], $jobExecution->getWarnings()),
115-
'child_executions' => array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()),
113+
'failures' => \array_map([$this, 'failureToArray'], $jobExecution->getFailures()),
114+
'warnings' => \array_map([$this, 'warningToArray'], $jobExecution->getWarnings()),
115+
'child_executions' => \array_map([$this, 'toChildRow'], $jobExecution->getChildExecutions()),
116116
];
117117
}
118118

@@ -123,11 +123,11 @@ private function toChildRow(JobExecution $jobExecution): array
123123
*/
124124
private function jsonFromString(array|string $value): array
125125
{
126-
if (is_string($value)) {
127-
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
126+
if (\is_string($value)) {
127+
$value = \json_decode($value, true, 512, JSON_THROW_ON_ERROR);
128128
}
129129

130-
if (!is_array($value)) {
130+
if (!\is_array($value)) {
131131
throw UnexpectedValueException::type('array', $value);
132132
}
133133

src/batch-doctrine-dbal/tests/DoctrineDBALJobExecutionStorageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testCreateStandardTable(): void
5454
'child_executions',
5555
'logs',
5656
],
57-
array_keys($columns)
57+
\array_keys($columns)
5858
);
5959
}
6060

@@ -81,7 +81,7 @@ public function testCreateCustomTable(): void
8181
'child_executions',
8282
'logs',
8383
],
84-
array_keys($columns)
84+
\array_keys($columns)
8585
);
8686
}
8787

src/batch-doctrine-dbal/tests/Dummy/SingleConnectionRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getConnection($name = null)
2727
return $this->connection;
2828
}
2929

30-
throw new InvalidArgumentException(sprintf('Doctrine Connection named "%s" does not exist.', $name));
30+
throw new InvalidArgumentException(\sprintf('Doctrine Connection named "%s" does not exist.', $name));
3131
}
3232

3333
public function getConnections()

src/batch-doctrine-persistence/src/ObjectRegistry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function ($repository) use ($criteria) {
4444

4545
return $repository->findOneBy($criteria);
4646
},
47-
serialize($criteria)
47+
\serialize($criteria)
4848
);
4949
}
5050

@@ -62,11 +62,11 @@ public function findOneUsing(string $class, \Closure $closure, string $key = nul
6262
{
6363
$manager = $this->doctrine->getManagerForClass($class);
6464
if ($manager === null) {
65-
throw new InvalidArgumentException(sprintf('Class "%s" is not a managed Doctrine entity.', $class));
65+
throw new InvalidArgumentException(\sprintf('Class "%s" is not a managed Doctrine entity.', $class));
6666
}
6767

68-
$key ??= spl_object_hash($closure);
69-
$key = md5($key);
68+
$key ??= \spl_object_hash($closure);
69+
$key = \md5($key);
7070

7171
$identity = $this->identities[$class][$key] ?? null;
7272
if ($identity !== null) {

src/batch-doctrine-persistence/src/ObjectWriter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(
3333
public function write(iterable $items): void
3434
{
3535
foreach ($items as $item) {
36-
if (!is_object($item)) {
36+
if (!\is_object($item)) {
3737
throw $this->createInvalidItemException($item);
3838
}
3939

@@ -62,15 +62,15 @@ private function getManagerForClass(object $item): ObjectManager
6262
$this->managerForClass[$class] = $manager;
6363
}
6464

65-
$this->encounteredManagers[spl_object_id($manager)] = $manager;
65+
$this->encounteredManagers[\spl_object_id($manager)] = $manager;
6666

6767
return $manager;
6868
}
6969

7070
private function createInvalidItemException(mixed $item): InvalidArgumentException
7171
{
7272
return new InvalidArgumentException(
73-
sprintf('Items to write must be object managed by Doctrine. Got "%s".', get_debug_type($item))
73+
\sprintf('Items to write must be object managed by Doctrine. Got "%s".', \get_debug_type($item))
7474
);
7575
}
7676
}

src/batch-doctrine-persistence/tests/Dummy/FindOneByCalledOnlyOnceWhenFoundRepositoryDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function findOneBy(array $criteria)
3737
return null;
3838
}
3939

40-
$this->ensureNotCalledAlready(__FUNCTION__, func_get_args());
40+
$this->ensureNotCalledAlready(__FUNCTION__, \func_get_args());
4141

4242
return $result;
4343
}
@@ -49,7 +49,7 @@ public function getClassName()
4949

5050
private function ensureNotCalledAlready(string $method, array $args): void
5151
{
52-
$key = md5($method . $serializedArgs = serialize($args));
52+
$key = \md5($method . $serializedArgs = \serialize($args));
5353
if (isset($this->calls[$key])) {
5454
throw new \LogicException(
5555
'Method ' . $method . ' with args ' . $serializedArgs . ' has already been called'

src/batch-openspout/src/Reader/FlatFileReader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function read(): iterable
4848
{
4949
/** @var string $path */
5050
$path = $this->filePath->get($this->jobExecution);
51-
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
51+
$extension = \strtolower(\pathinfo($path, PATHINFO_EXTENSION));
5252
$reader = match ($extension) {
5353
'csv' => new CSVReader($this->options),
5454
'xlsx' => new XLSXReader($this->options),
@@ -70,11 +70,11 @@ public function read(): iterable
7070
} catch (InvalidRowSizeException $exception) {
7171
$this->jobExecution->addWarning(
7272
new Warning(
73-
sprintf(
73+
\sprintf(
7474
'Expecting row %s to have exactly %d columns(s), but got %d.',
7575
$rowIndex,
76-
count($exception->getHeaders()),
77-
count($exception->getRow()),
76+
\count($exception->getHeaders()),
77+
\count($exception->getRow()),
7878
),
7979
[],
8080
['headers' => $exception->getHeaders(), 'row' => $exception->getRow()]

src/batch-openspout/src/Reader/HeaderStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getItem(array $row): array
8989

9090
try {
9191
/** @var array<string, string> $combined */
92-
$combined = @array_combine($this->headers, $row);
92+
$combined = @\array_combine($this->headers, $row);
9393
} catch (\ValueError) {
9494
throw new InvalidRowSizeException($this->headers, $row);
9595
}

0 commit comments

Comments
 (0)