Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
Expand Down Expand Up @@ -52,33 +51,6 @@ public function hasOnlyPropertyAssign(ClassMethod $classMethod, string $property
return $this->isLocalPropertyVariableAssign($onlyClassMethodStmt, $propertyName);
}

public function hasPropertyAssignWithReturnThis(ClassMethod $classMethod): bool
{
$stmts = (array) $classMethod->stmts;
if (count($stmts) !== 2) {
return false;
}

$possibleAssignStmt = $stmts[0];
$possibleReturnThis = $stmts[1];

if (! $this->isLocalPropertyVariableAssign($possibleAssignStmt, null)) {
return false;
}

if (! $possibleReturnThis instanceof Return_) {
return false;

}

$returnExpr = $possibleReturnThis->expr;
if (! $returnExpr instanceof Variable) {
return false;
}

return $this->nodeNameResolver->isName($returnExpr, 'this');
}

private function isLocalPropertyVariableAssign(Stmt $onlyClassMethodStmt, ?string $propertyName): bool
{
if (! $onlyClassMethodStmt instanceof Expression) {
Expand Down
Loading
Loading