nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } /** * Matches: * list([1, 2]) = each($items) */ public function matchListAndEach(Assign $assign) : ?ListAndEach { // could be behind error suppress if ($assign->expr instanceof ErrorSuppress) { $errorSuppress = $assign->expr; $bareExpr = $errorSuppress->expr; } else { $bareExpr = $assign->expr; } if (!$bareExpr instanceof FuncCall) { return null; } if (!$assign->var instanceof List_) { return null; } if (!$this->nodeNameResolver->isName($bareExpr, 'each')) { return null; } // no placeholders if ($bareExpr->isFirstClassCallable()) { return null; } return new ListAndEach($assign->var, $bareExpr); } public function isLeftPartOfAssign(Node $node) : bool { if ($node->getAttribute(AttributeKey::IS_BEING_ASSIGNED) === \true) { return \true; } return $node->getAttribute(AttributeKey::IS_ASSIGNED_TO) === \true; } /** * @api doctrine * @return array */ public function resolveAssignsToLocalPropertyFetches(FunctionLike $functionLike) : array { return $this->betterNodeFinder->find((array) $functionLike->getStmts(), function (Node $node) : bool { if (!$this->propertyFetchAnalyzer->isLocalPropertyFetch($node)) { return \false; } return $this->isLeftPartOfAssign($node); }); } }