phpcs-import-detection
phpcs-import-detection copied to clipboard
A set of phpcs sniffs to look for unused or unimported symbols.
With configuration: ``` ``` A false positive is occurring: "Found unimported symbol 'dbDelta'." I can see `dbdelta` (lowercase) is included in `WordPressSymbols.php`. Question: Should the symbol list be case insensitive,...
PHP 8 uses `T_NAME_QUALIFIED` [as the token type](https://wiki.php.net/rfc/namespaced_names_as_token) for symbols like `Foo\Bar` (previously, each section of an imported symbol appeared as a `T_STRING` separated by `T_NS_SEPARATOR` but now it appears...
Code like this (specifically: `&`) triggers a false positive for `ImportDetection.Imports.RequireImports.Symbol`: ```php class Foo { private static $something = 'foobar'; public &function bar() { return self::$something; } } ```
Fixes https://github.com/sirbrillig/phpcs-import-detection/issues/52 Needs tests and also probably needs more work.
For a line like this: ``` use function Code\find_first_name; ``` We get the error `Found unused symbol 'function'.`
I'm trying to use the PHP8 [nullsafe operator](https://wiki.php.net/rfc/nullsafe_operator) but I'm getting an issue from PHP Code Sniffer as `ImportDetection.Imports.RequireImports.Symbol`. So in the context of a class method this is fine:...
In the following code, `Route` is imported and used, but is being reported as unused. Conversely, `Method` is used without being imported, but PHPCS does not mind. ```php
```php \DrivingTracker\registerDrive($this); // this is fine because it's fully-qualified ``` Could we have a sniff that is triggered when FQCN is found? https://github.com/sirbrillig/phpcs-import-detection/blob/572bb1dd8a6b0d15c18abef60695a049e02fac8c/ImportDetection/Sniffs/Imports/RequireImportsSniff.php#L56-L59
Many of laravel helper functions like **app()**, **request()** e.g. $credentials = request(['username', 'password']); and build in **throw new Exception()**, and some of **self-created function** etc.s are showing warning with **Found...
They seem to not be recognised: