--- coder/includes/coder_php53.inc No Base Revision
+++ coder/includes/coder_php53.inc Locally New
@@ -0,0 +1,289 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * This include file implements coder functionality for Drupal Standards.
+ *
+ * As from: http://www.php.net/manual/en/migration53.deprecated.php
+ *
+ * Not all issues of a PHP 5.3 transition have been covered.
+ *
+ * @todo The rules for this review are not yet complete.
+ */
+
+/**
+ * Implementation of hook_reviews().
+ */
+function coder_php53_reviews() {
+  $argex = '(((\$?)[a-zA-Z_]+((\([^)]*\))|\[[^\]]*\])?)|[0-9]+(\.[0-9]*)?|\'\'|"")';
+  $rules = array(
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]call_user_method\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_call_user_method_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]call_user_method_array\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_call_user_method_array_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]define_syslog_variables\s*\(\);',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_define_syslog_variables_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]ereg\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_ereg_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]ereg_replace\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_ereg_replace_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]eregi\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_eregi_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]eregi_replace\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_eregi_replace_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(](set_magic_quotes_runtime|magic_quotes_runtime)\s*\(\s*[0-9\$\ ]',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_magic_quotes_runtime_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(](session_register|session_unregister|session_is_registered)\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_session_re_un_is_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]set_socket_blocking\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_set_socket_blocking_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]split\s*\([\s*\$\']',
+      '#never' => '[a-z|A-Z|0-9|\-\_]split',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_split_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]spliti\s*\([\s*\$\']',
+      '#never' => '[a-z|A-Z|0-9|\-\_]spliti',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_spliti_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]sql_regcase\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_sql_regcase_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]mysql_db_query\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_mysql_db_query_warning',
+    ),
+    array(
+      '#type' => 'regex',
+      '#value' => '[\s\(]mysql_escape_string\s*\([\s*\$\']',
+      '#source' => 'allphp',
+      '#warning_callback' => '_coder_php53_mysql_escape_string_warning',
+    ),
+
+  );
+  $review = array(
+    '#title' => 'Upgrade to D7: Drupal PHP 5.3 Checks',
+    '#link' => 'http://drupal.org/node/28984',
+    '#rules' => $rules,
+    '#severity' => 'critical',
+    '#description' => t('Usage of PHP 5.3 deprecated functions in the code.'),
+  );
+  return array('php53' => $review);
+}
+
+
+/**
+ * Define the rule callbacks.
+ */
+
+/* function _coder_php53_callback(&$coder_args, $review, $rule, $lines, &$results) {
+  if (!isset($coder_args['#tokens'])) {
+    $source = implode('', $lines);
+    $coder_args['#tokens'] = token_get_all($source);
+  }
+} */
+
+/**
+ * Define the warning callbacks.
+ */
+
+function _coder_php53_call_user_method_warning() {
+  return t('!call_user_method() is deprectated. use <em>!call_user_func()</em> instead.',
+    array(
+      '!call_user_method()' => l('call_user_method()', 'http://www.php.net/manual/en/function.call-user-method.php'),
+      '!call_user_func()' => l('call_user_func()', 'http://www.php.net/manual/en/function.call-user-func.php'),
+    )
+  );
+}
+
+function _coder_php53_call_user_method_array_warning() {
+  return t('!call_user_method_array() function is deprectated. use <em>!call_user_func_array()</em> instead.',
+    array(
+      '!call_user_method_array()' => l('call_user_method_array()', 'http://www.php.net/manual/en/function.call-user-method_array.php'),
+      '!call_user_func_array()' => l('call_user_func()', 'http://www.php.net/manual/en/function.call-user-func.php'),
+    )
+  );
+}
+
+function _coder_php53_define_syslog_variables_warning() {
+  return t('!define_syslog_variables() function is deprectated.',
+    array(
+      '!define_syslog_variables()' => l('define_syslog_variables()', 'http://www.php.net/manual/en/function.define-syslog-variables.php'),
+    )
+  );
+}
+
+function _coder_php53_dl_warning() {
+  return t('!dl() function is deprectated.',
+    array(
+      '!dl()' => l('dl()', 'http://www.php.net/manual/en/function.dl.php'),
+    )
+  );
+}
+
+function _coder_php53_ereg_warning() {
+  return t('!ereg() is deprectated. Use <em>!preg_match()</em> instead.',
+    array(
+      '!ereg()' => l('ereg()', 'http://www.php.net/manual/en/function.ereg.php'),
+      '!preg_match()' => l('preg_match()', 'http://www.php.net/manual/en/function.preg_match.php'),
+    )
+  );
+}
+
+function _coder_php53_ereg_replace_warning() {
+  return t('!ereg_replace() is deprectated. Use <em>!preg_replace()</em> instead.',
+    array(
+      '!ereg_replace()' => l('ereg_replace()', 'http://www.php.net/manual/en/function.ereg_replace.php'),
+      '!preg_match()' => l('preg_match()', 'http://www.php.net/manual/en/function.preg_match.php'),
+    )
+  );
+}
+
+
+function _coder_php53_eregi_warning() {
+  return t('!eregi() is deprectated. Use <em>!preg_match()</em> with <em>i</em> modifier instead.',
+    array(
+      '!eregi()' => l('eregi()', 'http://www.php.net/manual/en/function.eregi.php'),
+      '!preg_match()' => l('preg_match()', 'http://www.php.net/manual/en/function.preg_match.php'),
+    )
+  );
+}
+
+function _coder_php53_eregi_replace_warning() {
+  return t('!eregi_replace() is deprectated. Use <em>!preg_replace()</em> with the <em>i</em> modifier instead',
+    array(
+      '!eregi_replace()' => l('ereg_replace()', 'http://www.php.net/manual/en/function.eregi_replace.php'),
+      '!preg_match()' => l('preg_match()', 'http://www.php.net/manual/en/function.preg_match.php'),
+    )
+  );
+}
+
+function _coder_php53_magic_quotes_runtime_warning() {
+  return t('!set_magic_quotes_runtime() and its alias !magic_quotes_runtime() are deprectated.',
+    array(
+      '!magic_quotes_runtime()' => l('magic_quotes_runtime()', 'http://www.php.net/manual/en/function.magic-quotes-runtime.php'),
+      '!set_magic_quotes_runtime()' => l('set_magic_quotes_runtime()', 'http://www.php.net/manual/en/function.magic-quotes-runtime.php'),
+    )
+  );
+}
+
+function _coder_php53_session_reg_unreg_is_warning() {
+  return t('!session_register(), !session_unregister() and !session_is_registered() functions are deprecated. use the <em>!$_SESSION</em> superglobal instead.',
+    array(
+      '!session_register()' => l('session_register()', 'http://www.php.net/manual/en/function.session-register.php'),
+      '!session_unregister()' => l('session_unregister()', 'http://www.php.net/manual/en/function.session-unregister.php'),
+      '!session_is_registered()' => l('session_is_registered()', 'http://www.php.net/manual/en/function.session-is-registered.php'),
+      '!$_SESSION' => l('$_SESSION', 'http://www.php.net/manual/en/reserved.variables.session.php'),
+    )
+  );
+}
+
+function _coder_php53_set_socket_blocking_warning() {
+  return t('!set_socket_blocking() alias is deprecated. use <em>!stream_set_blocking()</em> instead.',
+    array(
+      '!set_socket_blocking()' => l('set_socket_blocking()', 'http://www.php.net/manual/en/function.set-socket-blocking.php'),
+      '!stream_set_blocking()' => l('stream_set_blocking()', 'http://www.php.net/manual/en/function.stream-set-blocking.php'),
+    )
+  );
+}
+
+function _coder_php53_split_warning() {
+  return t('!split() function is deprecated. use <em>!preg_split()</em> instead.',
+    array(
+      '!split()' => l('split()', 'http://www.php.net/manual/en/function.split.php'),
+      '!preg_split()' => l('preg_split()', 'http://www.php.net/manual/en/function.preg_split.php'),
+    )
+  );
+}
+
+
+function _coder_php53_spliti_warning() {
+  return t('!spliti() function is deprecated. use <em>!preg_split()</em> with the <em>i</em> modifier instead.',
+    array(
+      '!spliti()' => l('split()', 'http://www.php.net/manual/en/function.spliti.php'),
+      '!preg_split()' => l('preg_split()', 'http://www.php.net/manual/en/function.preg_split.php'),
+    )
+  );
+}
+
+function _coder_php53_sql_regcase_warning() {
+  return t('!sql_regcase() function is deprecated.',
+    array(
+      '!sql_regcase()' => l('sql_regcase()', 'http://www.php.net/manual/en/function.sql-regcase.php'),
+    )
+  );
+}
+
+
+function _coder_php53_mysql_db_query_warning() {
+  return t('!mysql_db_query() function is deprecated. Use <em>!mysql_select_db()</em> and <em>!mysql_query()</em> instead.',
+    array(
+      '!mysql_db_query()' => l('mysql_db_query()', 'http://www.php.net/manual/en/function.mysql-db-query.php'),
+      '!mysql_select()' => l('mysql_select()', 'http://www.php.net/manual/en/function.mysql-select.php'),
+      '!mysql_query()' => l('mysql_query()', 'http://www.php.net/manual/en/function.mysql-query.php'),
+    )
+  );
+}
+
+
+function _coder_php53_mysql_escape_string_warning() {
+  return t('!mysql_escape_string() function is deprecated. Use <em>!mysql_real_escape_string()</em> instead.',
+    array(
+      '!mysql_escape_string()' => l('mysql_escape_string()', 'http://www.php.net/manual/en/function.mysql-escape-string.php'),
+      '!mysql_real_escape_string()' => l('mysql_real_escape_string()', 'http://www.php.net/manual/en/function.mysql-real-escape-string.php'),
+    )
+  );
+}
--- coder/tests/coder_php53.test No Base Revision
+++ coder/tests/coder_php53.test Locally New
@@ -0,0 +1,189 @@
+<?php
+require_once(dirname(__FILE__) .'/coder_test_case.tinc');
+
+class CoderPHP53Test extends CoderTestCase {
+  function __construct($id = NULL) {
+    parent::__construct('php53', $id);
+  }
+  
+  public static function getInfo() {
+    return array(
+      'name' => t('Coder PHP53 Tests'),
+      'description' => t('Tests for the coder PHP53 review.'),
+      'group' => t('Coder'),
+    );
+  }
+
+  function testPHP53CallUserMethod() {
+    $this->assertCoderFail('  $test = call_user_method($method, $object);');
+    $this->assertCoderFail('  $test = call_user_method(\'method\', $object);');
+    $this->assertCoderFail('  call_user_method($method_name, $object)');
+    $this->assertCoderPass('  $test = re_call_user_method ($this');
+    $this->assertCoderPass('  $test = recall_user_method($this);');
+    $this->assertCoderPass('  when you use call_user_method() to do');
+    $this->assertCoderPass('  function call_user_method(string $method_name, $object)');
+  }
+
+  function testPHP53CallUserMethodArray() {
+    $this->assertCoderFail('  $test = call_user_method_array( array($method, $object), $whatever);');
+    $this->assertCoderFail('  $test = call_user_method_array(\'method\', $object);');
+    $this->assertCoderFail('  call_user_method_array($method_name, $object)');
+    $this->assertCoderPass('  $test = re_call_user_method_array ($this');
+    $this->assertCoderPass('  $test = recall_user_method_array($this);');
+    $this->assertCoderPass('  when you use call_user_method_array() to do');
+    $this->assertCoderPass('  function call_user_method_array(string $method_name, $object)');
+  }
+
+  function testPHP53DefineSyslogVariables() {
+    $this->assertCoderFail('  $test = define_syslog_variables();');
+    $this->assertCoderFail('  define_syslog_variables();');
+    $this->assertCoderPass('  $test = custom_define_syslog_variables();');
+    $this->assertCoderPass('  when you use define_syslog_variables() to do');
+    $this->assertCoderPass('  function define_syslog_variables() {');
+  }
+
+  function testPHP53Ereg() {
+    $this->assertCoderFail('  $test = ereg( $this, $that);');
+    $this->assertCoderFail('  $test = ereg(\'pattern\', $that);');
+    $this->assertCoderFail('  ereg($patter, $string)');
+    $this->assertCoderPass('  $test = re_ereg ($this');
+    $this->assertCoderPass('  $test = reereg($this);');
+    $this->assertCoderPass('  when you use ereg() to do');
+    $this->assertCoderPass('  function ereg(string $pattern, string $text)');
+  }
+
+  function testPHP53EregReplace() {
+    $this->assertCoderFail('  $test = ereg_replace( $this, $that, $it);');
+    $this->assertCoderFail('  $test = ereg_replace(\'pattern\', $that, $this);');
+    $this->assertCoderFail('  ereg_replace($patter, $string, $that)');
+    $this->assertCoderPass('  $test = re_ereg_replace ($this');
+    $this->assertCoderPass('  $test = reereg_replace($this);');
+    $this->assertCoderPass('  when you use ereg_replace() to do');
+    $this->assertCoderPass('  function ereg_replace(string $pattern, string $replacement, string $text)');
+  }
+
+  function testPHP53Eregi() {
+    $this->assertCoderFail('  $test = eregi( $this, $that);');
+    $this->assertCoderFail('  $test = eregi(\'pattern\', $that);');
+    $this->assertCoderFail('  eregi($patter, $string)');
+    $this->assertCoderPass('  $test = re_eregi ($this');
+    $this->assertCoderPass('  $test = reeregi($this);');
+    $this->assertCoderPass('  when you use eregi() to do');
+    $this->assertCoderPass('  function eregi(string $pattern, string $text)');
+  }
+
+  function testPHP53EregiReplace() {
+    $this->assertCoderFail('  $test = eregi_replace( $this, $that, $it);');
+    $this->assertCoderFail('  $test = eregi_replace(\'pattern\', $that, $this);');
+    $this->assertCoderFail('  eregi_replace($patter, $string, $that)');
+    $this->assertCoderPass('  $test = re_eregi_replace ($this');
+    $this->assertCoderPass('  $test = reeregi_replace($this);');
+    $this->assertCoderPass('  when you use eregi_replace() to do');
+    $this->assertCoderPass('  function eregi_replace(string $pattern, string $replacement, string $text)');
+  }
+
+  function testPHP53MagicQuotesRuntime() {
+    $this->assertCoderFail('  $test = magic_quotes_runtime( 1 );');
+    $this->assertCoderFail('  $test = magic_quotes_runtime($this);');
+    $this->assertCoderFail('  magic_quotes_runtime(0)');
+    $this->assertCoderPass('  $test = re_magic_quotes_runtime ($this');
+    $this->assertCoderPass('  $test = remagic_quotes_runtime($this);');
+    $this->assertCoderPass('  when you use magic_quotes_runtime() to do');
+    $this->assertCoderPass('  function magic_quotes_runtime(bool $status)');
+
+    $this->assertCoderFail('  $test = set_magic_quotes_runtime( 1 );');
+    $this->assertCoderFail('  $test = set_magic_quotes_runtime($this);');
+    $this->assertCoderFail('  set_magic_quotes_runtime(0)');
+    $this->assertCoderPass('  $test = re_set_magic_quotes_runtime ($this');
+    $this->assertCoderPass('  $test = reset_magic_quotes_runtime($this);');
+    $this->assertCoderPass('  when you use set_magic_quotes_runtime() to do');
+    $this->assertCoderPass('  function set_magic_quotes_runtime(bool $status)');
+  }
+
+  function testPHP53SessionReUnIsRegistered() {
+    $this->assertCoderFail('  $test = session_register($this);');
+    $this->assertCoderFail('  $test = session_register(\'pattern\', $that, $this);');
+    $this->assertCoderFail('  session_register($patter, $string, $that)');
+    $this->assertCoderPass('  $test = customsession_register($this');
+    $this->assertCoderPass('  $test = custom_session_register($this);');
+    $this->assertCoderPass('  when you use session_register() to do');
+    $this->assertCoderPass('  function session_register(string $pattern, string $replacement, string $text)');
+
+    $this->assertCoderFail('  $test = session_unregister($this);');
+    $this->assertCoderFail('  $test = session_unregister(\'pattern\', $that, $this);');
+    $this->assertCoderFail('  session_unregister($patter, $string, $that)');
+    $this->assertCoderPass('  $test = customsession_unregister($this');
+    $this->assertCoderPass('  $test = custom_session_unregister($this);');
+    $this->assertCoderPass('  when you use session_unregister() to do');
+    $this->assertCoderPass('  function session_unregister(string $pattern, string $replacement, string $text)');
+
+    $this->assertCoderFail('  $test = session_is_registered($this);');
+    $this->assertCoderFail('  $test = session_is_registered(\'pattern\', $that, $this);');
+    $this->assertCoderFail('  session_is_registered($patter, $string, $that)');
+    $this->assertCoderPass('  $test = customsession_is_registered($this');
+    $this->assertCoderPass('  $test = custom_session_is_registered($this);');
+    $this->assertCoderPass('  when you use session_is_registered() to do');
+    $this->assertCoderPass('  function session_is_registered(string $pattern, string $replacement, string $text)');
+  }
+
+  function testPHP53SetSocketBlocking() {
+    $this->assertCoderFail('  $test = set_socket_blocking( $this, $that);');
+    $this->assertCoderFail('  $test = set_socket_blocking($resource, 2);');
+    $this->assertCoderFail('  set_socket_blocking($this, $string)');
+    $this->assertCoderPass('  $test = my_set_socket_blocking ($this');
+    $this->assertCoderPass('  $test = customset_socket_blocking($this, $that);');
+    $this->assertCoderPass('  when you use set_socket_blocking() to do');
+    $this->assertCoderPass('  function set_socket_blocking(stream $stream, integer $what)');
+  }
+
+  function testPHP53Split() {
+    $this->assertCoderFail('  $test = split( $this, $that);');
+    $this->assertCoderFail('  $test = split(\'pattern\', $that);');
+    $this->assertCoderFail('  split($patter, $string)');
+    $this->assertCoderPass('  $test = re_split ($this');
+    $this->assertCoderPass('  $test = resplit($this);');
+    $this->assertCoderPass('  when you use split() to do');
+    $this->assertCoderPass('  function split(string $pattern, string $text)');
+  }
+
+  function testPHP53Spliti() {
+    $this->assertCoderFail('  $test = spliti( $this, $that);');
+    $this->assertCoderFail('  $test = spliti(\'pattern\', $that);');
+    $this->assertCoderFail('  spliti($patter, $string)');
+    $this->assertCoderPass('  $test = re_spliti ($this');
+    $this->assertCoderPass('  $test = respliti($this);');
+    $this->assertCoderPass('  when you use spliti() to do');
+    $this->assertCoderPass('  function spliti(string $pattern, string $text)');
+  }
+
+  function testPHP53SqlRegCase() {
+    $this->assertCoderFail('  $test = sql_regcase( $string );');
+    $this->assertCoderFail('  $test = sql_regcase(\'string\');');
+    $this->assertCoderFail('  sql_regcase($pattern)');
+    $this->assertCoderPass('  $test = re_sql_regcase ($this');
+    $this->assertCoderPass('  $test = resql_regcase($this);');
+    $this->assertCoderPass('  when you use sql_regcase() to do');
+    $this->assertCoderPass('  function sql_regcase(string $pattern, string $text)');
+  }
+
+  function testPHP53MysqlDbQuery() {
+    $this->assertCoderFail('  $test = mysql_db_query( $this, $that);');
+    $this->assertCoderFail('  $test = mysql_db_query(\'string\', $that);');
+    $this->assertCoderFail('  mysql_db_query($string, $string)');
+    $this->assertCoderPass('  $test = re_mysql_db_query ($this');
+    $this->assertCoderPass('  $test = remysql_db_query($this);');
+    $this->assertCoderPass('  when you use mysql_db_query() to do');
+    $this->assertCoderPass('  function mysql_db_query(string $pattern, string $text)');
+  }
+
+  function testPHP53MysqlEscapeString() {
+    $this->assertCoderFail('  $test = mysql_escape_string( $this);');
+    $this->assertCoderFail('  $test = mysql_escape_string(\'string\');');
+    $this->assertCoderFail('  mysql_escape_string($string)');
+    $this->assertCoderPass('  $test = re_mysql_escape_string ($this');
+    $this->assertCoderPass('  $test = remysql_escape_string($this);');
+    $this->assertCoderPass('  when you use mysql_escape_string() to do');
+    $this->assertCoderPass('  function mysql_escape_string(string $string)');
+  }
+
+}
