public function leaveNode($node)
{
if ($node instanceof Expr\FuncCall && $this->mysqlTable->has($node->name)) {
/**
* {Description}
* The original MySQL extension is now deprecated, and will generate
* E_DEPRECATED errors when connecting to a database. Instead, use the
* MySQLi or PDO_MySQL extensions.
*
* {Reference}
* http://php.net/manual/en/migration55.deprecated.php#migration55.deprecated.mysql
*/
$this->addSpot('DEPRECATED', true, 'The original MySQL extension is deprecated, use MySQLi or PDO_MySQL extensions instead');
} elseif ($node instanceof Expr\FuncCall && ParserHelper::isSameFunc($node->name, 'preg_replace')) {
/**
* {Description}
* The preg_replace() /e modifier is now deprecated. Instead, use the
* preg_replace_callback() function.
*
* {Reference}
* http://php.net/manual/en/migration55.deprecated.php#migration55.deprecated.preg-replace-e
*/
$affected = true;
$certain = false;
if (!isset($node->args[0])) {
return;
}
$pattern = $node->args[0]->value;
// TODO: shoud be full tested
// Read right-most if concat, encapsed
if ($pattern instanceof Expr\BinaryOp\Concat) {
$pattern = $pattern->right;
}
if ($pattern instanceof Scalar\Encapsed) {
$pattern = end($pattern->parts);
}
// Extract to string
if ($pattern instanceof Scalar\String_ || $pattern instanceof Scalar\EncapsedStringPart) {
$pattern = $pattern->value;
}
// Guess whether e in modifier
if (is_string($pattern)) {
$modifier = strrchr($pattern, '/');
$certain = $affected = strpos($modifier, 'e') !== false;
}
if ($affected) {
$this->addSpot('DEPRECATED', $certain, 'preg_replace() /e modifier is deprecated, use preg_replace_callback() instead');
}
} elseif ($node instanceof Expr\FuncCall && $this->funcTable->has($node->name)) {
/**
* TODO: how to check IntlDateFormatter::setTimeZoneId
*
* {Reference}
* http://php.net/manual/en/migration55.deprecated.php#migration55.deprecated.intl
* http://php.net/manual/en/migration55.deprecated.php#migration55.deprecated.mcrypt
*/
$this->addSpot('DEPRECATED', true, 'Function ' . $node->name . '() is deprecated');
}
}