More reliable way getting first stmt item

The key values are not reliable, this problem is caused by unsetting the values in the stmts array of a node without resetting them. It's not only in this rector file and might need a bigger fix, but this one was bugging me whole day.
This commit is contained in:
Jaapze 2020-01-09 11:41:58 +01:00 committed by GitHub
parent 6071b994e7
commit a1754b38ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,7 +90,8 @@ PHP
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_) {