From 4ada8675ba72300fb9cfa5bdd8450c5b1b39e856 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 16 Jun 2014 01:51:51 +0200 Subject: [PATCH 1/2] Check for old-style constructor names via Code Sniffer. --- build/code-sniffer-ruleset.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/code-sniffer-ruleset.xml b/build/code-sniffer-ruleset.xml index a0a5fc8a..963c2892 100644 --- a/build/code-sniffer-ruleset.xml +++ b/build/code-sniffer-ruleset.xml @@ -45,6 +45,9 @@ + + + From 67aedc240b26178bfa85fcba802feeaad74f8a1a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 16 Jun 2014 17:06:34 +0200 Subject: [PATCH 2/2] Change constructors from class name to __construct(). This has been produced as follows: getExtension() === 'php') { $file = $fileinfo->getPathname(); $content = file_get_contents($file); $files[$file] = $content; $tokens = token_get_all($content); foreach ($tokens as $key => $value) { if ($value[0] === T_CLASS) { $class = $tokens[$key + 2][1]; $replace += array( "$class::$class(" => "$class::__construct(", "parent::$class(" => "parent::__construct(", "function $class(" => "function __construct(", ); } } } } foreach ($files as $file => $content) { file_put_contents( $file, str_replace( array_keys($replace), array_values($replace), $content ) ); } --- phpseclib/Crypt/AES.php | 2 +- phpseclib/Crypt/Base.php | 10 +++++----- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Hash.php | 4 ++-- phpseclib/Crypt/RC2.php | 8 ++++---- phpseclib/Crypt/RC4.php | 8 ++++---- phpseclib/Crypt/RSA.php | 4 ++-- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 10 +++++----- phpseclib/Crypt/Twofish.php | 2 +- phpseclib/File/ANSI.php | 2 +- phpseclib/File/ASN1.php | 2 +- phpseclib/File/X509.php | 2 +- phpseclib/Net/SCP.php | 2 +- phpseclib/Net/SFTP.php | 10 +++++----- phpseclib/Net/SFTP/Stream.php | 2 +- phpseclib/Net/SSH1.php | 14 +++++++------- phpseclib/Net/SSH2.php | 22 +++++++++++----------- phpseclib/System/SSH/Agent.php | 4 ++-- 20 files changed, 57 insertions(+), 57 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 14a0a627..9c4eee54 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -109,7 +109,7 @@ define('CRYPT_AES_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Toggles the internal implementation diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 83f46e3e..458ba198 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -98,7 +98,7 @@ define('CRYPT_MODE_STREAM', 5); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Base value for the internal implementation $engine switch @@ -123,7 +123,7 @@ class Crypt_Base /** * The Encryption Mode * - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() * @var Integer * @access private */ @@ -312,7 +312,7 @@ class Crypt_Base /** * Is the mode one that is paddable? * - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() * @var Boolean * @access private */ @@ -387,7 +387,7 @@ class Crypt_Base * $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode * $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical * - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() * @var String * @access private */ @@ -443,7 +443,7 @@ class Crypt_Base * @param optional Integer $mode * @access public */ - function Crypt_Base($mode = CRYPT_MODE_CBC) + function __construct($mode = CRYPT_MODE_CBC) { $const_crypt_mode = 'CRYPT_' . $this->const_namespace . '_MODE'; diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 90587ca0..4ca69adc 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -103,7 +103,7 @@ define('CRYPT_BLOWFISH_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Toggles the internal implementation diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 3334eb98..5a1b8227 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -123,7 +123,7 @@ define('CRYPT_DES_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Toggles the internal implementation diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 54606d85..7e18b8ed 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -58,7 +58,7 @@ use \phpseclib\Math\BigInteger; /**#@+ * @access private - * @see Crypt_Hash::Crypt_Hash() + * @see Crypt_Hash::__construct() */ /** * Toggles the internal implementation @@ -153,7 +153,7 @@ class Crypt_Hash * @return Crypt_Hash * @access public */ - function Crypt_Hash($hash = 'sha1') + function __construct($hash = 'sha1') { if ( !defined('CRYPT_HASH_MODE') ) { switch (true) { diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 96c9f18c..fcf39b0e 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -101,7 +101,7 @@ define('CRYPT_RC2_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_RC2::Crypt_RC2() + * @see Crypt_RC2::__construct() */ /** * Toggles the internal implementation @@ -334,13 +334,13 @@ class Crypt_RC2 extends Crypt_Base * * If not explicitly set, CRYPT_RC2_MODE_CBC will be used. * - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() * @param optional Integer $mode * @access public */ - function Crypt_RC2($mode = CRYPT_RC2_MODE_CBC) + function __construct($mode = CRYPT_RC2_MODE_CBC) { - parent::Crypt_Base($mode); + parent::__construct($mode); $this->setKey(''); } diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 48807350..33ff8eb4 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -71,7 +71,7 @@ if (!class_exists('Crypt_Base')) { /**#@+ * @access private - * @see Crypt_RC4::Crypt_RC4() + * @see Crypt_RC4::__construct() */ /** * Toggles the internal implementation @@ -172,13 +172,13 @@ class Crypt_RC4 extends Crypt_Base * * Determines whether or not the mcrypt extension should be used. * - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() * @return Crypt_RC4 * @access public */ - function Crypt_RC4() + function __construct() { - parent::Crypt_Base(CRYPT_MODE_STREAM); + parent::__construct(CRYPT_MODE_STREAM); } /** diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 88647102..ff5eb17d 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -155,7 +155,7 @@ define('CRYPT_RSA_ASN1_SEQUENCE', 48); /**#@+ * @access private - * @see Crypt_RSA::Crypt_RSA() + * @see Crypt_RSA::__construct() */ /** * To use the pure-PHP implementation @@ -473,7 +473,7 @@ class Crypt_RSA * @return Crypt_RSA * @access public */ - function Crypt_RSA() + function __construct() { $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index a43283f1..878c904e 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -120,7 +120,7 @@ define('CRYPT_RIJNDAEL_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Toggles the internal implementation diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 59c5f31a..0994408a 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -181,18 +181,18 @@ class Crypt_TripleDES extends Crypt_DES * * If not explicitly set, CRYPT_DES_MODE_CBC will be used. * - * @see Crypt_DES::Crypt_DES() - * @see Crypt_Base::Crypt_Base() + * @see Crypt_DES::__construct() + * @see Crypt_Base::__construct() * @param optional Integer $mode * @access public */ - function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC) + function __construct($mode = CRYPT_DES_MODE_CBC) { switch ($mode) { // In case of CRYPT_DES_MODE_3CBC, we init as CRYPT_DES_MODE_CBC // and additional flag us internally as 3CBC case CRYPT_DES_MODE_3CBC: - parent::Crypt_DES(CRYPT_DES_MODE_CBC); + parent::__construct(CRYPT_DES_MODE_CBC); $this->mode_3cbc = true; // This three $des'es will do the 3CBC work (if $key > 64bits) @@ -209,7 +209,7 @@ class Crypt_TripleDES extends Crypt_DES break; // If not 3CBC, we init as usual default: - parent::Crypt_DES($mode); + parent::__construct($mode); } } diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index acd52c1c..183cf3ac 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -103,7 +103,7 @@ define('CRYPT_TWOFISH_MODE_OFB', CRYPT_MODE_OFB); /**#@+ * @access private - * @see Crypt_Base::Crypt_Base() + * @see Crypt_Base::__construct() */ /** * Toggles the internal implementation diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 682ba430..dc8e8eee 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -211,7 +211,7 @@ class File_ANSI * @return File_ANSI * @access public */ - function File_ANSI() + function __construct() { $this->setHistory(200); $this->setDimensions(80, 24); diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 8fe51018..659c8eb7 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -133,7 +133,7 @@ class File_ASN1_Element * @return File_ASN1_Element * @access public */ - function File_ASN1_Element($encoded) + function __construct($encoded) { $this->element = $encoded; } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 74f1d7ae..9cac4eb6 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -313,7 +313,7 @@ class File_X509 * @return File_X509 * @access public */ - function File_X509() + function __construct() { // Explicitly Tagged Module, 1988 Syntax // http://tools.ietf.org/html/rfc5280#appendix-A.1 diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 2796a355..762fbae2 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -122,7 +122,7 @@ class Net_SCP * @return Net_SCP * @access public */ - function Net_SCP($ssh) + function __construct($ssh) { if (!is_object($ssh)) { return; diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index ecc277b9..52dc3585 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -124,7 +124,7 @@ class Net_SFTP extends Net_SSH2 /** * Packet Types * - * @see Net_SFTP::Net_SFTP() + * @see Net_SFTP::__construct() * @var Array * @access private */ @@ -133,7 +133,7 @@ class Net_SFTP extends Net_SSH2 /** * Status Codes * - * @see Net_SFTP::Net_SFTP() + * @see Net_SFTP::__construct() * @var Array * @access private */ @@ -245,7 +245,7 @@ class Net_SFTP extends Net_SSH2 /** * Max SFTP Packet Size * - * @see Net_SFTP::Net_SFTP() + * @see Net_SFTP::__construct() * @see Net_SFTP::get() * @var Array * @access private @@ -283,9 +283,9 @@ class Net_SFTP extends Net_SSH2 * @return Net_SFTP * @access public */ - function Net_SFTP($host, $port = 22, $timeout = 10) + function __construct($host, $port = 22, $timeout = 10) { - parent::Net_SSH2($host, $port, $timeout); + parent::__construct($host, $port, $timeout); $this->max_sftp_packet = 1 << 15; diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 2f11abaa..e8bd23a1 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -131,7 +131,7 @@ class Net_SFTP_Stream * * @access public */ - function Net_SFTP_Stream() + function __construct() { if (defined('NET_SFTP_STREAM_LOGGING')) { echo "__construct()\r\n"; diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index d4fbdf06..511084cb 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -360,7 +360,7 @@ class Net_SSH1 /** * Protocol Flags * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @var Array * @access private */ @@ -463,7 +463,7 @@ class Net_SSH1 /** * Hostname * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @see Net_SSH1::_connect() * @var String * @access private @@ -473,7 +473,7 @@ class Net_SSH1 /** * Port Number * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @see Net_SSH1::_connect() * @var Integer * @access private @@ -488,7 +488,7 @@ class Net_SSH1 * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be * 10 seconds. It is used by fsockopen() in that function. * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @see Net_SSH1::_connect() * @var Integer * @access private @@ -498,7 +498,7 @@ class Net_SSH1 /** * Default cipher * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @see Net_SSH1::_connect() * @var Integer * @access private @@ -517,7 +517,7 @@ class Net_SSH1 * @return Net_SSH1 * @access public */ - function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) + function __construct($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) { // Include Crypt_Random // the class_exists() will only be called if the crypt_random_string function hasn't been defined and @@ -1333,7 +1333,7 @@ class Net_SSH1 * should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that * calls this call modexp, instead, but I think this makes things clearer, maybe... * - * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::__construct() * @param Math_BigInteger $m * @param Array $key * @return Math_BigInteger diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 41dfdd46..ae230bc8 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -299,7 +299,7 @@ class Net_SSH2 * * -- http://tools.ietf.org/html/rfc4253#section-6 * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @see Net_SSH2::_send_binary_packet() * @var Integer * @access private @@ -309,7 +309,7 @@ class Net_SSH2 /** * Block Size for Client to Server Encryption * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @see Net_SSH2::_get_binary_packet() * @var Integer * @access private @@ -403,7 +403,7 @@ class Net_SSH2 /** * Message Numbers * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @var Array * @access private */ @@ -412,7 +412,7 @@ class Net_SSH2 /** * Disconnection Message 'reason codes' defined in RFC4253 * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @var Array * @access private */ @@ -421,7 +421,7 @@ class Net_SSH2 /** * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @var Array * @access private */ @@ -431,7 +431,7 @@ class Net_SSH2 * Terminal Modes * * @link http://tools.ietf.org/html/rfc4254#section-8 - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @var Array * @access private */ @@ -441,7 +441,7 @@ class Net_SSH2 * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes * * @link http://tools.ietf.org/html/rfc4254#section-5.2 - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @var Array * @access private */ @@ -789,7 +789,7 @@ class Net_SSH2 /** * Hostname * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @see Net_SSH2::_connect() * @var String * @access private @@ -799,7 +799,7 @@ class Net_SSH2 /** * Port Number * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @see Net_SSH2::_connect() * @var Integer * @access private @@ -814,7 +814,7 @@ class Net_SSH2 * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be * 10 seconds. It is used by fsockopen() and the initial stream_select in that function. * - * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::__construct() * @see Net_SSH2::_connect() * @var Integer * @access private @@ -831,7 +831,7 @@ class Net_SSH2 * @return Net_SSH2 * @access public */ - function Net_SSH2($host, $port = 22, $timeout = 10) + function __construct($host, $port = 22, $timeout = 10) { if (!function_exists('crypt_random_string')) { include_once 'Crypt/Random.php'; diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index ead905fa..d4555111 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -115,7 +115,7 @@ class System_SSH_Agent_Identity * @return System_SSH_Agent_Identity * @access private */ - function System_SSH_Agent_Identity($fsock) + function __construct($fsock) { $this->fsock = $fsock; } @@ -231,7 +231,7 @@ class System_SSH_Agent * @return System_SSH_Agent * @access public */ - function System_SSH_Agent() + function __construct() { switch (true) { case isset($_SERVER['SSH_AUTH_SOCK']):