-
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.
Incorporating changes to our tests.
- Loading branch information
Showing
3 changed files
with
75 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
.PHONY: test test-report test-fix | ||
|
||
PHP_74_OR_NEWER=`php -r "echo (int) version_compare(PHP_VERSION, '7.4', '>=');"` | ||
|
||
test: test-report test-fix | ||
|
||
test-report: vendor | ||
@vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff tests/expected_report.txt phpcs.log | ||
|
||
@if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply tests/php-compatibility.patch; fi | ||
@vendor/bin/phpcs `find tests/input/* | sort` --report=summary --report-file=phpcs.log; diff tests/expected_report.txt phpcs.log; if [ $$? -ne 0 ] && [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; exit 1; fi | ||
@if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi | ||
|
||
test-fix: vendor | ||
@if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply tests/php-compatibility.patch; fi | ||
@cp -R tests/input/ tests/input2/ | ||
@vendor/bin/phpcbf tests/input2; diff tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/; exit 1; fi | ||
@rm -rf tests/input2/ | ||
@vendor/bin/phpcbf tests/input2; diff tests/input2 tests/fixed; if [ $$? -ne 0 ]; then rm -rf tests/input2/ && if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi; exit 1; fi | ||
@rm -rf tests/input2/ && if [ $(PHP_74_OR_NEWER) -eq 1 ]; then git apply -R tests/php-compatibility.patch; fi | ||
|
||
vendor: composer.json | ||
composer update |
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
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,67 @@ | ||
diff --git a/tests/expected_report.txt b/tests/expected_report.txt | ||
index 855edfd..5653a39 100644 | ||
--- a/tests/expected_report.txt | ||
+++ b/tests/expected_report.txt | ||
@@ -12,7 +12,7 @@ tests/input/constants-var.php 4 0 | ||
tests/input/doc-comment-spacing.php 10 0 | ||
tests/input/duplicate-assignment-variable.php 1 0 | ||
tests/input/EarlyReturn.php 6 0 | ||
-tests/input/example-class.php 45 0 | ||
+tests/input/example-class.php 48 0 | ||
tests/input/forbidden-comments.php 8 0 | ||
tests/input/forbidden-functions.php 6 0 | ||
tests/input/inline_type_hint_assertions.php 7 0 | ||
@@ -32,15 +32,15 @@ tests/input/superfluous-naming.php 11 0 | ||
tests/input/test-case.php 8 0 | ||
tests/input/trailing_comma_on_array.php 1 0 | ||
tests/input/traits-uses.php 11 0 | ||
-tests/input/type-hints.php 4 0 | ||
+tests/input/type-hints.php 5 0 | ||
tests/input/UnusedVariables.php 1 0 | ||
tests/input/use-ordering.php 1 0 | ||
tests/input/useless-semicolon.php 2 0 | ||
tests/input/UselessConditions.php 20 0 | ||
---------------------------------------------------------------------- | ||
-A TOTAL OF 290 ERRORS AND 0 WARNINGS WERE FOUND IN 34 FILES | ||
+A TOTAL OF 294 ERRORS AND 0 WARNINGS WERE FOUND IN 34 FILES | ||
---------------------------------------------------------------------- | ||
-PHPCBF CAN FIX 229 OF THESE SNIFF VIOLATIONS AUTOMATICALLY | ||
+PHPCBF CAN FIX 233 OF THESE SNIFF VIOLATIONS AUTOMATICALLY | ||
---------------------------------------------------------------------- | ||
|
||
|
||
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php | ||
index 195d963..a2ee5c8 100644 | ||
--- a/tests/fixed/example-class.php | ||
+++ b/tests/fixed/example-class.php | ||
@@ -24,14 +24,12 @@ class Example implements IteratorAggregate | ||
{ | ||
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION; | ||
|
||
- /** @var int|null */ | ||
- private $foo; | ||
+ private ?int $foo = null; | ||
|
||
/** @var string[] */ | ||
- private $bar; | ||
+ private array $bar; | ||
|
||
- /** @var bool */ | ||
- private $baz; | ||
+ private bool $baz; | ||
|
||
/** @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 | ||
--- a/tests/fixed/type-hints.php | ||
+++ b/tests/fixed/type-hints.php | ||
@@ -10,7 +10,7 @@ use Traversable; | ||
class TraversableTypeHints | ||
{ | ||
/** @var Traversable */ | ||
- private $parameter; | ||
+ private Traversable $parameter; | ||
|
||
/** | ||
* @param Iterator $iterator |