psalm: InvalidAttribute for SensitiveParameter when running on php 8.2 and targeting 8.1 or lower
SensitiveParameter attribute results in InvalidAttribute error when psalm runs on PHP 8.2 but targets 8.1 or below.
$ php --version
PHP 8.2.5 (cli)
$ vendor/bin/psalm
Target PHP version: 8.0 (inferred from composer.json).
ERROR: InvalidAttribute - src/Uri.php:246:11 - The class SensitiveParameter doesn't have the Attribute attribute (see https://psalm.dev/242)
#[SensitiveParameter]
When Psalm runs on PHP 8.1 or lower the error is then UndefinedAttributeClass
as expected:
Error: src/Uri.php:246:11: UndefinedAttributeClass: Attribute class SensitiveParameter does not exist (see https://psalm.dev/241)
The problem is inconsistency of result depending on runtime.
Expected result:
Psalm does not produce InvalidAttribute
error when running on PHP 8.2 but targeting 8.1 or below.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (2 by maintainers)
Commits related to this issue
- Merge #453 - Fix ReplaceStatement property type Pull-request: #453 Signed-off-by: William Desportes <williamdes@wdes.fr> — committed to phpmyadmin/sql-parser by williamdes a year ago
I can see attributes were moved to a separate stub file in #9920 and included on php 8.0 and up. Available since psalm 5.13.0
They are not included for target versions below 8.0 which is fine by me but might be an issue for others i suppose.
Btw, there is another similar attribute coming with php 8.3 -
Override
. See https://wiki.php.net/rfc/marking_overriden_methods