-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1338Labels
Milestone
Description
Bug report
PHPStan reports a private constant as unused although its used inside an attribute on class level.
Code snippet that reproduces the problem
<?php declare(strict_types = 1);
#[\Attribute(\Attribute::TARGET_CLASS)]
class Cache
{
public function __construct(public int $ttl)
{
}
}
#[Cache(ttl: self::CACHE_TTL)]
class HelloWorld
{
private const CACHE_TTL = 60;
}See https://phpstan.org/r/c8f6c992-6fa5-442e-b704-c6073970e0e7
=> Constant HelloWorld::CACHE_TTL is unused.
Expected output
No error should be reported on PHP 8+
Did PHPStan help you today? Did it make you happy in any way?
This tiny bug aside: PHPStan is a huge benefit to any php codebase 👍 🎉