/** * @param mixed $stmt * @param ArrayDto $arrayDto * @param string $parentClass * * @return array */ private function extract($stmt, ArrayDto $arrayDto, array $parentClass = array()) { if ($stmt instanceof Expr\Assign) { if ($stmt->expr instanceof Expr\BinaryOp) { $stmt->expr = $stmt->expr->left; $arrayDto->addCollected($this->dispatcher->pExpr_Assign($stmt)); } else { $arrayDto->addCollected($this->dispatcher->pExpr_Assign($stmt)); } } elseif ($this->isVarModification($stmt) && !in_array("PhpParser\\Node\\Expr\\Assign", $parentClass)) { $arrayDto->addCollected($this->dispatcher->p($stmt)); } elseif ($this->isVarCreation($stmt) && !in_array("PhpParser\\Node\\Expr\\ArrayItem", $parentClass) && !in_array("PhpParser\\Node\\Expr\\Assign", $parentClass)) { $arrayDto->addCollected('let tmpArray' . md5(serialize($stmt->items)) . ' = ' . $this->dispatcher->p($stmt)); } return $arrayDto; }
/** * @param mixed $stmt * @param array $collected * @param string $parentClass * * @return array */ private function extract($stmt, array $collected, $parentClass = '') { if ($stmt instanceof Expr\Assign) { if ($stmt->expr instanceof Expr\BinaryOp) { $stmt->expr = $stmt->expr->left; $collected['extracted'][] = $this->dispatcher->pExpr_Assign($stmt) . ";"; } else { $collected['extracted'][] = $this->dispatcher->pExpr_Assign($stmt) . ";"; } } elseif ($this->isVarModification($stmt)) { $collected['extracted'][] = $this->dispatcher->p($stmt) . ";"; } elseif ($this->isVarCreation($stmt) && $parentClass != "PhpParser\\Node\\Expr\\ArrayItem") { $collected['extracted'][] = 'let tmpArray' . md5(serialize($stmt->items)) . ' = ' . $this->dispatcher->p($stmt) . ";"; } return $collected; }