Merge pull request #375 from bantu/php5-construct

Change constructors from class name to __construct().

* bantu/php5-construct:
  Change constructors from class name to __construct().
  Check for old-style constructor names via Code Sniffer.
This commit is contained in:
Andreas Fischer 2014-06-16 19:56:57 +02:00
commit c5421e3493
21 changed files with 60 additions and 57 deletions

View File

@ -45,6 +45,9 @@
<!-- All code files MUST use only UTF-8 without BOM. --> <!-- All code files MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark" /> <rule ref="Generic.Files.ByteOrderMark" />
<!-- Constructors MUST be called __construct() instead of after the class. -->
<rule ref="Generic.NamingConventions.ConstructorName" />
<!-- Each file MUST end with exactly one newline character --> <!-- Each file MUST end with exactly one newline character -->
<rule ref="PSR2.Files.EndFileNewline" /> <rule ref="PSR2.Files.EndFileNewline" />

View File

@ -109,7 +109,7 @@ define('CRYPT_AES_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation

View File

@ -98,7 +98,7 @@ define('CRYPT_MODE_STREAM', 5);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Base value for the internal implementation $engine switch * Base value for the internal implementation $engine switch
@ -123,7 +123,7 @@ class Crypt_Base
/** /**
* The Encryption Mode * The Encryption Mode
* *
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @var Integer * @var Integer
* @access private * @access private
*/ */
@ -312,7 +312,7 @@ class Crypt_Base
/** /**
* Is the mode one that is paddable? * Is the mode one that is paddable?
* *
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @var Boolean * @var Boolean
* @access private * @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_AES_MODE_CFB); // $aes will operate in cfb mode
* $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical * $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical
* *
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @var String * @var String
* @access private * @access private
*/ */
@ -443,7 +443,7 @@ class Crypt_Base
* @param optional Integer $mode * @param optional Integer $mode
* @access public * @access public
*/ */
function Crypt_Base($mode = CRYPT_MODE_CBC) function __construct($mode = CRYPT_MODE_CBC)
{ {
$const_crypt_mode = 'CRYPT_' . $this->const_namespace . '_MODE'; $const_crypt_mode = 'CRYPT_' . $this->const_namespace . '_MODE';

View File

@ -103,7 +103,7 @@ define('CRYPT_BLOWFISH_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation

View File

@ -123,7 +123,7 @@ define('CRYPT_DES_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation

View File

@ -58,7 +58,7 @@ use \phpseclib\Math\BigInteger;
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Hash::Crypt_Hash() * @see Crypt_Hash::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation
@ -153,7 +153,7 @@ class Crypt_Hash
* @return Crypt_Hash * @return Crypt_Hash
* @access public * @access public
*/ */
function Crypt_Hash($hash = 'sha1') function __construct($hash = 'sha1')
{ {
if ( !defined('CRYPT_HASH_MODE') ) { if ( !defined('CRYPT_HASH_MODE') ) {
switch (true) { switch (true) {

View File

@ -101,7 +101,7 @@ define('CRYPT_RC2_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_RC2::Crypt_RC2() * @see Crypt_RC2::__construct()
*/ */
/** /**
* Toggles the internal implementation * 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. * If not explicitly set, CRYPT_RC2_MODE_CBC will be used.
* *
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @param optional Integer $mode * @param optional Integer $mode
* @access public * @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(''); $this->setKey('');
} }

View File

@ -71,7 +71,7 @@ if (!class_exists('Crypt_Base')) {
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_RC4::Crypt_RC4() * @see Crypt_RC4::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation
@ -172,13 +172,13 @@ class Crypt_RC4 extends Crypt_Base
* *
* Determines whether or not the mcrypt extension should be used. * Determines whether or not the mcrypt extension should be used.
* *
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @return Crypt_RC4 * @return Crypt_RC4
* @access public * @access public
*/ */
function Crypt_RC4() function __construct()
{ {
parent::Crypt_Base(CRYPT_MODE_STREAM); parent::__construct(CRYPT_MODE_STREAM);
} }
/** /**

View File

@ -155,7 +155,7 @@ define('CRYPT_RSA_ASN1_SEQUENCE', 48);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_RSA::Crypt_RSA() * @see Crypt_RSA::__construct()
*/ */
/** /**
* To use the pure-PHP implementation * To use the pure-PHP implementation
@ -473,7 +473,7 @@ class Crypt_RSA
* @return Crypt_RSA * @return Crypt_RSA
* @access public * @access public
*/ */
function Crypt_RSA() function __construct()
{ {
$this->configFile = CRYPT_RSA_OPENSSL_CONFIG; $this->configFile = CRYPT_RSA_OPENSSL_CONFIG;

View File

@ -120,7 +120,7 @@ define('CRYPT_RIJNDAEL_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation

View File

@ -181,18 +181,18 @@ class Crypt_TripleDES extends Crypt_DES
* *
* If not explicitly set, CRYPT_DES_MODE_CBC will be used. * If not explicitly set, CRYPT_DES_MODE_CBC will be used.
* *
* @see Crypt_DES::Crypt_DES() * @see Crypt_DES::__construct()
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
* @param optional Integer $mode * @param optional Integer $mode
* @access public * @access public
*/ */
function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC) function __construct($mode = CRYPT_DES_MODE_CBC)
{ {
switch ($mode) { switch ($mode) {
// In case of CRYPT_DES_MODE_3CBC, we init as CRYPT_DES_MODE_CBC // In case of CRYPT_DES_MODE_3CBC, we init as CRYPT_DES_MODE_CBC
// and additional flag us internally as 3CBC // and additional flag us internally as 3CBC
case CRYPT_DES_MODE_3CBC: case CRYPT_DES_MODE_3CBC:
parent::Crypt_DES(CRYPT_DES_MODE_CBC); parent::__construct(CRYPT_DES_MODE_CBC);
$this->mode_3cbc = true; $this->mode_3cbc = true;
// This three $des'es will do the 3CBC work (if $key > 64bits) // This three $des'es will do the 3CBC work (if $key > 64bits)
@ -209,7 +209,7 @@ class Crypt_TripleDES extends Crypt_DES
break; break;
// If not 3CBC, we init as usual // If not 3CBC, we init as usual
default: default:
parent::Crypt_DES($mode); parent::__construct($mode);
} }
} }

View File

@ -103,7 +103,7 @@ define('CRYPT_TWOFISH_MODE_OFB', CRYPT_MODE_OFB);
/**#@+ /**#@+
* @access private * @access private
* @see Crypt_Base::Crypt_Base() * @see Crypt_Base::__construct()
*/ */
/** /**
* Toggles the internal implementation * Toggles the internal implementation

View File

@ -211,7 +211,7 @@ class File_ANSI
* @return File_ANSI * @return File_ANSI
* @access public * @access public
*/ */
function File_ANSI() function __construct()
{ {
$this->setHistory(200); $this->setHistory(200);
$this->setDimensions(80, 24); $this->setDimensions(80, 24);

View File

@ -133,7 +133,7 @@ class File_ASN1_Element
* @return File_ASN1_Element * @return File_ASN1_Element
* @access public * @access public
*/ */
function File_ASN1_Element($encoded) function __construct($encoded)
{ {
$this->element = $encoded; $this->element = $encoded;
} }

View File

@ -313,7 +313,7 @@ class File_X509
* @return File_X509 * @return File_X509
* @access public * @access public
*/ */
function File_X509() function __construct()
{ {
// Explicitly Tagged Module, 1988 Syntax // Explicitly Tagged Module, 1988 Syntax
// http://tools.ietf.org/html/rfc5280#appendix-A.1 // http://tools.ietf.org/html/rfc5280#appendix-A.1

View File

@ -122,7 +122,7 @@ class Net_SCP
* @return Net_SCP * @return Net_SCP
* @access public * @access public
*/ */
function Net_SCP($ssh) function __construct($ssh)
{ {
if (!is_object($ssh)) { if (!is_object($ssh)) {
return; return;

View File

@ -124,7 +124,7 @@ class Net_SFTP extends Net_SSH2
/** /**
* Packet Types * Packet Types
* *
* @see Net_SFTP::Net_SFTP() * @see Net_SFTP::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -133,7 +133,7 @@ class Net_SFTP extends Net_SSH2
/** /**
* Status Codes * Status Codes
* *
* @see Net_SFTP::Net_SFTP() * @see Net_SFTP::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -245,7 +245,7 @@ class Net_SFTP extends Net_SSH2
/** /**
* Max SFTP Packet Size * Max SFTP Packet Size
* *
* @see Net_SFTP::Net_SFTP() * @see Net_SFTP::__construct()
* @see Net_SFTP::get() * @see Net_SFTP::get()
* @var Array * @var Array
* @access private * @access private
@ -283,9 +283,9 @@ class Net_SFTP extends Net_SSH2
* @return Net_SFTP * @return Net_SFTP
* @access public * @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; $this->max_sftp_packet = 1 << 15;

View File

@ -131,7 +131,7 @@ class Net_SFTP_Stream
* *
* @access public * @access public
*/ */
function Net_SFTP_Stream() function __construct()
{ {
if (defined('NET_SFTP_STREAM_LOGGING')) { if (defined('NET_SFTP_STREAM_LOGGING')) {
echo "__construct()\r\n"; echo "__construct()\r\n";

View File

@ -360,7 +360,7 @@ class Net_SSH1
/** /**
* Protocol Flags * Protocol Flags
* *
* @see Net_SSH1::Net_SSH1() * @see Net_SSH1::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -463,7 +463,7 @@ class Net_SSH1
/** /**
* Hostname * Hostname
* *
* @see Net_SSH1::Net_SSH1() * @see Net_SSH1::__construct()
* @see Net_SSH1::_connect() * @see Net_SSH1::_connect()
* @var String * @var String
* @access private * @access private
@ -473,7 +473,7 @@ class Net_SSH1
/** /**
* Port Number * Port Number
* *
* @see Net_SSH1::Net_SSH1() * @see Net_SSH1::__construct()
* @see Net_SSH1::_connect() * @see Net_SSH1::_connect()
* @var Integer * @var Integer
* @access private * @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 * 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. * 10 seconds. It is used by fsockopen() in that function.
* *
* @see Net_SSH1::Net_SSH1() * @see Net_SSH1::__construct()
* @see Net_SSH1::_connect() * @see Net_SSH1::_connect()
* @var Integer * @var Integer
* @access private * @access private
@ -498,7 +498,7 @@ class Net_SSH1
/** /**
* Default cipher * Default cipher
* *
* @see Net_SSH1::Net_SSH1() * @see Net_SSH1::__construct()
* @see Net_SSH1::_connect() * @see Net_SSH1::_connect()
* @var Integer * @var Integer
* @access private * @access private
@ -517,7 +517,7 @@ class Net_SSH1
* @return Net_SSH1 * @return Net_SSH1
* @access public * @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 // Include Crypt_Random
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and // 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 * 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... * 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 Math_BigInteger $m
* @param Array $key * @param Array $key
* @return Math_BigInteger * @return Math_BigInteger

View File

@ -299,7 +299,7 @@ class Net_SSH2
* *
* -- http://tools.ietf.org/html/rfc4253#section-6 * -- http://tools.ietf.org/html/rfc4253#section-6
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @see Net_SSH2::_send_binary_packet() * @see Net_SSH2::_send_binary_packet()
* @var Integer * @var Integer
* @access private * @access private
@ -309,7 +309,7 @@ class Net_SSH2
/** /**
* Block Size for Client to Server Encryption * Block Size for Client to Server Encryption
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @see Net_SSH2::_get_binary_packet() * @see Net_SSH2::_get_binary_packet()
* @var Integer * @var Integer
* @access private * @access private
@ -403,7 +403,7 @@ class Net_SSH2
/** /**
* Message Numbers * Message Numbers
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -412,7 +412,7 @@ class Net_SSH2
/** /**
* Disconnection Message 'reason codes' defined in RFC4253 * Disconnection Message 'reason codes' defined in RFC4253
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -421,7 +421,7 @@ class Net_SSH2
/** /**
* SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -431,7 +431,7 @@ class Net_SSH2
* Terminal Modes * Terminal Modes
* *
* @link http://tools.ietf.org/html/rfc4254#section-8 * @link http://tools.ietf.org/html/rfc4254#section-8
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -441,7 +441,7 @@ class Net_SSH2
* SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes
* *
* @link http://tools.ietf.org/html/rfc4254#section-5.2 * @link http://tools.ietf.org/html/rfc4254#section-5.2
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @var Array * @var Array
* @access private * @access private
*/ */
@ -789,7 +789,7 @@ class Net_SSH2
/** /**
* Hostname * Hostname
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @see Net_SSH2::_connect() * @see Net_SSH2::_connect()
* @var String * @var String
* @access private * @access private
@ -799,7 +799,7 @@ class Net_SSH2
/** /**
* Port Number * Port Number
* *
* @see Net_SSH2::Net_SSH2() * @see Net_SSH2::__construct()
* @see Net_SSH2::_connect() * @see Net_SSH2::_connect()
* @var Integer * @var Integer
* @access private * @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 * 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. * 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() * @see Net_SSH2::_connect()
* @var Integer * @var Integer
* @access private * @access private
@ -831,7 +831,7 @@ class Net_SSH2
* @return Net_SSH2 * @return Net_SSH2
* @access public * @access public
*/ */
function Net_SSH2($host, $port = 22, $timeout = 10) function __construct($host, $port = 22, $timeout = 10)
{ {
if (!function_exists('crypt_random_string')) { if (!function_exists('crypt_random_string')) {
include_once 'Crypt/Random.php'; include_once 'Crypt/Random.php';

View File

@ -115,7 +115,7 @@ class System_SSH_Agent_Identity
* @return System_SSH_Agent_Identity * @return System_SSH_Agent_Identity
* @access private * @access private
*/ */
function System_SSH_Agent_Identity($fsock) function __construct($fsock)
{ {
$this->fsock = $fsock; $this->fsock = $fsock;
} }
@ -231,7 +231,7 @@ class System_SSH_Agent
* @return System_SSH_Agent * @return System_SSH_Agent
* @access public * @access public
*/ */
function System_SSH_Agent() function __construct()
{ {
switch (true) { switch (true) {
case isset($_SERVER['SSH_AUTH_SOCK']): case isset($_SERVER['SSH_AUTH_SOCK']):