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 718f2d25a..476cb781e 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -1296,6 +1296,19 @@ class ClassLikeNodeScanner } $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 aa213ea47..bcbe39dcd 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 */