1
0
Fork 0

Fix variable type from method return value, add tests (#393)

pull/392/head
Rob Lourens 2017-06-10 02:10:15 -07:00 committed by Felix Becker
parent 7b72b38fd9
commit f10680e441
53 changed files with 264 additions and 61 deletions

View File

@ -0,0 +1,11 @@
<?php
class FooClass {
public function foo(): FooClass {
return $this;
}
}
$fc = new FooClass();
$foo = $fc->foo();
$foo->

View File

@ -0,0 +1,12 @@
<?php
class FooClass {
public static function staticFoo(): FooClass {
return new FooClass();
}
public function bar() { }
}
$foo = FooClass::staticFoo();
$foo->

View File

@ -623,6 +623,16 @@ class DefinitionResolver
} }
} }
// MEMBER CALL EXPRESSION/SCOPED PROPERTY CALL EXPRESSION
// The type of the member/scoped property call expression is the type of the method, so resolve the
// type of the callable expression.
if ($expr instanceof Node\Expression\CallExpression && (
$expr->callableExpression instanceof Node\Expression\MemberAccessExpression ||
$expr->callableExpression instanceof Node\Expression\ScopedPropertyAccessExpression)
) {
return $this->resolveExpressionNodeToType($expr->callableExpression);
}
// MEMBER ACCESS EXPRESSION // MEMBER ACCESS EXPRESSION
if ($expr instanceof Node\Expression\MemberAccessExpression) { if ($expr instanceof Node\Expression\MemberAccessExpression) {
if ($expr->memberName instanceof Node\Expression) { if ($expr->memberName instanceof Node\Expression) {

View File

@ -57,7 +57,7 @@ class LanguageServerTest extends TestCase
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) { if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
if ($msg->body->params->type === MessageType::ERROR) { if ($msg->body->params->type === MessageType::ERROR) {
$promise->reject(new Exception($msg->body->params->message)); $promise->reject(new Exception($msg->body->params->message));
} else if (strpos($msg->body->params->message, 'All 27 PHP files parsed') !== false) { } else if (preg_match('/All \d+ PHP files parsed/', $msg->body->params->message)) {
$promise->fulfill(); $promise->fulfill();
} }
} }
@ -103,7 +103,7 @@ class LanguageServerTest extends TestCase
if ($promise->state === Promise::PENDING) { if ($promise->state === Promise::PENDING) {
$promise->reject(new Exception($msg->body->params->message)); $promise->reject(new Exception($msg->body->params->message));
} }
} else if (strpos($msg->body->params->message, 'All 27 PHP files parsed') !== false) { } else if (preg_match('/All \d+ PHP files parsed/', $msg->body->params->message)) {
$promise->fulfill(); $promise->fulfill();
} }
} }

View File

@ -499,6 +499,50 @@ class CompletionTest extends TestCase
], true), $items); ], true), $items);
} }
public function testMethodReturnType()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/method_return_type.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(10, 6)
)->wait();
$this->assertCompletionsListSubset(new CompletionList([
new CompletionItem(
'foo',
CompletionItemKind::METHOD,
'\FooClass',
null,
null,
null,
null,
null
)
], true), $items);
}
public function testStaticMethodReturnType()
{
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_method_return_type.php');
$this->loader->open($completionUri, file_get_contents($completionUri));
$items = $this->textDocument->completion(
new TextDocumentIdentifier($completionUri),
new Position(11, 6)
)->wait();
$this->assertCompletionsListSubset(new CompletionList([
new CompletionItem(
'bar',
CompletionItemKind::METHOD,
'mixed',
null,
null,
null,
null,
null
)
], true), $items);
}
private function assertCompletionsListSubset(CompletionList $subsetList, CompletionList $list) private function assertCompletionsListSubset(CompletionList $subsetList, CompletionList $list)
{ {
foreach ($subsetList->items as $expectedItem) { foreach ($subsetList->items as $expectedItem) {

View File

@ -132,8 +132,7 @@ class ValidationTest extends TestCase
} elseif ($propertyName === 'extends') { } elseif ($propertyName === 'extends') {
$definition->$propertyName = $definition->$propertyName ?? []; $definition->$propertyName = $definition->$propertyName ?? [];
} elseif ($propertyName === 'type' && $definition->type !== null) { } elseif ($propertyName === 'type' && $definition->type !== null) {
// Class info is not captured by json_encode. It's important for 'type'. $defsForAssert[$fqn]['type__tostring'] = (string)$definition->type;
$defsForAssert[$fqn]['type__class'] = get_class($definition->type);
} }
$defsForAssert[$fqn][$propertyName] = $definition->$propertyName; $defsForAssert[$fqn][$propertyName] = $definition->$propertyName;

View File

@ -69,7 +69,7 @@
}, },
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints" "containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\self",
"type": {}, "type": {},
"declarationLine": "public function getSelf(): self {", "declarationLine": "public function getSelf(): self {",
"documentation": null "documentation": null
@ -88,7 +88,7 @@
}, },
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints" "containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\String_", "type__tostring": "string",
"type": {}, "type": {},
"declarationLine": "public function getName(): string {", "declarationLine": "public function getName(): string {",
"documentation": null "documentation": null
@ -107,7 +107,7 @@
}, },
"containerName": "Fixtures\\Prophecy\\WithReturnTypehints" "containerName": "Fixtures\\Prophecy\\WithReturnTypehints"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\parent",
"type": {}, "type": {},
"declarationLine": "public function getParent(): parent {", "declarationLine": "public function getParent(): parent {",
"documentation": null "documentation": null

View File

@ -33,7 +33,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Array_", "type__tostring": "string[]",
"type": {}, "type": {},
"declarationLine": "protected $foo;", "declarationLine": "protected $foo;",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "TestNamespace\\A" "containerName": "TestNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Integer", "type__tostring": "int",
"type": {}, "type": {},
"declarationLine": "public $a;", "declarationLine": "public $a;",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "TestNamespace\\TestClass" "containerName": "TestNamespace\\TestClass"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public $testProperty;", "declarationLine": "public $testProperty;",
"documentation": null "documentation": null
@ -77,7 +77,7 @@
}, },
"containerName": "TestNamespace\\TestClass" "containerName": "TestNamespace\\TestClass"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function testMethod($testParameter)", "declarationLine": "public function testMethod($testParameter)",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public static function suite()", "declarationLine": "public static function suite()",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public static function suite()", "declarationLine": "public static function suite()",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public static function suite()", "declarationLine": "public static function suite()",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function suite()", "declarationLine": "public function suite()",
"documentation": null "documentation": null

View File

@ -55,7 +55,7 @@
}, },
"containerName": "MyNamespace\\Mbstring" "containerName": "MyNamespace\\Mbstring"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\MyNamespace\\PHP_INT_MAX",
"type": {}, "type": {},
"declarationLine": "const MB_CASE_FOLD = PHP_INT_MAX;", "declarationLine": "const MB_CASE_FOLD = PHP_INT_MAX;",
"documentation": null "documentation": null

View File

@ -37,7 +37,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b ($a = MY_CONSTANT);", "declarationLine": "function b ($a = MY_CONSTANT);",
"documentation": null "documentation": null

View File

@ -37,7 +37,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Array_", "type__tostring": "\\__CLASS__[]",
"type": {}, "type": {},
"declarationLine": "private static $deprecationsTriggered;", "declarationLine": "private static $deprecationsTriggered;",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "static function a() {", "declarationLine": "static function a() {",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "static function a() {", "declarationLine": "static function a() {",
"documentation": null "documentation": null

View File

@ -73,7 +73,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public static function getInitializer(ClassLoader $loader)", "declarationLine": "public static function getInitializer(ClassLoader $loader)",
"documentation": null "documentation": null

View File

@ -64,7 +64,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function testRequest()", "declarationLine": "public function testRequest()",
"documentation": null "documentation": null

View File

@ -55,7 +55,7 @@
}, },
"containerName": "MyNamespace\\ParseErrorsTest" "containerName": "MyNamespace\\ParseErrorsTest"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function setUp()", "declarationLine": "public function setUp()",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\ParseErrorsTest" "containerName": "MyNamespace\\ParseErrorsTest"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function setAccount(AccountInterface $account)", "declarationLine": "public function setAccount(AccountInterface $account)",
"documentation": null "documentation": null

View File

@ -0,0 +1,7 @@
<?php
class FooClass {
public function foo(): FooClass {
return $this;
}
}

View File

@ -0,0 +1,46 @@
{
"references": {
"FooClass": [
"./methodReturnType.php"
]
},
"definitions": {
"FooClass": {
"fqn": "FooClass",
"extends": [],
"isGlobal": true,
"isStatic": false,
"canBeInstantiated": true,
"symbolInformation": {
"name": "FooClass",
"kind": 5,
"location": {
"uri": "./methodReturnType.php"
},
"containerName": ""
},
"type": null,
"declarationLine": "class FooClass {",
"documentation": null
},
"FooClass->foo()": {
"fqn": "FooClass->foo()",
"extends": [],
"isGlobal": false,
"isStatic": false,
"canBeInstantiated": false,
"symbolInformation": {
"name": "foo",
"kind": 6,
"location": {
"uri": "./methodReturnType.php"
},
"containerName": "FooClass"
},
"type__tostring": "\\FooClass",
"type": {},
"declarationLine": "public function foo(): FooClass {",
"documentation": null
}
}
}

View File

@ -64,7 +64,7 @@
}, },
"containerName": "MyNamespace1\\B" "containerName": "MyNamespace1\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -121,7 +121,7 @@
}, },
"containerName": "MyNamespace2\\A" "containerName": "MyNamespace2\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -33,7 +33,7 @@
}, },
"containerName": "Foo" "containerName": "Foo"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\Iterator",
"type": {}, "type": {},
"declarationLine": "public function fn()", "declarationLine": "public function fn()",
"documentation": "Foo" "documentation": "Foo"

View File

@ -33,7 +33,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null

View File

@ -55,7 +55,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -76,7 +76,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -37,7 +37,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -37,7 +37,7 @@
}, },
"containerName": "MyNamespace" "containerName": "MyNamespace"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function init(Hi $view)", "declarationLine": "function init(Hi $view)",
"documentation": null "documentation": null

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -97,7 +97,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -33,7 +33,7 @@
}, },
"containerName": "MyClass" "containerName": "MyClass"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\String_", "type__tostring": "string",
"type": {}, "type": {},
"declarationLine": "protected $mainPropertyName;", "declarationLine": "protected $mainPropertyName;",
"documentation": "The name of the main property, or NULL if there is none." "documentation": "The name of the main property, or NULL if there is none."

View File

@ -33,7 +33,7 @@
}, },
"containerName": "MyClass" "containerName": "MyClass"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\String_", "type__tostring": "string",
"type": {}, "type": {},
"declarationLine": "protected $mainPropertyName;", "declarationLine": "protected $mainPropertyName;",
"documentation": "The name of the main property, or NULL if there is none." "documentation": "The name of the main property, or NULL if there is none."

View File

@ -40,7 +40,7 @@
}, },
"containerName": "TestNamespace" "containerName": "TestNamespace"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\TestNamespace\\TestClass",
"type": {}, "type": {},
"declarationLine": "function whatever(TestClass $param): TestClass2 {", "declarationLine": "function whatever(TestClass $param): TestClass2 {",
"documentation": "Aute duis elit reprehenderit tempor cillum proident anim laborum eu laboris reprehenderit ea incididunt." "documentation": "Aute duis elit reprehenderit tempor cillum proident anim laborum eu laboris reprehenderit ea incididunt."

View File

@ -58,7 +58,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "static function a() {", "declarationLine": "static function a() {",
"documentation": null "documentation": null

View File

@ -40,7 +40,7 @@
}, },
"containerName": "A" "containerName": "A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\String_", "type__tostring": "string",
"type": {}, "type": {},
"declarationLine": "static $a;", "declarationLine": "static $a;",
"documentation": null "documentation": null

View File

@ -46,7 +46,7 @@
}, },
"containerName": "TestClass" "containerName": "TestClass"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Array_", "type__tostring": "\\TestClass[]",
"type": {}, "type": {},
"declarationLine": "public static $testProperty;", "declarationLine": "public static $testProperty;",
"documentation": "Lorem excepteur officia sit anim velit veniam enim." "documentation": "Lorem excepteur officia sit anim velit veniam enim."

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -70,7 +70,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public static function suite()", "declarationLine": "public static function suite()",
"documentation": null "documentation": null

View File

@ -55,7 +55,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function typesProvider()", "declarationLine": "public function typesProvider()",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -61,7 +61,7 @@
}, },
"containerName": "MyNamespace\\B" "containerName": "MyNamespace\\B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function b() {", "declarationLine": "function b() {",
"documentation": null "documentation": null
@ -100,7 +100,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -60,7 +60,7 @@
}, },
"containerName": "MyNamespace\\A" "containerName": "MyNamespace\\A"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -0,0 +1,9 @@
<?php
class FooClass {
public static function staticFoo(): FooClass {
return new FooClass();
}
public function bar() { }
}

View File

@ -0,0 +1,65 @@
{
"references": {
"FooClass": [
"./staticMethodReturnType.php"
]
},
"definitions": {
"FooClass": {
"fqn": "FooClass",
"extends": [],
"isGlobal": true,
"isStatic": false,
"canBeInstantiated": true,
"symbolInformation": {
"name": "FooClass",
"kind": 5,
"location": {
"uri": "./staticMethodReturnType.php"
},
"containerName": ""
},
"type": null,
"declarationLine": "class FooClass {",
"documentation": null
},
"FooClass::staticFoo()": {
"fqn": "FooClass::staticFoo()",
"extends": [],
"isGlobal": false,
"isStatic": true,
"canBeInstantiated": false,
"symbolInformation": {
"name": "staticFoo",
"kind": 6,
"location": {
"uri": "./staticMethodReturnType.php"
},
"containerName": "FooClass"
},
"type__tostring": "\\FooClass",
"type": {},
"declarationLine": "public static function staticFoo(): FooClass {",
"documentation": null
},
"FooClass->bar()": {
"fqn": "FooClass->bar()",
"extends": [],
"isGlobal": false,
"isStatic": false,
"canBeInstantiated": false,
"symbolInformation": {
"name": "bar",
"kind": 6,
"location": {
"uri": "./staticMethodReturnType.php"
},
"containerName": "FooClass"
},
"type__tostring": "mixed",
"type": {},
"declarationLine": "public function bar() { }",
"documentation": null
}
}
}

View File

@ -33,7 +33,7 @@
}, },
"containerName": "B" "containerName": "B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Integer", "type__tostring": "int",
"type": {}, "type": {},
"declarationLine": "public $hi;", "declarationLine": "public $hi;",
"documentation": null "documentation": null
@ -52,7 +52,7 @@
}, },
"containerName": "B" "containerName": "B"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "function a () {", "declarationLine": "function a () {",
"documentation": null "documentation": null

View File

@ -40,7 +40,7 @@
}, },
"containerName": "Foo" "containerName": "Foo"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Object_", "type__tostring": "\\",
"type": {}, "type": {},
"declarationLine": "protected $bar;", "declarationLine": "protected $bar;",
"documentation": null "documentation": null
@ -59,7 +59,7 @@
}, },
"containerName": "Foo" "containerName": "Foo"
}, },
"type__class": "phpDocumentor\\Reflection\\Types\\Mixed", "type__tostring": "mixed",
"type": {}, "type": {},
"declarationLine": "public function foo () {", "declarationLine": "public function foo () {",
"documentation": null "documentation": null