Skip to content

Commit c0d3cd8

Browse files
committed
fix: ignore incorrect whitespace before declare error
1 parent b9795c9 commit c0d3cd8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88

9+
## 2.0.1 - 2021-06-30
10+
11+
### Fixed
12+
13+
* Ignore the `IncorrectWhitespaceBeforeDeclare` error emitted by the `SlevomatCodingStandard.TypeHints.DeclareStrictTypes` sniff.
14+
15+
In my personal projects, I usually have 2 newlines before the `declare` statement. One before the file header comment and one after. However, in tests, I have no file header comment, so there is only 1 newline before the `declare` statement. Since I like my tests to follow the same coding standard as the rest of my source, it is easiest to ignore this error.
16+
17+
918
## 2.0.0 - 2021-06-30
1019

1120
### Added

src/Ramsey/ruleset.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,14 @@
311311

312312
<!-- Require presence of declare(strict_types=1) -->
313313
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
314+
<!-- Ignore whitespace requirements for lines occurring before declare(strict_types=1).
315+
In general, we have two lines before this statement, one before the
316+
file header comment and one after. The sniff does not count any
317+
newlines from the comment block. However, in tests, we don't use
318+
file header comments, so we have only one line before this
319+
statement. This causes problems, so we just ignore this error. -->
320+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBeforeDeclare"/>
314321
<properties>
315-
<!--
316-
Two newlines accounts for 1 newline, the file header comment,
317-
and 1 more newline before declare(strict_types=1).
318-
-->
319-
<property name="linesCountBeforeDeclare" value="2"/>
320322
<property name="linesCountAfterDeclare" value="1"/>
321323
<property name="spacesCountAroundEqualsSign" value="0"/>
322324
</properties>

0 commit comments

Comments
 (0)