The rules() method has fixed (better say "side effects free") result -- it uses fixed values only. Sure, it calls getPhoneNumberRules() from a trait but it also returns fixed array (always the same). It does not make changes anywhere else (internal state or external storage).

The messages() method calls a method from a trait that calls __() to get translated message... that can come from a different source (a DB, a file) and therefore potentially can throw exceptions if a storage (file/DB) is not readable. The IDE does not know for sure if __() makes changes to a file/DB -- it's not annotated as pure and PhpStorm cannot make such decision from the methods that it uses.


P.S. If this inspection annoys you (which I can understand) then I suggest you just ignore such inspection and lower its severity in PhpStorm Settings to "No highlighting, only fix" (Settings (Preferences on macOS) | Editor | Inspections | PHP | Attributes | '#[Pure]' attribute can be added)

Answer from LazyOne on Stack Overflow
🌐
JetBrains
blog.jetbrains.com › phpstorm › 2020 › 10 › phpstorm-2020-3-eap-4
PhpStorm 2020.3 EAP #4: Custom PHP 8 Attributes | The PhpStorm Blog
June 15, 2021 - If the function is marked as pure, ... highlight the unsafe code. With this attribute, you can specify which values a function accepts as parameters and which it can return....
Discussions

Using PhpStorm Php 8 attributes
Psalm apparently added support for these . There was already equivalent functionality available via Psalm's own annotations so it sounds like it was just a case of mapping them to their PhpStorm equivalents. Psalm has also added similar attributes via a package, and as someone who uses Psalm and not PhpStorm that's obviously a more attractive option for me. Also, it has the advantage it can run in a CI environment. I'm also inclined to agree with the creator of Psalm that for ArrayShape the docblock version supported by Psalm is more succinct. More on reddit.com
🌐 r/PHP
20
18
February 27, 2021
PhpStorm 2020.3 will come with several PHP 8 attributes: #[ArrayShape], #[ExpectedValues], #[NoReturn], #[Pure], #[Deprecated], #[Immutable]
The attribute wars, begun, they have. More on reddit.com
🌐 r/PHP
61
114
October 26, 2020
🌐
GitHub
github.com › JetBrains › phpstorm-attributes
GitHub - JetBrains/phpstorm-attributes: PhpStorm specific attributes · GitHub
Use these PHP 8 attributes in PhpStorm to get more advanced code completion and analysis.
Starred by 414 users
Forked by 11 users
Languages   PHP
🌐
PHP
php.net › manual › en › language.attributes.overview.php
PHP: Attributes overview - Manual
Attributes enable the decoupling of a feature's implementation from its usage. While interfaces define structure by enforcing methods, attributes provide metadata across multiple elements, including methods, functions, properties, and constants.
🌐
Psalm
psalm.dev › articles › php-8-attributes
Psalm supports PHP 8 Attributes
It’s a little less obvious that attributes are appropriate for use with static analysis tools (where no runtime reflection is needed). It boils down to aesthetics: would you rather see something like functional purity annotated with PHP 8 Attributes: use Psalm\Pure; #[Pure] function foo(int $i) : int {...}
🌐
PHP.Watch
php.watch › versions › 8.0 › attributes
Attributes - PHP 8.0 • PHP.Watch
One of the biggest new changes in PHP 8 is the Attributes support. Attributes help to add meta-data to PHP functions, parameters, classes, class methods, constants, properties, closures, and even anonymous classes.
🌐
GitHub
github.com › JetBrains › phpstorm-attributes › blob › master › src › Pure.php
phpstorm-attributes/src/Pure.php at master · JetBrains/phpstorm-attributes
namespace JetBrains\PhpStorm; · use Attribute; · /** * The attribute marks the function that has no impact on the program state or passed parameters used after the function execution.
Author   JetBrains
Find elsewhere
🌐
Stitcher
stitcher.io › blog › attributes-in-php-8
PHP 8: Attributes | Stitcher.io
September 3, 2020 - First of all, custom attributes are simple classes, annotated themselves with the #[Attribute] attribute; this base Attribute used to be called PhpAttribute in the original RFC, but was changed with another RFC afterwards.
🌐
GitHub
github.com › php-static-analysis › attributes › blob › main › doc › Pure.md
attributes/doc/Pure.md at main · php-static-analysis/attributes
This attribute is the equivalent of the @pure annotation for class methods and functions. The attribute accepts no arguments. <?php use PhpStaticAnalysis\Attributes\Pure; class PureExample { #[Pure] // this function is pure public static function ...
Author   php-static-analysis
🌐
Reddit
reddit.com › r/php › phpstorm 2020.3 will come with several php 8 attributes: #[arrayshape], #[expectedvalues], #[noreturn], #[pure], #[deprecated], #[immutable]
r/PHP on Reddit: PhpStorm 2020.3 will come with several PHP 8 attributes: #[ArrayShape], #[ExpectedValues], #[NoReturn], #[Pure], #[Deprecated], #[Immutable]
October 26, 2020 - I do agree that using Attributes over comments purely for analysis hints seems a bit silly! ... #[Deprecated] is the only one where having it as attributes might make sense, so you can collect it programmatically and to pave a better way of handling deprecations in both development and production than E_DEPRECATED. Yet having a PHPStorm namespaced Deprecated class seems bad - either it should be a global Deprecated class in PHP itself (via an RFC), or a class/component the PHP community can agree on so not every framework and component has its own version of such a class.
🌐
PHP
wiki.php.net › rfc › attributes
PHP: rfc:attributes
April 21, 2016 - Attributes (or annotations) are a form of syntactic metadata that can be added to language classes, functions, etc. PHP offers only a single form of such metadata - doc-comments. This is just a string and to keep some structured information, we had to use some pseudo-language.
🌐
DEV Community
dev.to › inspector › php-attributes-how-to-use-php-attributes-and-create-custom-attribute-classes-fast-tips-7nf
PHP Attributes: how to use PHP Attributes and create custom attribute classes – Fast Tips - DEV Community
August 26, 2024 - As mentioned before adding the attribute to the property have no impact during execution. But we can now retrive this information using reflection to take some action eventually. The most used PHP frameworks like Symfony and Laravel are already adopting attributes to basically replace "Annotations".
🌐
Medium
itsimiro.medium.com › unlocking-the-power-of-attributes-in-php-a6af57225bbf
Unlocking the Power of Attributes in PHP | by itsimiro | Medium
May 22, 2024 - PHP attributes are a robust and flexible way to improve your code by embedding metadata directly into it. They improve readability, centralize configuration, provide type safety, reduce boilerplate, improve integration with frameworks, and increase ...
🌐
Exakat
exakat.io › home › php 8 attribute usage in 2023
PHP 8 Attribute usage in 2023 - Exakat
February 13, 2025 - Last year, we reported attributes lists, edited by independant editors, such as PHPStorm, Navarr, PHP Language Extensions. Except for Pure, which is in the Top 5, those attributes are used but with a very low level of popularity.
🌐
DEV Community
dev.to › nasrulhazim › working-with-php-attributes-dos-donts-2g0l
Working with PHP Attributes: Do’s & Don’ts - DEV Community
November 14, 2024 - Attributes in PHP simplify code configuration by allowing you to annotate code elements with metadata directly, potentially reducing boilerplate in frameworks like Laravel.
🌐
DEV Community
dev.to › icolomina › using-php-attributes-easily-2fpo
Using PHP attributes easily - DEV Community
November 11, 2025 - Full Stack Developer. PHP/Symfony - Angular ... Hi Yannick, Thanks to you too. You can use attributes when you want to add metadata to a class but it is not necessary the class to follow a contract. If the class has to follow a contract then you would have to use an interface.