> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'mysql_pconnect')) { return null; } if (!isset($node->args[0])) { return null; } if (!$node->args[0] instanceof Arg) { return null; } $node->name = new Name('mysqli_connect'); $node->args[0]->value = $this->joinStringWithNode('p:', $node->args[0]->value); return $node; } /** * @return \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\BinaryOp\Concat */ private function joinStringWithNode(string $string, Expr $expr) { if ($expr instanceof String_) { return new String_($string . $expr->value); } return new Concat(new String_($string), $expr); } }