From 57395074618d7ac7fbc03dff48d32eeeb40d96ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Nov 2024 10:44:59 +0100 Subject: [PATCH 1/3] Properly comply with PHPCS naming conventions Note: I've not changed the `composer.json` file, but it could also be considered to leave the sniff namespace the same and to change the `"Exercism\\": "src",` config in the `composer.json` file to `"Exercism\\": "src\\Exercism",`. --- phpcs.xml | 2 +- .../Sniffs/StrictTypes/ExplainStrictTypesSniff.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{ => Exercism}/Sniffs/StrictTypes/ExplainStrictTypesSniff.php (97%) diff --git a/phpcs.xml b/phpcs.xml index 99478d5a..c2d9de5f 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -44,7 +44,7 @@ - + */*Test\.php */.meta/*\.php src/* diff --git a/src/Sniffs/StrictTypes/ExplainStrictTypesSniff.php b/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php similarity index 97% rename from src/Sniffs/StrictTypes/ExplainStrictTypesSniff.php rename to src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php index 32ee71e2..dbc95526 100644 --- a/src/Sniffs/StrictTypes/ExplainStrictTypesSniff.php +++ b/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Exercism\Sniffs\StrictTypes; +namespace Exercism\Exercism\Sniffs\StrictTypes; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Fixer; From 448baf49eef25ed7b687a815fa2feb77fc34ba7b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Nov 2024 10:46:43 +0100 Subject: [PATCH 2/3] ExplainStrictTypesSniff: use proper error code The class name is already translated to a sniff name, so no need to duplicate it. Also not a good idea to use backslashes in the error code as that makes configuration in the XML file more fiddly. --- src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php b/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php index dbc95526..374b3313 100644 --- a/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php +++ b/src/Exercism/Sniffs/StrictTypes/ExplainStrictTypesSniff.php @@ -57,7 +57,7 @@ public function process(File $phpcsFile, $stackPtr): void $phpcsFile->addFixableError( 'Missing explanation of declaration of strict types.', $stackPtr - 1, - self::class + 'Missing' ); $this->fix(); } From 212c4877ef8f9f70a4df5b176d3b4f5edd98f35c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 15 Nov 2024 10:47:50 +0100 Subject: [PATCH 3/3] PHPCS config: include sniff from installed standard by name --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index c2d9de5f..c88f737e 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -34,7 +34,7 @@ */concept/city-office/* */concept/windowing-system/* - + */.meta/*\.php */concept/* */hello-world/*