diff --git a/src/main/php/PDepend/Source/AST/AbstractASTCallable.php b/src/main/php/PDepend/Source/AST/AbstractASTCallable.php index 0388b1ad0..600030f31 100644 --- a/src/main/php/PDepend/Source/AST/AbstractASTCallable.php +++ b/src/main/php/PDepend/Source/AST/AbstractASTCallable.php @@ -284,6 +284,24 @@ public function getReturnClass() return null; } + /** + * Tests if this callable has a return class and return true if it is + * configured. + * + * @return boolean + * @since 2.2.4 + */ + public function hasReturnClass() + { + if ($this->returnClassReference) { + return true; + } + if (($node = $this->getReturnType()) instanceof ASTClassOrInterfaceReference) { + return true; + } + return false; + } + /** * @return \PDepend\Source\AST\ASTType */ diff --git a/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php b/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php index 355bac5b8..2d0101e65 100644 --- a/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php +++ b/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php @@ -51,6 +51,7 @@ use PDepend\Source\AST\ASTClass; use PDepend\Source\AST\ASTDeclareStatement; use PDepend\Source\AST\ASTExpression; +use PDepend\Source\AST\ASTIndexExpression; use PDepend\Source\AST\ASTInterface; use PDepend\Source\AST\ASTNode; use PDepend\Source\AST\ASTStatement; @@ -3922,12 +3923,14 @@ private function parseMemberPrimaryPrefix(ASTNode $node) $tokenType = $this->tokenizer->peek(); switch ($tokenType) { + case Tokens::T_CALLABLE: + /* Fixme */ case Tokens::T_STRING: $child = $this->parseIdentifier(); $child = $this->parseOptionalIndexExpression($child); // TODO: Move this in a separate method - if ($child instanceof \PDepend\Source\AST\ASTIndexExpression) { + if ($child instanceof ASTIndexExpression) { $this->consumeComments(); if (Tokens::T_PARENTHESIS_OPEN === $this->tokenizer->peek()) { $prefix->addChild($this->parsePropertyPostfix($child)); @@ -6709,7 +6712,7 @@ private function prepareCallable(AbstractASTCallable $callable) } // Stop here if return class already exists. - if ($callable->getReturnClass()) { + if ($callable->hasReturnClass()) { return; }