Bug report
Changing method/property attributes does not trigger analysis of dependent files because PHP Attributes are not taken into account in src/Dependency/ExportedNodeResolver.php.
Although questionable, attributes are part of public API in my opinion (even though accessible only via reflection), especially for tools like PHPStan where I expect migration from annotations to attributes in the near future (PHPStorm already pushes usage of #[Deprecated], #[ArrayShape],...)
Current behaviour makes it impossible to write rules that disallow calling #[Deprecated] methods whereas the same example with @deprecated works properly.
Let's assume we have a rule that forbids calling methods that are deprecated.
Then following will happen with current behaviour.
Code snippet that reproduces the problem
<?php declare(strict_types = 1);
class Foo
{
/**
* @deprecated
*/
public static function bar(): void
{
}
}
class Foo2
{
#[Deprecated]
public static function bar(): void
{
}
}
class C
{
public function test(): void
{
// Removing @deprecated annotation will correctly "invalidate" cache
// and therefore not trigger an error
Foo::bar();
// Removing [#Deprecated] attribute will NOT "invalidate" cache
// and therefore error will still be there even though it's now OK to call the method
Foo2::bar();
}
}