FIX: Correct PHP4-style constructors in SimpleTest.

Note that the best solution to this will be to remove the use of
SimpleTest entirely. This is quick fix is intended to help us get PHP7
tests running without needing to cross that bridge.
This commit is contained in:
Sam Minnee 2015-08-27 13:10:48 +12:00
parent 40bf945322
commit cca7e9697c
10 changed files with 76 additions and 89 deletions

View File

@ -36,7 +36,7 @@ class SimpleCookie {
* @param string $expiry Expiry date as string.
* @param boolean $is_secure Currently ignored.
*/
function SimpleCookie($name, $value = false, $path = false, $expiry = false, $is_secure = false) {
function __construct($name, $value = false, $path = false, $expiry = false, $is_secure = false) {
$this->_host = false;
$this->_name = $name;
$this->_value = $value;
@ -232,7 +232,7 @@ class SimpleCookieJar {
* Constructor. Jar starts empty.
* @access public
*/
function SimpleCookieJar() {
function __construct() {
$this->_cookies = array();
}

View File

@ -26,7 +26,7 @@ class SimpleEncodedPair {
* @param string $key Form element name.
* @param string $value Data to send.
*/
function SimpleEncodedPair($key, $value) {
function __construct($key, $value) {
$this->_key = $key;
$this->_value = $value;
}
@ -97,7 +97,7 @@ class SimpleAttachment {
* @param string $content Raw data.
* @param hash $filename Original filename.
*/
function SimpleAttachment($key, $content, $filename) {
function __construct($key, $content, $filename) {
$this->_key = $key;
$this->_content = $content;
$this->_filename = $filename;
@ -198,7 +198,7 @@ class SimpleEncoding {
* as lists on a single key.
* @access public
*/
function SimpleEncoding($query = false) {
function __construct($query = false) {
if (! $query) {
$query = array();
}
@ -328,17 +328,6 @@ class SimpleEncoding {
*/
class SimpleGetEncoding extends SimpleEncoding {
/**
* Starts empty.
* @param array $query Hash of parameters.
* Multiple values are
* as lists on a single key.
* @access public
*/
function SimpleGetEncoding($query = false) {
$this->SimpleEncoding($query);
}
/**
* HTTP request method.
* @return string Always GET.
@ -390,8 +379,8 @@ class SimpleHeadEncoding extends SimpleGetEncoding {
* as lists on a single key.
* @access public
*/
function SimpleHeadEncoding($query = false) {
$this->SimpleGetEncoding($query);
function __construct($query = false) {
parent::__construct($query);
}
/**
@ -419,11 +408,11 @@ class SimplePostEncoding extends SimpleEncoding {
* as lists on a single key.
* @access public
*/
function SimplePostEncoding($query = false) {
function __construct($query = false) {
if (is_array($query) and $this->hasMoreThanOneLevel($query)) {
$query = $this->rewriteArrayWithMultipleLevels($query);
}
$this->SimpleEncoding($query);
parent::__construct($query);
}
function hasMoreThanOneLevel($query) {
@ -509,8 +498,8 @@ class SimpleMultipartEncoding extends SimplePostEncoding {
* as lists on a single key.
* @access public
*/
function SimpleMultipartEncoding($query = false, $boundary = false) {
$this->SimplePostEncoding($query);
function __construct($query = false, $boundary = false) {
parent::__construct($query);
$this->_boundary = ($boundary === false ? uniqid('st') : $boundary);
}

View File

@ -36,7 +36,7 @@ class SimpleForm {
* @param SimpleTag $tag Form tag to read.
* @param SimplePage $page Holding page.
*/
function SimpleForm($tag, &$page) {
function __construct($tag, &$page) {
$this->_method = $tag->getAttribute('method');
$this->_action = $this->_createAction($tag->getAttribute('action'), $page);
$this->_encoding = $this->_setEncodingClass($tag);

View File

@ -28,7 +28,7 @@ class SimpleRoute {
* @param SimpleUrl $url URL as object.
* @access public
*/
function SimpleRoute($url) {
function __construct($url) {
$this->_url = $url;
}
@ -125,8 +125,8 @@ class SimpleProxyRoute extends SimpleRoute {
* @param string $password Password for autentication.
* @access public
*/
function SimpleProxyRoute($url, $proxy, $username = false, $password = false) {
$this->SimpleRoute($url);
function __construct($url, $proxy, $username = false, $password = false) {
parent::__construct($url);
$this->_proxy = $proxy;
$this->_username = $username;
$this->_password = $password;
@ -208,7 +208,7 @@ class SimpleHttpRequest {
* request.
* @access public
*/
function SimpleHttpRequest(&$route, $encoding) {
function __construct(&$route, $encoding) {
$this->_route = &$route;
$this->_encoding = $encoding;
$this->_headers = array();
@ -307,7 +307,7 @@ class SimpleHttpHeaders {
* @param string $headers Header block.
* @access public
*/
function SimpleHttpHeaders($headers) {
function __construct($headers) {
$this->_raw_headers = $headers;
$this->_response_code = false;
$this->_http_version = false;
@ -494,8 +494,8 @@ class SimpleHttpResponse extends SimpleStickyError {
* @param mixed $encoding Record of content sent.
* @access public
*/
function SimpleHttpResponse(&$socket, $url, $encoding) {
$this->SimpleStickyError();
function __construct(&$socket, $url, $encoding) {
parent::__construct();
$this->_url = $url;
$this->_encoding = $encoding;
$this->_sent = $socket->getSent();

View File

@ -127,10 +127,9 @@ class SimplePageBuilder extends SimpleSaxListener {
* Sets the builder up empty.
* @access public
*/
function SimplePageBuilder() {
$this->SimpleSaxListener();
function __construct() {
parent::__construct();
}
/**
* Frees up any references so as to allow the PHP garbage
* collection from unset() to work.
@ -358,7 +357,7 @@ class SimplePage {
* @param SimpleHttpResponse $response Result of HTTP fetch.
* @access public
*/
function SimplePage($response = false) {
function __construct($response = false) {
$this->_links = array();
$this->_title = false;
$this->_left_over_labels = array();

View File

@ -37,7 +37,7 @@ class ParallelRegex {
* for insensitive.
* @access public
*/
function ParallelRegex($case) {
function __construct($case) {
$this->_case = $case;
$this->_patterns = array();
$this->_labels = array();
@ -129,7 +129,7 @@ class SimpleStateStack {
* @param string $start Starting state name.
* @access public
*/
function SimpleStateStack($start) {
function __construct($start) {
$this->_stack = array($start);
}
@ -193,7 +193,7 @@ class SimpleLexer {
* @param boolean $case True for case sensitive.
* @access public
*/
function SimpleLexer(&$parser, $start = "accept", $case = false) {
function __construct(&$parser, $start = "accept", $case = false) {
$this->_case = $case;
$this->_regexes = array();
$this->_parser = &$parser;
@ -456,8 +456,8 @@ class SimpleHtmlLexer extends SimpleLexer {
* reference.
* @access public
*/
function SimpleHtmlLexer(&$parser) {
$this->SimpleLexer($parser, 'text');
function __construct(&$parser) {
parent::__construct($parser, 'text');
$this->mapHandler('text', 'acceptTextToken');
$this->_addSkipping();
foreach ($this->_getParsedTags() as $tag) {
@ -552,7 +552,7 @@ class SimpleHtmlSaxParser {
* @param SimpleSaxListener $listener SAX event handler.
* @access public
*/
function SimpleHtmlSaxParser(&$listener) {
function __construct(&$listener) {
$this->_listener = &$listener;
$this->_lexer = &$this->createLexer($this);
$this->_tag = '';
@ -728,7 +728,7 @@ class SimpleSaxListener {
* Sets the document to write to.
* @access public
*/
function SimpleSaxListener() {
function __construct() {
}
/**

View File

@ -26,7 +26,7 @@ class SimpleByName {
* Stashes the name for later comparison.
* @param string $name Name attribute to match.
*/
function SimpleByName($name) {
function __construct($name) {
$this->_name = $name;
}
@ -57,7 +57,7 @@ class SimpleByLabel {
* Stashes the name for later comparison.
* @param string $label Visible text to match.
*/
function SimpleByLabel($label) {
function __construct($label) {
$this->_label = $label;
}
@ -88,7 +88,7 @@ class SimpleById {
* Stashes the name for later comparison.
* @param string $id ID atribute to match.
*/
function SimpleById($id) {
function __construct($id) {
$this->_id = $id;
}
@ -115,7 +115,7 @@ class SimpleByLabelOrName {
* Stashes the name/label for later comparison.
* @param string $label Visible text to match.
*/
function SimpleByLabelOrName($label) {
function __construct($label) {
$this->_label = $label;
}

View File

@ -25,7 +25,7 @@ class SimpleStickyError {
* Sets the error to empty.
* @access public
*/
function SimpleStickyError() {
function __construct() {
$this->_clearError();
}
@ -85,8 +85,8 @@ class SimpleSocket extends SimpleStickyError {
* @param integer $block_size Size of chunk to read.
* @access public
*/
function SimpleSocket($host, $port, $timeout, $block_size = 255) {
$this->SimpleStickyError();
function __construct($host, $port, $timeout, $block_size = 255) {
parent::__construct();
if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
$this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds");
return;
@ -196,8 +196,8 @@ class SimpleSecureSocket extends SimpleSocket {
* @param integer $timeout Connection timeout in seconds.
* @access public
*/
function SimpleSecureSocket($host, $port, $timeout) {
$this->SimpleSocket($host, $port, $timeout);
function __construct($host, $port, $timeout) {
parent::__construct($host, $port, $timeout);
}
/**

View File

@ -31,7 +31,7 @@ class SimpleTag {
* the keys must have been
* converted to lower case.
*/
function SimpleTag($name, $attributes) {
function __construct($name, $attributes) {
$this->_name = strtolower(trim($name));
$this->_attributes = $attributes;
$this->_content = '';
@ -162,8 +162,8 @@ class SimpleBaseTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleBaseTag($attributes) {
$this->SimpleTag('base', $attributes);
function __construct($attributes) {
parent::__construct('base', $attributes);
}
/**
@ -188,8 +188,8 @@ class SimpleTitleTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleTitleTag($attributes) {
$this->SimpleTag('title', $attributes);
function __construct($attributes) {
parent::__construct('title', $attributes);
}
}
@ -205,8 +205,8 @@ class SimpleAnchorTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleAnchorTag($attributes) {
$this->SimpleTag('a', $attributes);
function __construct($attributes) {
parent::__construct('a', $attributes);
}
/**
@ -239,8 +239,8 @@ class SimpleWidget extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleWidget($name, $attributes) {
$this->SimpleTag($name, $attributes);
function __construct($name, $attributes) {
parent::__construct($name, $attributes);
$this->_value = false;
$this->_label = false;
$this->_is_set = false;
@ -344,8 +344,8 @@ class SimpleTextTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleTextTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
if ($this->getAttribute('value') === false) {
$this->_setAttribute('value', '');
}
@ -387,8 +387,8 @@ class SimpleSubmitTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleSubmitTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
if ($this->getAttribute('value') === false) {
$this->_setAttribute('value', 'Submit');
}
@ -445,10 +445,9 @@ class SimpleImageSubmitTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleImageSubmitTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
}
/**
* Tag contains no end element.
* @return boolean False.
@ -521,8 +520,8 @@ class SimpleButtonTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleButtonTag($attributes) {
$this->SimpleWidget('button', $attributes);
function __construct($attributes) {
parent::__construct('button', $attributes);
}
/**
@ -577,8 +576,8 @@ class SimpleTextAreaTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleTextAreaTag($attributes) {
$this->SimpleWidget('textarea', $attributes);
function __construct($attributes) {
parent::__construct('textarea', $attributes);
}
/**
@ -662,8 +661,8 @@ class SimpleUploadTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleUploadTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
}
/**
@ -705,8 +704,8 @@ class SimpleSelectionTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleSelectionTag($attributes) {
$this->SimpleWidget('select', $attributes);
function __construct($attributes) {
parent::__construct('select', $attributes);
$this->_options = array();
$this->_choice = false;
}
@ -792,8 +791,8 @@ class MultipleSelectionTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function MultipleSelectionTag($attributes) {
$this->SimpleWidget('select', $attributes);
function __construct($attributes) {
parent::__construct('select', $attributes);
$this->_options = array();
$this->_values = false;
}
@ -883,8 +882,8 @@ class SimpleOptionTag extends SimpleWidget {
/**
* Stashes the attributes.
*/
function SimpleOptionTag($attributes) {
$this->SimpleWidget('option', $attributes);
function __construct($attributes) {
parent::__construct('option', $attributes);
}
/**
@ -945,8 +944,8 @@ class SimpleRadioButtonTag extends SimpleWidget {
* Stashes the attributes.
* @param array $attributes Hash of attributes.
*/
function SimpleRadioButtonTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
if ($this->getAttribute('value') === false) {
$this->_setAttribute('value', 'on');
}
@ -1003,8 +1002,8 @@ class SimpleCheckboxTag extends SimpleWidget {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleCheckboxTag($attributes) {
$this->SimpleWidget('input', $attributes);
function __construct($attributes) {
parent::__construct('input', $attributes);
if ($this->getAttribute('value') === false) {
$this->_setAttribute('value', 'on');
}
@ -1359,8 +1358,8 @@ class SimpleLabelTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleLabelTag($attributes) {
$this->SimpleTag('label', $attributes);
function __construct($attributes) {
parent::__construct('label', $attributes);
}
/**
@ -1385,8 +1384,8 @@ class SimpleFormTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleFormTag($attributes) {
$this->SimpleTag('form', $attributes);
function __construct($attributes) {
parent::__construct('form', $attributes);
}
}
@ -1402,8 +1401,8 @@ class SimpleFrameTag extends SimpleTag {
* @param hash $attributes Attribute names and
* string values.
*/
function SimpleFrameTag($attributes) {
$this->SimpleTag('frame', $attributes);
function __construct($attributes) {
parent::__construct('frame', $attributes);
}
/**

View File

@ -41,7 +41,7 @@ class SimpleUrl {
* @param string $url Incoming URL.
* @access public
*/
function SimpleUrl($url = '') {
function __construct($url = '') {
list($x, $y) = $this->_chompCoordinates($url);
$this->setCoordinates($x, $y);
$this->_scheme = $this->_chompScheme($url);