-
Notifications
You must be signed in to change notification settings - Fork 51
Ensure that Typed Properties are spaced correctly #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spacing; | ||
|
||
final class PropertyTypeHintSpacing | ||
{ | ||
public bool $boolPropertyWithDefaultValue = false; | ||
public string $stringProperty; | ||
public int $intProperty; | ||
public ?string $nullableString = null; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spacing; | ||
|
||
final class PropertyTypeHintSpacing | ||
{ | ||
public bool $boolPropertyWithDefaultValue = false; | ||
public string $stringProperty; | ||
public int $intProperty; | ||
public ? string $nullableString = null; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
diff --git a/tests/expected_report.txt b/tests/expected_report.txt | ||
index d1fdd9f..4b5f6e4 100644 | ||
index d1fdd9f..577922e 100644 | ||
--- a/tests/expected_report.txt | ||
+++ b/tests/expected_report.txt | ||
@@ -5,21 +5,23 @@ FILE ERRORS WARNINGS | ||
@@ -5,43 +5,47 @@ FILE ERRORS WARNINGS | ||
---------------------------------------------------------------------- | ||
tests/input/array_indentation.php 10 0 | ||
tests/input/assignment-operators.php 4 0 | ||
|
@@ -29,7 +29,8 @@ index d1fdd9f..4b5f6e4 100644 | |
tests/input/new_with_parentheses.php 18 0 | ||
tests/input/not_spacing.php 8 0 | ||
tests/input/null_coalesce_operator.php 3 0 | ||
@@ -27,21 +29,22 @@ tests/input/optimized-functions.php 1 0 | ||
tests/input/optimized-functions.php 1 0 | ||
+tests/input/PropertyTypeHintSpacing.php 6 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Output of E 1 / 1 (100%)
FILE: tests/input/PropertyTypeHintSpacing.php
--------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------
9 | ERROR | [x] Equals sign not aligned correctly; expected 1 space but found 2 spaces
10 | ERROR | [x] There must be 1 space after the property type declaration; 2 found
10 | ERROR | [x] There must be exactly one space between type hint and property.
11 | ERROR | [x] Scope keyword "public" must be followed by a single space; found 2
11 | ERROR | [x] There must be exactly one space before type hint.
12 | ERROR | [x] There must be no whitespace between type hint nullability symbol and type hint.
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------
Time: 95ms; Memory: 8MB |
||
tests/input/return_type_on_closures.php 21 0 | ||
tests/input/return_type_on_methods.php 17 0 | ||
tests/input/semicolon_spacing.php 3 0 | ||
|
@@ -48,18 +49,18 @@ index d1fdd9f..4b5f6e4 100644 | |
tests/input/UselessConditions.php 20 0 | ||
---------------------------------------------------------------------- | ||
-A TOTAL OF 296 ERRORS AND 0 WARNINGS WERE FOUND IN 35 FILES | ||
+A TOTAL OF 349 ERRORS AND 0 WARNINGS WERE FOUND IN 38 FILES | ||
+A TOTAL OF 355 ERRORS AND 0 WARNINGS WERE FOUND IN 39 FILES | ||
---------------------------------------------------------------------- | ||
-PHPCBF CAN FIX 235 OF THESE SNIFF VIOLATIONS AUTOMATICALLY | ||
+PHPCBF CAN FIX 284 OF THESE SNIFF VIOLATIONS AUTOMATICALLY | ||
+PHPCBF CAN FIX 290 OF THESE SNIFF VIOLATIONS AUTOMATICALLY | ||
---------------------------------------------------------------------- | ||
|
||
|
||
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php | ||
index 59148a3..eb019d5 100644 | ||
index dbec9cb..dca22ed 100644 | ||
--- a/tests/fixed/example-class.php | ||
+++ b/tests/fixed/example-class.php | ||
@@ -23,14 +23,12 @@ class Example implements IteratorAggregate | ||
@@ -25,14 +25,12 @@ class Example implements IteratorAggregate | ||
{ | ||
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION; | ||
|
||
|
@@ -78,7 +79,7 @@ index 59148a3..eb019d5 100644 | |
/** @var ControlStructureSniff|int|string|null */ | ||
private $baxBax; | ||
diff --git a/tests/fixed/type-hints.php b/tests/fixed/type-hints.php | ||
index a1b1827..fb7d406 100644 | ||
index 0e952fc..9824fb0 100644 | ||
--- a/tests/fixed/type-hints.php | ||
+++ b/tests/fixed/type-hints.php | ||
@@ -10,7 +10,7 @@ use Traversable; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment for this rule and the others are on lines 360-362:
coding-standard/lib/Doctrine/ruleset.xml
Lines 360 to 362 in d025e82