diff --git a/.gitattributes b/.gitattributes index cb445a2..5f539cc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,10 @@ +/.cache export-ignore /.github export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore /tests export-ignore /phpunit.xml.dist export-ignore +/psalm.xml export-ignore +/psalm-baseline.xml export-ignore +/renovate.json export-ignore \ No newline at end of file diff --git a/.github/workflows/format_php.yml b/.github/workflows/format_php.yml index abc4efd..16af2ab 100644 --- a/.github/workflows/format_php.yml +++ b/.github/workflows/format_php.yml @@ -21,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.4 coverage: none tools: cs2pr - name: Get Composer cache directory diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 735e55c..ec86fcc 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -24,7 +24,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.4 coverage: none - name: Get Composer cache directory diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81f80e3..e4aafdd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,8 +25,8 @@ jobs: - "lowest" - "highest" php-version: - - "8.2" - "8.3" + - "8.4" operating-system: - "ubuntu-latest" diff --git a/.github/workflows/validator.yml b/.github/workflows/validator.yml index 211ee94..54e03ad 100644 --- a/.github/workflows/validator.yml +++ b/.github/workflows/validator.yml @@ -20,7 +20,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.4 coverage: none - name: Get Composer cache directory diff --git a/IxDFCodingStandard/Helpers/ClassHelper.php b/IxDFCodingStandard/Helpers/ClassHelper.php new file mode 100644 index 0000000..fcace7d --- /dev/null +++ b/IxDFCodingStandard/Helpers/ClassHelper.php @@ -0,0 +1,8 @@ + */ public function register(): array { - return TokenHelper::ONLY_NAME_TOKEN_CODES; + return TokenHelper::NAME_TOKEN_CODES; } /** @inheritDoc */ diff --git a/IxDFCodingStandard/Sniffs/Laravel/BladeTemplateExtractor.php b/IxDFCodingStandard/Sniffs/Laravel/BladeTemplateExtractor.php index f92ae57..19e18f3 100644 --- a/IxDFCodingStandard/Sniffs/Laravel/BladeTemplateExtractor.php +++ b/IxDFCodingStandard/Sniffs/Laravel/BladeTemplateExtractor.php @@ -4,6 +4,7 @@ use BadMethodCallException; +/** phpcs:disable IxDFCodingStandard.Laravel.NonExistingBladeTemplate.TemplateNotFound */ final class BladeTemplateExtractor { private const INVALID_METHOD_CALL = 'Invalid method call'; @@ -53,7 +54,7 @@ public function getBladeTemplateName(string $tokenContent): string throw new BadMethodCallException(self::INVALID_METHOD_CALL); } - return (string) $matches[2]; + return $matches[2]; } public function getConditionalBladeTemplateName(string $tokenContent): string @@ -69,7 +70,7 @@ public function getConditionalBladeTemplateName(string $tokenContent): string throw new BadMethodCallException(self::INVALID_METHOD_CALL); } - return (string) $matches[2]; + return $matches[2]; } public function getEachBladeTemplateName(string $tokenContent): string @@ -85,7 +86,7 @@ public function getEachBladeTemplateName(string $tokenContent): string throw new BadMethodCallException(self::INVALID_METHOD_CALL); } - return (string) $matches[1]; + return $matches[1]; } public function getFirstBladeTemplateName(string $tokenContent): string @@ -101,6 +102,6 @@ public function getFirstBladeTemplateName(string $tokenContent): string throw new BadMethodCallException(self::INVALID_METHOD_CALL); } - return (string) $matches[2]; + return $matches[2]; } } diff --git a/IxDFCodingStandard/Sniffs/Laravel/DisallowGuardedAttributeSniff.php b/IxDFCodingStandard/Sniffs/Laravel/DisallowGuardedAttributeSniff.php index facf690..55683f0 100644 --- a/IxDFCodingStandard/Sniffs/Laravel/DisallowGuardedAttributeSniff.php +++ b/IxDFCodingStandard/Sniffs/Laravel/DisallowGuardedAttributeSniff.php @@ -2,9 +2,9 @@ namespace IxDFCodingStandard\Sniffs\Laravel; +use IxDFCodingStandard\Helpers\ClassHelper; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; -use SlevomatCodingStandard\Helpers\ClassHelper; final class DisallowGuardedAttributeSniff extends AbstractScopeSniff { diff --git a/IxDFCodingStandard/Sniffs/Laravel/NonExistingBladeTemplateSniff.php b/IxDFCodingStandard/Sniffs/Laravel/NonExistingBladeTemplateSniff.php index a06a29c..dbd26da 100644 --- a/IxDFCodingStandard/Sniffs/Laravel/NonExistingBladeTemplateSniff.php +++ b/IxDFCodingStandard/Sniffs/Laravel/NonExistingBladeTemplateSniff.php @@ -46,7 +46,7 @@ public function register(): array } /** @inheritDoc */ - public function process(File $phpcsFile, $stackPtr): int // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh + public function process(File $phpcsFile, $stackPtr): int // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh { $filename = $phpcsFile->getFilename(); diff --git a/IxDFCodingStandard/Sniffs/Laravel/RequireCustomAbortMessageSniff.php b/IxDFCodingStandard/Sniffs/Laravel/RequireCustomAbortMessageSniff.php index b026874..2938cc7 100644 --- a/IxDFCodingStandard/Sniffs/Laravel/RequireCustomAbortMessageSniff.php +++ b/IxDFCodingStandard/Sniffs/Laravel/RequireCustomAbortMessageSniff.php @@ -30,7 +30,7 @@ public function register(): array } /** @param int $functionPointer */ - public function process(File $phpcsFile, $functionPointer): void // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Functions.FunctionLength.FunctionLength, SlevomatCodingStandard.Files.FunctionLength.FunctionLength, SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh + public function process(File $phpcsFile, $functionPointer): void // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh,SlevomatCodingStandard.Functions.FunctionLength.FunctionLength { $tokens = $phpcsFile->getTokens(); diff --git a/IxDFCodingStandard/Sniffs/NamingConventions/MeaningfulVariableNameSniff.php b/IxDFCodingStandard/Sniffs/NamingConventions/MeaningfulVariableNameSniff.php index 5332368..2f45bef 100644 --- a/IxDFCodingStandard/Sniffs/NamingConventions/MeaningfulVariableNameSniff.php +++ b/IxDFCodingStandard/Sniffs/NamingConventions/MeaningfulVariableNameSniff.php @@ -12,7 +12,20 @@ final class MeaningfulVariableNameSniff extends AbstractVariableSniff { /** @var array */ - public array $forbiddenNames = []; + public array $forbiddenNames = [ + // type-like names + 'bool' => 'Provide more context', + 'boolean' => 'Provide more context', + 'int' => 'Provide more context', + 'integer' => 'Provide more context', + 'float' => 'Provide more context', + 'double' => 'Provide more context', + 'str' => 'Provide more context', + 'var' => 'Provide more context', + 'arr' => 'Provide more context', + 'col' => 'Provide more context', + 'coll' => 'Provide more context', + ]; /** * Processes this test, when one of its tokens is encountered. diff --git a/composer.json b/composer.json index 77b4864..c55fdf0 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,15 @@ "license": "MIT", "type": "phpcodesniffer-standard", "require": { - "php": "^8.2", + "php": "^8.3", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "slevomat/coding-standard": "^8.22", - "squizlabs/php_codesniffer": "^3.13" + "slevomat/coding-standard": "^8.23", + "squizlabs/php_codesniffer": "^4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.87", - "phpunit/phpunit": "^11 || ^12", - "vimeo/psalm": "^6.12" + "phpunit/phpunit": "^12.3", + "vimeo/psalm": "^6.13" }, "minimum-stability": "dev", "prefer-stable": true,