Skip to content

Commit 8f962e1

Browse files
authored
Merge pull request #112 from doctrine/sniff/DisallowLateStaticBindingForConstants
Forbid LSB for constants
2 parents 6b50008 + 4979a90 commit 8f962e1

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

lib/Doctrine/ruleset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
<property name="fixable" value="true"/>
107107
</properties>
108108
</rule>
109+
<!-- Forbid LSB for constants (static::FOO) -->
110+
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
109111
<!-- Forbid empty lines around type declarations -->
110112
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
111113
<properties>

tests/expected_report.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tests/input/array_indentation.php 10 0
77
tests/input/assignment-operators.php 4 0
88
tests/input/class-references.php 10 0
99
tests/input/concatenation_spacing.php 24 0
10+
tests/input/constants-no-lsb.php 2 0
1011
tests/input/constants-var.php 3 0
1112
tests/input/doc-comment-spacing.php 10 0
1213
tests/input/duplicate-assignment-variable.php 1 0
@@ -32,9 +33,9 @@ tests/input/UnusedVariables.php 1 0
3233
tests/input/useless-semicolon.php 2 0
3334
tests/input/UselessConditions.php 20 0
3435
----------------------------------------------------------------------
35-
A TOTAL OF 244 ERRORS AND 0 WARNINGS WERE FOUND IN 28 FILES
36+
A TOTAL OF 246 ERRORS AND 0 WARNINGS WERE FOUND IN 29 FILES
3637
----------------------------------------------------------------------
37-
PHPCBF CAN FIX 208 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
38+
PHPCBF CAN FIX 209 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
3839
----------------------------------------------------------------------
3940

4041

tests/fixed/constants-no-lsb.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Test;
6+
7+
class ConstantLsb
8+
{
9+
public const A = 123;
10+
11+
public function __construct()
12+
{
13+
echo self::A;
14+
}
15+
}

tests/input/constants-no-lsb.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Test;
6+
7+
class ConstantLsb
8+
{
9+
public const A = 123;
10+
11+
public function __construct()
12+
{
13+
echo static::A;
14+
}
15+
}

0 commit comments

Comments
 (0)