Permalink
Browse files

Merge pull request #365 from j-velasco/GH304-object-operator-from-ins…

…tances-returned-by-callable-objects

Fixes #304: Object operator on objects returned by callable object
  • Loading branch information...
emirb committed Aug 6, 2018
2 parents 9daf26d + 4f32f35 commit 87f4740063df1cd03e1c46863572ab11d6fa1a96
@@ -389,7 +389,8 @@ protected function parseParenthesisExpressionOrPrimaryPrefixForVersion(ASTExpres
return $this->parseStaticMemberPrimaryPrefix($expr->getChild(0));
}
if ($this->tokenizer->peek() === Tokens::T_OBJECT_OPERATOR) {
return $this->parseMemberPrimaryPrefix($expr->getChild(0));
$node = count($expr->getChildren()) === 0 ? $expr : $expr->getChild(0);
return $this->parseMemberPrimaryPrefix($node);
}
return $expr;
}
@@ -518,4 +518,12 @@ public function testClassMethodNamesInvoked()
{
$this->assertNotNull($this->parseCodeResourceForTest());
}
/**
* @return void
*/
public function testMethodsCanBeCallOnInstancesReturnedByInvokableObject()
{
$this->assertNotNull($this->parseCodeResourceForTest());
}
}
@@ -0,0 +1,19 @@
<?php
class Foo
{
public function bar()
{
echo 'baz';
}
}
class FooFactory
{
public function __invoke()
{
return new Foo();
}
}
(new FooFactory())()->bar();

0 comments on commit 87f4740

Please sign in to comment.