From e75d8d00bbabafb567e0de90e7add8e9a8a5148a Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Tue, 18 Dec 2018 01:14:19 -0500 Subject: [PATCH] Improve result of "static" type-to-string --- src/Psalm/Type/Atomic/TGenericObject.php | 2 +- src/Psalm/Type/Atomic/TNamedObject.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php index 5e0ec5148..03b0d39e1 100644 --- a/src/Psalm/Type/Atomic/TGenericObject.php +++ b/src/Psalm/Type/Atomic/TGenericObject.php @@ -36,7 +36,7 @@ class TGenericObject extends TNamedObject * @param int $php_major_version * @param int $php_minor_version * - * @return string + * @return string|null */ public function toPhpString( $namespace, diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php index ecacc48ae..8a7cdfd9c 100644 --- a/src/Psalm/Type/Atomic/TNamedObject.php +++ b/src/Psalm/Type/Atomic/TNamedObject.php @@ -64,6 +64,10 @@ class TNamedObject extends Atomic $use_phpdoc_format ); + if ($this->value === 'static') { + return 'static'; + } + if ($this->value === $this_class) { return 'self' . $intersection_types; } @@ -94,7 +98,7 @@ class TNamedObject extends Atomic * @param int $php_major_version * @param int $php_minor_version * - * @return string + * @return string|null */ public function toPhpString( $namespace, @@ -103,12 +107,16 @@ class TNamedObject extends Atomic $php_major_version, $php_minor_version ) { + if ($this->value === 'static') { + return null; + } + return $this->toNamespacedString($namespace, $aliased_classes, $this_class, false); } public function canBeFullyExpressedInPhp() { - return true; + return $this->value !== 'static'; } /**