Skip to content

Commit

Permalink
feat: enforce spaces between constants
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Jun 27, 2022
1 parent 0f64bb0 commit 982dae0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Doctrine/ruleset.xml
Expand Up @@ -120,6 +120,8 @@
<property name="fixable" value="true"/>
</properties>
</rule>
<!-- Enforce consistent constant spacing -->
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
Expand Down
2 changes: 1 addition & 1 deletion tests/expected_report.txt
Expand Up @@ -10,7 +10,7 @@ tests/input/binary_operators.php 9 0
tests/input/class-references.php 10 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 6 0
tests/input/constants-var.php 12 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
Expand Down
14 changes: 14 additions & 0 deletions tests/fixed/constants-var.php
Expand Up @@ -16,3 +16,17 @@ class Bar
protected const PROPERTY_1 = '1';
protected const PROPERTY_2 = '2';
}

// phpcs:disable SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment

class Spacing
{
/** @var string */
public const FOO = 'bar';

/** @var string */
public const BAR = 'bar';
public const BAZ = 'baz';

public const BAM = 'bam';
}
14 changes: 14 additions & 0 deletions tests/input/constants-var.php
Expand Up @@ -16,3 +16,17 @@ class Bar

protected const PROPERTY_1 = '1', PROPERTY_2 = '2';
}

// phpcs:disable SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment

class Spacing
{
/** @var string */
public const FOO = 'bar';
/** @var string */
public const BAR = 'bar';
public const BAZ = 'baz';


public const BAM = 'bam';
}

0 comments on commit 982dae0

Please sign in to comment.