Merge pull request #2618 from Jaapze/master

More reliable way getting first stmt item
This commit is contained in:
Tomas Votruba 2020-01-09 13:18:41 +01:00 committed by GitHub
commit 8eafe7a6ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,11 +86,12 @@ PHP
return null;
}
if (count((array) $node->stmts) !== 1) {
if ($node->stmts === null || count((array) $node->stmts) !== 1) {
return null;
}
$onlyStmt = $this->unwrapExpression($node->stmts[0]);
$stmtsValues = array_values($node->stmts);
$onlyStmt = $this->unwrapExpression($stmtsValues[0]);
// are both return?
if ($this->isMethodReturnType($node, 'void') && ! $onlyStmt instanceof Return_) {