add PHP5-style constructors along side PHP4-style ones

This commit is contained in:
terrafrost 2016-09-09 21:52:56 -08:00
parent 1eda62913a
commit 845135f887
18 changed files with 217 additions and 52 deletions

View File

@ -6,6 +6,7 @@ php:
- 5.5.9 - 5.5.9
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0
- hhvm - hhvm
env: env:
@ -26,7 +27,7 @@ install:
- cd .. - cd ..
- eval `ssh-agent -s` - eval `ssh-agent -s`
- travis/setup-secure-shell.sh - travis/setup-secure-shell.sh
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then travis/install-php-extensions.sh; fi" - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' ]; then travis/install-php-extensions.sh; fi"
- travis/setup-composer.sh - travis/setup-composer.sh
script: script:

View File

@ -503,7 +503,7 @@ class Crypt_Base
* @param int $mode * @param int $mode
* @access public * @access public
*/ */
function Crypt_Base($mode = CRYPT_MODE_CBC) function __construct($mode = CRYPT_MODE_CBC)
{ {
// $mode dependent settings // $mode dependent settings
switch ($mode) { switch ($mode) {
@ -531,6 +531,18 @@ class Crypt_Base
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param int $mode
* @access public
*/
function Crypt_Base($mode = CRYPT_MODE_CBC)
{
$this->__construct($mode);
}
/** /**
* Sets the initialization vector. (optional) * Sets the initialization vector. (optional)
* *

View File

@ -151,7 +151,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) {
@ -169,6 +169,18 @@ class Crypt_Hash
$this->setHash($hash); $this->setHash($hash);
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param int $mode
* @access public
*/
function Crypt_Hash($hash = 'sha1')
{
$this->__construct($mode);
}
/** /**
* Sets the key for HMACs * Sets the key for HMACs
* *

View File

@ -161,9 +161,20 @@ class Crypt_RC4 extends Crypt_Base
* @return Crypt_RC4 * @return Crypt_RC4
* @access public * @access public
*/ */
function __construct()
{
parent::__construct(CRYPT_MODE_STREAM);
}
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function Crypt_RC4() function Crypt_RC4()
{ {
parent::Crypt_Base(CRYPT_MODE_STREAM); $this->__construct();
} }
/** /**

View File

@ -491,7 +491,7 @@ class Crypt_RSA
* @return Crypt_RSA * @return Crypt_RSA
* @access public * @access public
*/ */
function Crypt_RSA() function __construct()
{ {
if (!class_exists('Math_BigInteger')) { if (!class_exists('Math_BigInteger')) {
include_once 'Math/BigInteger.php'; include_once 'Math/BigInteger.php';
@ -562,6 +562,17 @@ class Crypt_RSA
$this->mgfHLen = $this->mgfHash->getLength(); $this->mgfHLen = $this->mgfHash->getLength();
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function Crypt_RSA()
{
$this->__construct();
}
/** /**
* Create public / private key pair * Create public / private key pair
* *

View File

@ -241,34 +241,6 @@ class Crypt_Rijndael extends Crypt_Base
*/ */
var $kl; var $kl;
/**
* Default Constructor.
*
* Determines whether or not the mcrypt extension should be used.
*
* $mode could be:
*
* - CRYPT_RIJNDAEL_MODE_ECB
*
* - CRYPT_RIJNDAEL_MODE_CBC
*
* - CRYPT_RIJNDAEL_MODE_CTR
*
* - CRYPT_RIJNDAEL_MODE_CFB
*
* - CRYPT_RIJNDAEL_MODE_OFB
*
* If not explictly set, CRYPT_RIJNDAEL_MODE_CBC will be used.
*
* @see Crypt_Base::Crypt_Base()
* @param int $mode
* @access public
*/
function Crypt_Rijndael($mode = CRYPT_RIJNDAEL_MODE_CBC)
{
parent::Crypt_Base($mode);
}
/** /**
* Sets the key. * Sets the key.
* *

View File

@ -196,7 +196,7 @@ class Crypt_TripleDES extends Crypt_DES
* @param int $mode * @param int $mode
* @access public * @access public
*/ */
function Crypt_TripleDES($mode = CRYPT_MODE_CBC) function __construct($mode = CRYPT_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
@ -219,10 +219,22 @@ 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_Base($mode); parent::__construct($mode);
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param int $mode
* @access public
*/
function Crypt_TripleDES($mode = CRYPT_MODE_CBC)
{
$this->__construct($mode);
}
/** /**
* Test for engine validity * Test for engine validity
* *

View File

@ -179,7 +179,7 @@ class File_ANSI
* @return File_ANSI * @return File_ANSI
* @access public * @access public
*/ */
function File_ANSI() function __construct()
{ {
$attr_cell = new stdClass(); $attr_cell = new stdClass();
$attr_cell->bold = false; $attr_cell->bold = false;
@ -195,6 +195,17 @@ class File_ANSI
$this->setDimensions(80, 24); $this->setDimensions(80, 24);
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function File_ANSI()
{
$this->__construct($mode);
}
/** /**
* Set terminal width and height * Set terminal width and height
* *

View File

@ -131,10 +131,22 @@ 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;
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param int $mode
* @access public
*/
function File_ASN1_Element($encoded)
{
$this->__construct($encoded);
}
} }
/** /**
@ -245,7 +257,7 @@ class File_ASN1
* *
* @access public * @access public
*/ */
function File_ASN1() function __construct()
{ {
static $static_init = null; static $static_init = null;
if (!$static_init) { if (!$static_init) {
@ -256,6 +268,17 @@ class File_ASN1
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function File_ASN1()
{
$this->__construct($mode);
}
/** /**
* Parse BER-encoding * Parse BER-encoding
* *

View File

@ -326,7 +326,7 @@ class File_X509
* @return File_X509 * @return File_X509
* @access public * @access public
*/ */
function File_X509() function __construct()
{ {
if (!class_exists('Math_BigInteger')) { if (!class_exists('Math_BigInteger')) {
include_once 'Math/BigInteger.php'; include_once 'Math/BigInteger.php';
@ -1448,6 +1448,17 @@ class File_X509
); );
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function File_X509()
{
$this->__construct();
}
/** /**
* Load X.509 certificate * Load X.509 certificate
* *

View File

@ -243,7 +243,7 @@ class Math_BigInteger
* @return Math_BigInteger * @return Math_BigInteger
* @access public * @access public
*/ */
function Math_BigInteger($x = 0, $base = 10) function __construct($x = 0, $base = 10)
{ {
if (!defined('MATH_BIGINTEGER_MODE')) { if (!defined('MATH_BIGINTEGER_MODE')) {
switch (true) { switch (true) {
@ -500,6 +500,19 @@ class Math_BigInteger
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param $x base-10 number or base-$base number if $base set.
* @param int $base
* @access public
*/
function Math_BigInteger($x = 0, $base = 10)
{
$this->__construct($x, $base);
}
/** /**
* Converts a BigInteger to a byte string (eg. base-256). * Converts a BigInteger to a byte string (eg. base-256).
* *

View File

@ -116,13 +116,11 @@ class Net_SCP
* *
* Connects to an SSH server * Connects to an SSH server
* *
* @param string $host * @param Net_SSH1|Net_SSH2 $ssh
* @param int $port
* @param int $timeout
* @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;
@ -143,6 +141,18 @@ class Net_SCP
$this->ssh = $ssh; $this->ssh = $ssh;
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param Net_SSH1|Net_SSH2 $ssh
* @access public
*/
function Net_SCP($ssh)
{
$this->__construct($ssh);
}
/** /**
* Uploads a file to the SCP server. * Uploads a file to the SCP server.
* *

View File

@ -288,9 +288,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;
@ -417,6 +417,20 @@ class Net_SFTP extends Net_SSH2
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param string $host
* @param int $port
* @param int $timeout
* @access public
*/
function Net_SFTP($host, $port = 22, $timeout = 10)
{
$this->__construct($host, $port, $timeout);
}
/** /**
* Login * Login
* *

View File

@ -146,7 +146,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

@ -515,7 +515,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)
{ {
if (!class_exists('Math_BigInteger')) { if (!class_exists('Math_BigInteger')) {
include_once 'Math/BigInteger.php'; include_once 'Math/BigInteger.php';
@ -557,6 +557,21 @@ class Net_SSH1
$this->cipher = $cipher; $this->cipher = $cipher;
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param string $host
* @param int $port
* @param int $timeout
* @param int $cipher
* @access public
*/
function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES)
{
$this->__construct($host, $port, $timeout, $cipher);
}
/** /**
* Connect to an SSHv1 server * Connect to an SSHv1 server
* *

View File

@ -883,7 +883,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)
{ {
// Include Math_BigInteger // Include Math_BigInteger
// Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification.
@ -992,6 +992,20 @@ class Net_SSH2
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param mixed $host
* @param int $port
* @param int $timeout
* @access public
*/
function Net_SSH2($host, $port = 22, $timeout = 10)
{
$this->__construct($host, $port, $timeout);
}
/** /**
* Set Crypto Engine Mode * Set Crypto Engine Mode
* *

View File

@ -130,11 +130,23 @@ 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;
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @param resource $fsock
* @access public
*/
function System_SSH_Agent_Identity($fsock)
{
$this->__construct($fsock);
}
/** /**
* Set Public Key * Set Public Key
* *
@ -269,7 +281,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']):
@ -289,6 +301,17 @@ class System_SSH_Agent
} }
} }
/**
* PHP4 compatible Default Constructor.
*
* @see self::__construct()
* @access public
*/
function System_SSH_Agent()
{
$this->__construct();
}
/** /**
* Request Identities * Request Identities
* *

View File

@ -20,7 +20,7 @@ then
PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0" PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0"
fi fi
if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ] if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o "$TRAVIS_PHP_VERSION" = '7.0' ]
then then
find tests -type f -name "*Test.php" | \ find tests -type f -name "*Test.php" | \
parallel --gnu --keep-order \ parallel --gnu --keep-order \