-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic/RequireStrictTypes: add warning for when value is 0
Strict types is disabled when the value for the `strict_types` directive is `0`. As this sniff is supposed to be about enforcing the use of `strict_types`, `strict_types` declarations which turn the feature off should be flagged as well. Implemented with a separate error code to allow for selectively turning this warning off. Includes dedicated tests.
- Loading branch information
Showing
11 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare(strict_types=0); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.11.inc.fixed
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.12.inc
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare( strict_types = /*comment*/ 0 ); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.12.inc.fixed
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare( strict_types = /*comment*/ 1 ); | ||
|
||
// some code |
3 changes: 3 additions & 0 deletions
3
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.13.inc
This file contains 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,3 @@ | ||
<?php | ||
// Safeguard sniff handles parse error/live coding correctly. | ||
declare(strict_types= |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.14.inc
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare( strict_types = 0, encoding='utf-8' ); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.14.inc.fixed
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare( strict_types = 1, encoding='utf-8' ); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.15.inc
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare(encoding='utf-8', strict_types=0); | ||
|
||
// some code |
5 changes: 5 additions & 0 deletions
5
src/Standards/Generic/Tests/PHP/RequireStrictTypesUnitTest.15.inc.fixed
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare(encoding='utf-8', strict_types=1); | ||
|
||
// some code |
This file contains 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