diff --git a/src/Infer/Scope/Scope.php b/src/Infer/Scope/Scope.php index 2f383975..e40a4a28 100644 --- a/src/Infer/Scope/Scope.php +++ b/src/Infer/Scope/Scope.php @@ -38,7 +38,7 @@ public function __construct( ) { } - public function getType(Node $node) + public function getType(Node $node): Type { if ($node instanceof Node\Scalar) { return (new ScalarTypeGetter)($node); @@ -113,7 +113,7 @@ public function getType(Node $node) if ($node instanceof Node\Expr\PropertyFetch) { // Only string prop names support. if (! $name = ($node->name->name ?? null)) { - return null; + return new UnknownType('Cannot infer type of property fetch: not supported yet.'); } $calleeType = $this->getType($node->var); @@ -122,7 +122,7 @@ public function getType(Node $node) // if ($calleeType->is instanceof ObjectType) { // $calleeType = $calleeType->is; // } - return $this->setType($node, new UnknownType("Cannot infer type of property [{$name}] call on template type: not supported yet.")); + return $this->setType($node, new UnknownType("Cannot infer type of property [{$name}] fetch on template type: not supported yet.")); } return $this->setType( diff --git a/tests/Generator/ResponseExtensionTest.php b/tests/Generator/ResponseExtensionTest.php deleted file mode 100644 index d9a910be..00000000 --- a/tests/Generator/ResponseExtensionTest.php +++ /dev/null @@ -1,26 +0,0 @@ -skip('this is where things started'); - -class ResponseExtensionTest_ControllerWithOtherClassReference -{ - public function __invoke() - { - return (new Bar)->getResponse(); - } -} - -class Foo -{ - public function getResponse() - { - return (new Bar)->getResponse(); - } -} diff --git a/tests/Infer/InferTest.php b/tests/Infer/InferTest.php deleted file mode 100644 index 91e0f05a..00000000 --- a/tests/Infer/InferTest.php +++ /dev/null @@ -1,13 +0,0 @@ -index = new Index(); - $this->infer = new Infer($this->index); -}); - -it('creates class definition on analyzeClass call', function () { - -}); diff --git a/tests/Infer/Scope/ScopeTest.php b/tests/Infer/Scope/ScopeTest.php new file mode 100644 index 00000000..64c47c8d --- /dev/null +++ b/tests/Infer/Scope/ScopeTest.php @@ -0,0 +1,13 @@ +getExpressionType($statement); +} + +it('infers property fetch nodes types', function ($code, $expectedTypeString) { + expect(getStatementTypeForScopeTest($code)->toString())->toBe($expectedTypeString); +})->with([ + ['$foo->bar', 'unknown'], + ['$foo->bar->{"baz"}', 'unknown'], +]);