coding-standard
coding-standard copied to clipboard
Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs
Here $bar is considered an unused variable: ```php $foo = new class () { public array $bar = []; }; ``` This also happens if I use the property in...
Given this config ```xml ``` And this analysed file ```php
It would be nice to have detection like phpstorm, because $bankAccount variable assigned on first line is never read, only redefined later on, thus its unused and the result of...
`SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse` thinks the import `use function Psl\Type\null;` is unused when we use `null()` in the code. (https://github.com/slevomat/coding-standard/issues/1613#issuecomment-1733307645)
- Related: https://github.com/slevomat/coding-standard/issues/1617 This is almost (but not quite) a request for the opposite of [`SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces`](https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesuseonlywhitelistednamespaces): I want to require all third-party namespaces to use aliases. To that end, I...
I would like to use arbitrary error messages for [`SlevomatCodingStandard.PHP.ForbiddenClasses.forbiddenClasses`](https://github.com/slevomat/coding-standard/blob/master/doc/php.md#slevomatcodingstandardphpforbiddenclasses-), because I want to tell a developer what to do instead, but it's not necessarily a "fixable" alternative. For example,...
I want specific classes to always be aliased with the same names. For example, I want these classes to _always_ and _only_ be aliased like this: ```php use Symfony\Component\Filesystem\Filesystem as...
To close a file created with `SplFileObject`, the variable should be set to NULL. For example: ```php class X { public function wrt ( ): void { $sfo = new...
When reviewing PRs in VSCode, I get the following linter error: ``` Class name App\Actions\MyAction does not match filepath STDIN. (SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName)phpcs ``` I believe this is due to the diffed...
Hi, i'm developing an application using CakePHP4. When generating a template for viewing a database Table that has a nullable field in it, phpcs quits with a fatal error. This...