Skip to content

Commit 0faab1e

Browse files
authored
CS: update ruleset for PHP8 (#112)
* CS: update ruleset for PHP8 * Only latest psr/log
1 parent e301f84 commit 0faab1e

13 files changed

+64
-31
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"phpstan/phpstan-phpunit": "^2.0.0",
1919
"phpstan/phpstan-strict-rules": "^2.0.0",
2020
"phpunit/phpunit": "^10.5.29",
21-
"psr/log": "^1 || ^2 || ^3",
21+
"psr/log": "^3",
2222
"shipmonk/composer-dependency-analyser": "^1.7.0",
2323
"shipmonk/phpstan-rules": "^4.0.0",
2424
"slevomat/coding-standard": "^8.15.0"

composer.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml.dist

+42-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
55
name="ShipMonk Generic Coding Standard"
66
>
7-
<config name="php_version" value="70400"/>
7+
<config name="php_version" value="80100"/>
88
<arg name="basepath" value="."/>
99
<arg name="extensions" value="php"/>
1010
<arg name="parallel" value="80"/>
@@ -244,9 +244,7 @@
244244
</rule>
245245

246246
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
247-
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference">
248-
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall"/> <!-- after bumping to PHP8 -->
249-
</rule>
247+
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
250248
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
251249
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
252250
<properties>
@@ -265,8 +263,19 @@
265263
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" />
266264
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" />
267265
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" />
266+
<rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch"/>
268267
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing" />
268+
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing">
269+
<properties>
270+
<property name="minLinesCountBeforeWithComment" value="0"/>
271+
<property name="maxLinesCountBeforeWithComment" value="1"/>
272+
<property name="minLinesCountBeforeWithoutComment" value="0"/>
273+
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
274+
</properties>
275+
</rule>
269276
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>
277+
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
278+
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/>
270279
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration" />
271280
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing" />
272281
<rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion" />
@@ -280,7 +289,11 @@
280289
</rule>
281290
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
282291
<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
283-
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
292+
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
293+
<properties>
294+
<property name="allowAboveNonAssignment" value="true"/>
295+
</properties>
296+
</rule>
284297
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
285298
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
286299
<properties>
@@ -300,12 +313,33 @@
300313
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
301314
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
302315
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
303-
<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>
316+
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
317+
<properties>
318+
<property name="allowMultiLine" value="true" />
319+
</properties>
320+
</rule>
321+
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
322+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse">
323+
<properties>
324+
<property name="onlySingleLine" value="true"/>
325+
</properties>
326+
</rule>
327+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration">
328+
<properties>
329+
<property name="onlySingleLine" value="true"/>
330+
</properties>
331+
</rule>
332+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall">
333+
<properties>
334+
<property name="onlySingleLine" value="true"/>
335+
</properties>
336+
</rule>
337+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
338+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
304339
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
305340
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
306341
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
307342
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
308-
<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>
309343
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
310344
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
311345
<properties>
@@ -392,6 +426,7 @@
392426
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
393427
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
394428
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
429+
<rule ref="SlevomatCodingStandard.Variables.DisallowVariableVariable"/>
395430
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
396431
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
397432
<properties>

src/Command/MigrationCheckCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MigrationCheckCommand extends Command
2323
private MigrationService $migrationService;
2424

2525
public function __construct(
26-
MigrationService $migrationService
26+
MigrationService $migrationService,
2727
)
2828
{
2929
parent::__construct();

src/Command/MigrationGenerateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MigrationGenerateCommand extends Command
1414
private MigrationService $migrationService;
1515

1616
public function __construct(
17-
MigrationService $migrationService
17+
MigrationService $migrationService,
1818
)
1919
{
2020
parent::__construct();

src/Command/MigrationInitCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MigrationInitCommand extends Command
1313
private MigrationService $migrationService;
1414

1515
public function __construct(
16-
MigrationService $migrationService
16+
MigrationService $migrationService,
1717
)
1818
{
1919
parent::__construct();

src/Command/MigrationRunCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MigrationRunCommand extends Command
2323
private MigrationService $migrationService;
2424

2525
public function __construct(
26-
MigrationService $migrationService
26+
MigrationService $migrationService,
2727
)
2828
{
2929
parent::__construct();

src/MigrationConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
?string $migrationClassPrefix = null,
3737
?array $excludedTables = null,
3838
?string $templateFilePath = null,
39-
?string $templateIndent = null
39+
?string $templateIndent = null,
4040
)
4141
{
4242
$templateFilePathToUse = $templateFilePath ?? __DIR__ . '/template/migration.txt';

src/MigrationDefaultExecutor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MigrationDefaultExecutor implements MigrationExecutor
1414
private Connection $connection;
1515

1616
public function __construct(
17-
Connection $connection
17+
Connection $connection,
1818
)
1919
{
2020
$this->connection = $connection;

src/MigrationRun.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(
1919
string $version,
2020
MigrationPhase $phase,
2121
DateTimeImmutable $startedAt,
22-
DateTimeImmutable $finishedAt
22+
DateTimeImmutable $finishedAt,
2323
)
2424
{
2525
$this->version = $version;

src/MigrationService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
MigrationConfig $config,
4141
?MigrationExecutor $executor = null,
4242
?MigrationVersionProvider $versionProvider = null,
43-
?MigrationAnalyzer $migrationsAnalyzer = null
43+
?MigrationAnalyzer $migrationsAnalyzer = null,
4444
)
4545
{
4646
$this->entityManager = $entityManager;

tests/CachingSqlLogger.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ class CachingSqlLogger implements LoggerInterface
1919
private array $queries = [];
2020

2121
/**
22-
* @param mixed $level
23-
* @param string|Stringable $message
2422
* @param mixed[] $context
2523
*/
2624
public function log(
27-
$level,
28-
$message,
29-
array $context = []
25+
mixed $level,
26+
string|Stringable $message,
27+
array $context = [],
3028
): void
3129
{
3230
if (isset($context['sql'])) {

tests/MigrationServiceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ private function createMigrationService(
295295
array $excludedTables = [],
296296
bool $transactional = false,
297297
?MigrationVersionProvider $versionProvider = null,
298-
?MigrationAnalyzer $statementAnalyzer = null
298+
?MigrationAnalyzer $statementAnalyzer = null,
299299
): MigrationService
300300
{
301301
$migrationsDir = $this->getMigrationsTestDir();

0 commit comments

Comments
 (0)