diff --git a/psalm.xml.dist b/psalm.xml.dist
index e0af21bf5..6b2ce178d 100644
--- a/psalm.xml.dist
+++ b/psalm.xml.dist
@@ -23,6 +23,10 @@
+
+
+
+
diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php
index 74a2f5915..92321592c 100644
--- a/src/Psalm/Internal/LanguageServer/LanguageServer.php
+++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php
@@ -173,7 +173,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
* @param int|null $processId The process Id of the parent process that started the server.
* Is null if the process has not been started by another process. If the parent process is
* not alive then the server should exit (see exit notification) its process.
- * @return Promise
+ * @return Promise
* @psalm-suppress PossiblyUnusedMethod
*/
public function initialize(
diff --git a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php
index 181f522e0..38c16b364 100644
--- a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php
+++ b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php
@@ -171,7 +171,7 @@ class TextDocument
*
* @param TextDocumentIdentifier $textDocument The text document
* @param Position $position The position inside the text document
- * @return Promise
+ * @return Promise
*/
public function definition(TextDocumentIdentifier $textDocument, Position $position): Promise
{
@@ -223,7 +223,7 @@ class TextDocument
*
* @param TextDocumentIdentifier $textDocument The text document
* @param Position $position The position inside the text document
- * @return Promise
+ * @return Promise
*/
public function hover(TextDocumentIdentifier $textDocument, Position $position): Promise
{
@@ -275,7 +275,7 @@ class TextDocument
*
* @param TextDocumentIdentifier The text document
* @param Position $position The position
- * @return Promise
+ * @return Promise
*/
public function completion(TextDocumentIdentifier $textDocument, Position $position): Promise
{
diff --git a/src/Psalm/Internal/Stubs/SabreEvent.php b/src/Psalm/Internal/Stubs/SabreEvent.php
new file mode 100644
index 000000000..c0c844567
--- /dev/null
+++ b/src/Psalm/Internal/Stubs/SabreEvent.php
@@ -0,0 +1,20 @@
+ $gen
+ * @return Promise
+ */
+function coroutine(callable $gen) : Promise {}
+
+/**
+ * @template TReturn
+ */
+class Promise {
+ /**
+ * @return TReturn
+ */
+ function wait() {}
+}
diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php
index 136b6a96b..ecacc48ae 100644
--- a/src/Psalm/Type/Atomic/TNamedObject.php
+++ b/src/Psalm/Type/Atomic/TNamedObject.php
@@ -57,9 +57,6 @@ class TNamedObject extends Atomic
*/
public function toNamespacedString($namespace, array $aliased_classes, $this_class, $use_phpdoc_format)
{
- $class_parts = explode('\\', $this->value);
- $class_name = array_pop($class_parts);
-
$intersection_types = $this->getNamespacedIntersectionTypes(
$namespace,
$aliased_classes,
@@ -71,8 +68,12 @@ class TNamedObject extends Atomic
return 'self' . $intersection_types;
}
- if ($namespace && preg_match('/^' . preg_quote($namespace) . '\\\\' . $class_name . '$/i', $this->value)) {
- return $class_name . $intersection_types;
+ if ($namespace && stripos($this->value, $namespace . '\\') === 0) {
+ return preg_replace(
+ '/^' . preg_quote($namespace . '\\') . '/i',
+ '',
+ $this->value
+ ) . $intersection_types;
}
if (!$namespace && stripos($this->value, '\\') === false) {