From 08413d71bbba7bd85d6770807e4baf62e980fe22 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 26 Dec 2021 02:24:01 +0200 Subject: [PATCH] Restore attributes in ClassConstantStorage This partially fixes BC break introduced in vimeo/psalm#7129 --- .../PhpVisitor/Reflector/ClassLikeNodeScanner.php | 13 +++++++++++++ src/Psalm/Storage/ClassConstantStorage.php | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php index 718f2d25a24..476cb781eef 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -1296,6 +1296,19 @@ private function visitClassConstDeclaration( } $constant_storage->description = $description; + + foreach ($stmt->attrGroups as $attr_group) { + foreach ($attr_group->attrs as $attr) { + $constant_storage->attributes[] = AttributeResolver::resolve( + $this->codebase, + $this->file_scanner, + $this->file_storage, + $this->aliases, + $attr, + $this->storage->name ?? null + ); + } + } } } diff --git a/src/Psalm/Storage/ClassConstantStorage.php b/src/Psalm/Storage/ClassConstantStorage.php index aa213ea4707..bcbe39dcdb6 100644 --- a/src/Psalm/Storage/ClassConstantStorage.php +++ b/src/Psalm/Storage/ClassConstantStorage.php @@ -39,6 +39,12 @@ class ClassConstantStorage */ public $deprecated = false; + /** + * @var list + * @psalm-suppress PossiblyUnusedProperty + */ + public $attributes = []; + /** * @var ?string */