From 2e9fbd456995d185af46c296c78faaaa305f01aa Mon Sep 17 00:00:00 2001 From: Yurun Date: Sun, 19 Jul 2026 09:30:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B7=B3=E8=BF=87=20trait=20=E7=9A=84?= =?UTF-8?q?=E9=9D=99=E6=80=81=E5=B1=9E=E6=80=A7=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=BB=A5=E9=81=BF=E5=85=8D=20PHP=20=E5=BC=83=E7=94=A8=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Translator.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Translator.php b/src/Translator.php index e89d42fa..06b02977 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -866,6 +866,16 @@ CODE; $code .= '// static property ' . PHP_EOL; foreach ($this->symbols->classes() as $classDef) { + // Traits are never instantiated on their own; their static properties + // live on the classes that use them (where the members are flattened). + // Initialising a default on the trait itself would write to the trait's + // static property table and, on PHP >= 8.3, trigger a + // "Accessing static trait property" deprecation when the value is read + // through `self::` from a consuming class. Skip traits here; the + // consuming classes still initialise their own (flattened) copies. + if ($classDef->trait) { + continue; + } foreach ($classDef->properties as $property) { if (!$property->isStatic() || $property->default === null) { continue;