Skip to content

Commit

Permalink
CS: update ruleset for PHP8
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Jan 31, 2025
1 parent e301f84 commit 948978b
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 21 deletions.
49 changes: 42 additions & 7 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
name="ShipMonk Generic Coding Standard"
>
<config name="php_version" value="70400"/>
<config name="php_version" value="80100"/>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
Expand Down Expand Up @@ -244,9 +244,7 @@
</rule>

<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference">
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall"/> <!-- after bumping to PHP8 -->
</rule>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
Expand All @@ -265,8 +263,19 @@
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch"/>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing" />
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="0"/>
<property name="maxLinesCountBeforeWithComment" value="1"/>
<property name="minLinesCountBeforeWithoutComment" value="0"/>
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration" />
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing" />
<rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion" />
Expand All @@ -280,7 +289,11 @@
</rule>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
<properties>
<property name="allowAboveNonAssignment" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
Expand All @@ -300,12 +313,33 @@
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="allowMultiLine" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall">
<properties>
<property name="onlySingleLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
Expand Down Expand Up @@ -392,6 +426,7 @@
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Variables.DisallowVariableVariable"/>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MigrationCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MigrationCheckCommand extends Command
private MigrationService $migrationService;

public function __construct(
MigrationService $migrationService
MigrationService $migrationService,
)
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MigrationGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MigrationGenerateCommand extends Command
private MigrationService $migrationService;

public function __construct(
MigrationService $migrationService
MigrationService $migrationService,
)
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MigrationInitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MigrationInitCommand extends Command
private MigrationService $migrationService;

public function __construct(
MigrationService $migrationService
MigrationService $migrationService,
)
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MigrationRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MigrationRunCommand extends Command
private MigrationService $migrationService;

public function __construct(
MigrationService $migrationService
MigrationService $migrationService,
)
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
?string $migrationClassPrefix = null,
?array $excludedTables = null,
?string $templateFilePath = null,
?string $templateIndent = null
?string $templateIndent = null,
)
{
$templateFilePathToUse = $templateFilePath ?? __DIR__ . '/template/migration.txt';
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationDefaultExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MigrationDefaultExecutor implements MigrationExecutor
private Connection $connection;

public function __construct(
Connection $connection
Connection $connection,
)
{
$this->connection = $connection;
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
string $version,
MigrationPhase $phase,
DateTimeImmutable $startedAt,
DateTimeImmutable $finishedAt
DateTimeImmutable $finishedAt,
)
{
$this->version = $version;
Expand Down
2 changes: 1 addition & 1 deletion src/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
MigrationConfig $config,
?MigrationExecutor $executor = null,
?MigrationVersionProvider $versionProvider = null,
?MigrationAnalyzer $migrationsAnalyzer = null
?MigrationAnalyzer $migrationsAnalyzer = null,
)
{
$this->entityManager = $entityManager;
Expand Down
8 changes: 3 additions & 5 deletions tests/CachingSqlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ class CachingSqlLogger implements LoggerInterface
private array $queries = [];

/**
* @param mixed $level
* @param string|Stringable $message
* @param mixed[] $context
*/
public function log(
$level,
$message,
array $context = []
mixed $level,
string|Stringable $message,
array $context = [],
): void
{
if (isset($context['sql'])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/MigrationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private function createMigrationService(
array $excludedTables = [],
bool $transactional = false,
?MigrationVersionProvider $versionProvider = null,
?MigrationAnalyzer $statementAnalyzer = null
?MigrationAnalyzer $statementAnalyzer = null,
): MigrationService
{
$migrationsDir = $this->getMigrationsTestDir();
Expand Down

0 comments on commit 948978b

Please sign in to comment.