A name imported with use is never mentioned
What it finds
A use import whose name the file never mentions: the import does nothing and makes the file look as if it depended on the class. Names in documentation and block comments count as mentions, since such comments name types that tools read.
From the rule's source, unused_import.rs.
<?phpnamespace App; use App\Models\User;use App\Models\Post;tx0 reports: Post is imported but never useduse App\Contracts\{Repository, Cache as Store};use App\Docs\Documented; /** * @param Documented $d */function make(Repository $r, Store $s, $d){ return new User($r, $s, $d);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:unused-import" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:unused-import] reason="..."tx0 explain tx0/php:unused-import shows the same in the terminal. Found a false positive? Report it.