diff --git a/Proton/Sniffs/CodingStandard/ForbiddenNamespacedFunctionsSniff.php b/Proton/Sniffs/CodingStandard/ForbiddenNamespacedFunctionsSniff.php new file mode 100644 index 0000000..8169578 --- /dev/null +++ b/Proton/Sniffs/CodingStandard/ForbiddenNamespacedFunctionsSniff.php @@ -0,0 +1,24 @@ + tests/out.csv; diff tests/expected_csv.txt tests/out.csv" + "test-print": "phpcs --standard=tests/phpcs.xml --report=summary tests", + "test": "phpcs --standard=tests/phpcs.xml --report=csv tests | sort -r | cut -f 2,3,4,6 -d ',' > tests/out.csv; diff tests/expected_csv.txt tests/out.csv" }, "require": { "php": "^7.1", diff --git a/tests/correct/ClassOk.php b/tests/correct/ClassOk.php index cfb7964..1005803 100644 --- a/tests/correct/ClassOk.php +++ b/tests/correct/ClassOk.php @@ -5,6 +5,7 @@ namespace Proton\Test; use Proton\Http\Request; +use function Proton\Support\phpinfo2; final class ClassOk { @@ -21,6 +22,8 @@ public function __construct(array $config) $this->foo = $config + [ 'foo' => 'bar', ]; + + phpinfo2(); } public function ping(Request $request) diff --git a/tests/expected.txt b/tests/expected.txt index b6011c2..1783575 100644 --- a/tests/expected.txt +++ b/tests/expected.txt @@ -3,11 +3,11 @@ PHP CODE SNIFFER REPORT SUMMARY ------------------------------------------------------------------------------------------------ FILE ERRORS WARNINGS ------------------------------------------------------------------------------------------------ -/Users/Username/dev/Proton/php-coding-standard/tests/wrong/Class1.php 30 0 -/Users/Username/dev/Proton/php-coding-standard/tests/wrong/ClassMetrics.php 4 0 +/Users/Username/dev/Proton/php-coding-standard/tests/wrong/Class1.php 31 3 +/Users/Username/dev/Proton/php-coding-standard/tests/wrong/ClassMetrics.php 4 2 /Users/Username/dev/Proton/php-coding-standard/tests/wrong/file.php 2 0 ------------------------------------------------------------------------------------------------ -A TOTAL OF 36 ERRORS AND 0 WARNINGS WERE FOUND IN 3 FILES +A TOTAL OF 37 ERRORS AND 5 WARNINGS WERE FOUND IN 3 FILES +------------------------------------------------------------------------------------------------ +PHPCBF CAN FIX 29 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ------------------------------------------------------------------------------------------------ -PHPCBF CAN FIX 28 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/tests/expected_csv.txt b/tests/expected_csv.txt index 15b7fe0..44a269b 100644 --- a/tests/expected_csv.txt +++ b/tests/expected_csv.txt @@ -9,26 +9,27 @@ Line,Column,Type,Source 1,1,error,SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing 8,1,error, found 1." 6,18,error,PSR12.Files.FileHeader.SpacingInsideBlock -40,1,error,PSR2.Files.EndFileNewline.NoneFound +41,1,error,PSR2.Files.EndFileNewline.NoneFound 4,1,error, found 2." +39,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed +38,13,warning,Squiz.PHP.NonExecutableCode.Unreachable 38,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed -37,13,warning,Squiz.PHP.NonExecutableCode.Unreachable 37,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed +36,9,error,Generic.PHP.LowerCaseKeyword.Found +36,9,error,Squiz.ControlStructures.LowercaseDeclaration.FoundUppercase +36,9,error,Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword +36,12,error,Squiz.NamingConventions.ValidVariableName.NotCamelCaps 36,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed -35,9,error,Generic.PHP.LowerCaseKeyword.Found -35,9,error,Squiz.ControlStructures.LowercaseDeclaration.FoundUppercase -35,9,error,Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword -35,12,error,Squiz.NamingConventions.ValidVariableName.NotCamelCaps -35,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed -33,9,error,Squiz.NamingConventions.ValidVariableName.NotCamelCaps -33,24,warning,Generic.CodeAnalysis.EmptyPHPStatement.SemicolonWithoutCodeDetected -33,24,error,SlevomatCodingStandard.PHP.UselessSemicolon.UselessSemicolon -33,24,error,Generic.Formatting.DisallowMultipleStatements.SameLine -33,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed -31,31,error,Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine -31,13,error,SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod -27,27,error,PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword -24,13,error,SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma +34,9,error,Squiz.NamingConventions.ValidVariableName.NotCamelCaps +34,24,warning,Generic.CodeAnalysis.EmptyPHPStatement.SemicolonWithoutCodeDetected +34,24,error,SlevomatCodingStandard.PHP.UselessSemicolon.UselessSemicolon +34,24,error,Generic.Formatting.DisallowMultipleStatements.SameLine +34,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed +32,31,error,Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine +32,13,error,SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod +28,27,error,PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword +25,13,error,SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma +22,9,error,Proton.CodingStandard.ForbiddenNamespacedFunctions.FoundWithAlternative 20,19,error,Generic.PHP.BacktickOperator.Found 20,14,error,Generic.PHP.BacktickOperator.Found 16,5,error,PSR12.Traits.UseDeclaration.UseAfterBrace diff --git a/tests/phpcs.xml b/tests/phpcs.xml new file mode 100644 index 0000000..c4d71f8 --- /dev/null +++ b/tests/phpcs.xml @@ -0,0 +1,18 @@ + + + + Proton PHP Coding Standard + + + + + + + + + + + + + + diff --git a/tests/wrong/Class1.php b/tests/wrong/Class1.php index c9d7d5b..4364d36 100644 --- a/tests/wrong/Class1.php +++ b/tests/wrong/Class1.php @@ -19,6 +19,7 @@ public function __construct() { echo `test`; + phpinfo2(); print_r([ 1