Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Apr 22, 2023
1 parent f928f19 commit a270f63
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<!-- Forbid suffix "Trait" for traits -->
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
<!-- Forbid "@inheritdoc" in favor of "@inheritDoc" annotation -->
<!-- Forbid invalid annotation names in standard PHPDoc tags -->
<rule ref="SlevomatCodingStandard.Commenting.AnnotationName"/>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
Expand Down
25 changes: 25 additions & 0 deletions tests/fixed/annotation-name.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

interface Foo
{
/**
* This method does something
*/
public function doSomething(array $options): void;

/**
* This method does not perform any action
*/
public function nothing(): void;
}

final class Bar implements Foo
{
/** @inheritDoc */
public function doSomething(array $options): void;

/** {@inheritDoc} */
public function nothing(): void;
}
25 changes: 25 additions & 0 deletions tests/input/annotation-name.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

interface Foo
{
/**
* This method does something
*/
public function doSomething(array $options): void;

/**
* This method does not perform any action
*/
public function nothing(): void;
}

final class Bar implements Foo
{
/** @inheritdoc */
public function doSomething(array $options): void;

/** {@inheritdoc} */
public function nothing(): void;
}
70 changes: 42 additions & 28 deletions tests/php74-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,73 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 1773423..9422a54 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -16,26 +16,23 @@ tests/input/constants-var.php 6 0
tests/input/ControlStructures.php 28 0
@@ -3,36 +3,38 @@
----------------------------------------------------------------------
FILE ERRORS WARNINGS
----------------------------------------------------------------------
+tests/input/annotation-name.php 8 0
tests/input/array_indentation.php 10 0
tests/input/arrow-functions-format.php 10 0
tests/input/assignment-operators.php 4 0
tests/input/attributes.php 15 0
tests/input/binary_operators.php 9 0
-tests/input/class-references.php 10 0
+tests/input/class-references.php 10 2
tests/input/ClassPropertySpacing.php 2 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
tests/input/constants-var.php 6 0
-tests/input/ControlStructures.php 28 0
+tests/input/ControlStructures.php 29 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
-tests/input/EarlyReturn.php 7 0
-tests/input/example-class.php 47 0
-tests/input/ExampleBackedEnum.php 3 0
-tests/input/Exceptions.php 1 0
+tests/input/EarlyReturn.php 6 0
+tests/input/example-class.php 44 0
-tests/input/EarlyReturn.php 6 0
-tests/input/example-class.php 44 0
+tests/input/EarlyReturn.php 7 0
+tests/input/example-class.php 47 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
tests/input/inline_type_hint_assertions.php 10 0
tests/input/LowCaseTypes.php 2 0
tests/input/namespaces-spacing.php 7 0
-tests/input/NamingCamelCase.php 9 0
+tests/input/NamingCamelCase.php 6 0
-tests/input/NamingCamelCase.php 6 0
+tests/input/NamingCamelCase.php 9 0
tests/input/negation-operator.php 2 0
tests/input/new_with_parentheses.php 19 0
tests/input/not_spacing.php 8 0
tests/input/null_coalesce_equal_operator.php 5 0
tests/input/null_coalesce_operator.php 3 0
-tests/input/null_safe_operator.php 1 0
+tests/input/null_safe_operator.php 1 0
tests/input/optimized-functions.php 1 0
-tests/input/PropertyDeclaration.php 14 0
-tests/input/return_type_on_closures.php 26 0
-tests/input/return_type_on_methods.php 22 0
+tests/input/PropertyDeclaration.php 6 0
+tests/input/return_type_on_closures.php 21 0
+tests/input/return_type_on_methods.php 17 0
-tests/input/PropertyDeclaration.php 6 0
-tests/input/return_type_on_closures.php 21 0
-tests/input/return_type_on_methods.php 17 0
+tests/input/PropertyDeclaration.php 7 0
+tests/input/return_type_on_closures.php 26 0
+tests/input/return_type_on_methods.php 22 0
tests/input/semicolon_spacing.php 3 0
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
@@ -44,17 +41,17 @@ tests/input/strings.php 3 0
@@ -41,17 +43,17 @@
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/TrailingCommaOnFunctions.php 6 0
+tests/input/TrailingCommaOnFunctions.php 2 0
-tests/input/TrailingCommaOnFunctions.php 2 0
+tests/input/TrailingCommaOnFunctions.php 4 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 9 0
+tests/input/type-hints.php 8 0
-tests/input/type-hints.php 8 0
+tests/input/type-hints.php 9 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 21 0
+tests/input/UselessConditions.php 20 0
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 453 ERRORS AND 0 WARNINGS WERE FOUND IN 48 FILES
+A TOTAL OF 417 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
-A TOTAL OF 417 ERRORS AND 0 WARNINGS WERE FOUND IN 45 FILES
+A TOTAL OF 449 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 375 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 339 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-PHPCBF CAN FIX 339 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 365 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down
25 changes: 20 additions & 5 deletions tests/php80-compatibility.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index 1773423..449da88 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -18,7 +18,6 @@ tests/input/doc-comment-spacing.php 11 0
@@ -3,12 +3,13 @@
----------------------------------------------------------------------
FILE ERRORS WARNINGS
----------------------------------------------------------------------
+tests/input/annotation-name.php 8 0
tests/input/array_indentation.php 10 0
tests/input/arrow-functions-format.php 10 0
tests/input/assignment-operators.php 4 0
tests/input/attributes.php 15 0
tests/input/binary_operators.php 9 0
-tests/input/class-references.php 10 0
+tests/input/class-references.php 10 2
tests/input/ClassPropertySpacing.php 2 0
tests/input/concatenation_spacing.php 49 0
tests/input/constants-no-lsb.php 2 0
@@ -18,7 +19,6 @@
tests/input/duplicate-assignment-variable.php 1 0
tests/input/EarlyReturn.php 7 0
tests/input/example-class.php 47 0
-tests/input/ExampleBackedEnum.php 3 0
tests/input/Exceptions.php 1 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
@@ -33,7 +32,7 @@ tests/input/null_coalesce_equal_operator.php 5 0
@@ -33,7 +33,7 @@
tests/input/null_coalesce_operator.php 3 0
tests/input/null_safe_operator.php 1 0
tests/input/optimized-functions.php 1 0
Expand All @@ -19,15 +34,15 @@ index 1773423..449da88 100644
tests/input/return_type_on_closures.php 26 0
tests/input/return_type_on_methods.php 22 0
tests/input/semicolon_spacing.php 3 0
@@ -52,9 +51,9 @@ tests/input/use-ordering.php 1 0
@@ -52,9 +52,9 @@
tests/input/useless-semicolon.php 2 0
tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 453 ERRORS AND 0 WARNINGS WERE FOUND IN 48 FILES
+A TOTAL OF 447 ERRORS AND 0 WARNINGS WERE FOUND IN 47 FILES
+A TOTAL OF 455 ERRORS AND 2 WARNINGS WERE FOUND IN 48 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 375 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 369 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 371 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


Expand Down

0 comments on commit a270f63

Please sign in to comment.