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 03a3244d12
commit 680b19a1da
10 changed files with 76 additions and 78 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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