summaryrefslogtreecommitdiff
path: root/tests/test_tools/simpletest
diff options
context:
space:
mode:
authorxue <>2006-12-01 12:28:55 +0000
committerxue <>2006-12-01 12:28:55 +0000
commit17f49a9bc71d88c9b3e2f31a161f3689c136ac16 (patch)
treefc77b9c75927cd56281417843a318e85c39ce729 /tests/test_tools/simpletest
parent074032e0270ae70eed481a082158dc9554aaa1db (diff)
merge from 3.0 branch till 1531.
Diffstat (limited to 'tests/test_tools/simpletest')
-rw-r--r--tests/test_tools/simpletest/authentication.php36
-rw-r--r--tests/test_tools/simpletest/compatibility.php34
-rw-r--r--tests/test_tools/simpletest/dumper.php40
-rw-r--r--tests/test_tools/simpletest/expectation.php114
-rw-r--r--tests/test_tools/simpletest/mock_objects.php6
-rw-r--r--tests/test_tools/simpletest/options.php88
-rw-r--r--tests/test_tools/simpletest/parser.php104
-rw-r--r--tests/test_tools/simpletest/reporter.php2
-rw-r--r--tests/test_tools/simpletest/scorer.php2
-rw-r--r--tests/test_tools/simpletest/simple_test.php2
-rw-r--r--tests/test_tools/simpletest/simpletest.php22
-rw-r--r--tests/test_tools/simpletest/test_case.php2
-rw-r--r--tests/test_tools/simpletest/url.php72
13 files changed, 262 insertions, 262 deletions
diff --git a/tests/test_tools/simpletest/authentication.php b/tests/test_tools/simpletest/authentication.php
index 2677f3b2..9d72966a 100644
--- a/tests/test_tools/simpletest/authentication.php
+++ b/tests/test_tools/simpletest/authentication.php
@@ -9,7 +9,7 @@
* include http class
*/
require_once(dirname(__FILE__) . '/http.php');
-
+
/**
* Represents a single security realm's identity.
* @package SimpleTest
@@ -20,7 +20,7 @@
protected $_root;
protected $_username;
protected $_password;
-
+
/**
* Starts with the initial entry directory.
* @param string $type Authentication type for this
@@ -35,7 +35,7 @@
$this->_username = false;
$this->_password = false;
}
-
+
/**
* Adds another location to the realm.
* @param SimpleUrl $url Somewhere in realm.
@@ -44,7 +44,7 @@
function stretch($url) {
$this->_root = $this->_getCommonPath($this->_root, $url->getPath());
}
-
+
/**
* Finds the common starting path.
* @param string $first Path to compare.
@@ -62,7 +62,7 @@
}
return implode('/', $first) . '/';
}
-
+
/**
* Sets the identity to try within this realm.
* @param string $username Username in authentication dialog.
@@ -73,7 +73,7 @@
$this->_username = $username;
$this->_password = $password;
}
-
+
/**
* Accessor for current identity.
* @return string Last succesful username.
@@ -82,7 +82,7 @@
function getUsername() {
return $this->_username;
}
-
+
/**
* Accessor for current identity.
* @return string Last succesful password.
@@ -91,7 +91,7 @@
function getPassword() {
return $this->_password;
}
-
+
/**
* Test to see if the URL is within the directory
* tree of the realm.
@@ -108,7 +108,7 @@
}
return false;
}
-
+
/**
* Tests to see if one string is a substring of
* another.
@@ -122,7 +122,7 @@
return strpos($whole, $part) === 0;
}
}
-
+
/**
* Manages security realms.
* @package SimpleTest
@@ -130,7 +130,7 @@
*/
class SimpleAuthenticator {
protected $_realms;
-
+
/**
* Clears the realms.
* @access public
@@ -138,7 +138,7 @@
function SimpleAuthenticator() {
$this->restartSession();
}
-
+
/**
* Starts with no realms set up.
* @access public
@@ -146,7 +146,7 @@
function restartSession() {
$this->_realms = array();
}
-
+
/**
* Adds a new realm centered the current URL.
* Browsers vary wildly on their behaviour in this
@@ -166,7 +166,7 @@
function addRealm($url, $type, $realm) {
$this->_realms[$url->getHost()][$realm] = new SimpleRealm($type, $url);
}
-
+
/**
* Sets the current identity to be presented
* against that realm.
@@ -181,7 +181,7 @@
$this->_realms[$host][$realm]->setIdentity($username, $password);
}
}
-
+
/**
* Finds the name of the realm by comparing URLs.
* @param SimpleUrl $url URL to test.
@@ -199,7 +199,7 @@
}
return false;
}
-
+
/**
* Presents the appropriate headers for this location.
* @param SimpleHttpRequest $request Request to modify.
@@ -218,7 +218,7 @@
}
$this->addBasicHeaders($request, $username, $password);
}
-
+
/**
* Presents the appropriate headers for this
* location for basic authentication.
@@ -228,7 +228,7 @@
* @access public
* @static
*/
- function addBasicHeaders($request, $username, $password) {
+ static function addBasicHeaders($request, $username, $password) {
if ($username && $password) {
$request->addHeaderLine(
'Authorization: Basic ' . base64_encode("$username:$password"));
diff --git a/tests/test_tools/simpletest/compatibility.php b/tests/test_tools/simpletest/compatibility.php
index d3495cf9..0be00ca8 100644
--- a/tests/test_tools/simpletest/compatibility.php
+++ b/tests/test_tools/simpletest/compatibility.php
@@ -4,14 +4,14 @@
* @package SimpleTest
* @version $Id$
*/
-
+
/**
* Static methods for compatibility between different
* PHP versions.
* @package SimpleTest
*/
class SimpleTestCompatibility {
-
+
/**
* Creates a copy whether in PHP5 or PHP4.
* @param object $object Thing to copy.
@@ -19,14 +19,14 @@
* @access public
* @static
*/
- function copy($object) {
+ static function copy($object) {
if (version_compare(phpversion(), '5') >= 0) {
eval('$copy = clone $object;');
return $copy;
}
return $object;
}
-
+
/**
* Identity test. Drops back to equality + types for PHP5
* objects as the === operator counts as the
@@ -37,7 +37,7 @@
* @access public
* @static
*/
- function isIdentical($first, $second) {
+ static function isIdentical($first, $second) {
if ($first != $second) {
return false;
}
@@ -46,7 +46,7 @@
}
return ($first === $second);
}
-
+
/**
* Recursive type test.
* @param mixed $first Test subject.
@@ -55,7 +55,7 @@
* @access private
* @static
*/
- function _isIdenticalType($first, $second) {
+ static function _isIdenticalType($first, $second) {
if (gettype($first) != gettype($second)) {
return false;
}
@@ -72,7 +72,7 @@
}
return true;
}
-
+
/**
* Recursive type test for each element of an array.
* @param mixed $first Test subject.
@@ -81,7 +81,7 @@
* @access private
* @static
*/
- function _isArrayOfIdenticalTypes($first, $second) {
+ static function _isArrayOfIdenticalTypes($first, $second) {
if (array_keys($first) != array_keys($second)) {
return false;
}
@@ -95,7 +95,7 @@
}
return true;
}
-
+
/**
* Test for two variables being aliases.
* @param mixed $first Test subject.
@@ -104,7 +104,7 @@
* @access public
* @static
*/
- function isReference($first, $second) {
+ static function isReference($first, $second) {
if (version_compare(phpversion(), '5', '>=')
&& is_object($first)) {
return ($first === $second);
@@ -122,7 +122,7 @@
$first = $temp;
return $is_ref;
}
-
+
/**
* Test to see if an object is a member of a
* class hiearchy.
@@ -132,7 +132,7 @@
* @access public
* @static
*/
- function isA($object, $class) {
+ static function isA($object, $class) {
if (version_compare(phpversion(), '5') >= 0) {
if (! class_exists($class, false)) {
if (function_exists('interface_exists')) {
@@ -150,7 +150,7 @@
return ((strtolower($class) == get_class($object))
or (is_subclass_of($object, $class)));
}
-
+
/**
* Sets a socket timeout for each chunk.
* @param resource $handle Socket handle.
@@ -158,7 +158,7 @@
* @access public
* @static
*/
- function setTimeout($handle, $timeout) {
+ static function setTimeout($handle, $timeout) {
if (function_exists('stream_set_timeout')) {
stream_set_timeout($handle, $timeout, 0);
} elseif (function_exists('socket_set_timeout')) {
@@ -167,14 +167,14 @@
set_socket_timeout($handle, $timeout, 0);
}
}
-
+
/**
* Gets the current stack trace topmost first.
* @return array List of stack frames.
* @access public
* @static
*/
- function getStackTrace() {
+ static function getStackTrace() {
if (function_exists('debug_backtrace')) {
return array_reverse(debug_backtrace());
}
diff --git a/tests/test_tools/simpletest/dumper.php b/tests/test_tools/simpletest/dumper.php
index 63af5ea8..97c249ea 100644
--- a/tests/test_tools/simpletest/dumper.php
+++ b/tests/test_tools/simpletest/dumper.php
@@ -11,14 +11,14 @@
if (! defined('TYPE_MATTERS')) {
define('TYPE_MATTERS', true);
}
-
+
/**
* Displays variables as text and does diffs.
* @package SimpleTest
* @subpackage UnitTester
*/
class SimpleDumper {
-
+
/**
* Renders a variable in a shorter form than print_r().
* @param mixed $value Variable to render as a string.
@@ -43,7 +43,7 @@
}
return "Unknown";
}
-
+
/**
* Gets the string representation of a type.
* @param mixed $value Variable to check against.
@@ -95,7 +95,7 @@
$method = '_describe' . $type . 'Difference';
return $this->$method($first, $second, $identical);
}
-
+
/**
* Tests to see if types match.
* @param mixed $first First variable.
@@ -128,7 +128,7 @@
$value = substr($value, $start, $size);
return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : "");
}
-
+
/**
* Creates a human readable description of the
* difference between two variables. The minimal
@@ -143,7 +143,7 @@
"] does not match [" .
$this->describeValue($second) . "]";
}
-
+
/**
* Creates a human readable description of the
* difference between a null and another variable.
@@ -156,7 +156,7 @@
function _describeNullDifference($first, $second, $identical) {
return $this->_describeGenericDifference($first, $second);
}
-
+
/**
* Creates a human readable description of the
* difference between a boolean and another variable.
@@ -169,7 +169,7 @@
function _describeBooleanDifference($first, $second, $identical) {
return $this->_describeGenericDifference($first, $second);
}
-
+
/**
* Creates a human readable description of the
* difference between a string and another variable.
@@ -190,7 +190,7 @@
$this->clipString($second, 200, $position) . "]";
return $message;
}
-
+
/**
* Creates a human readable description of the
* difference between an integer and another variable.
@@ -209,7 +209,7 @@
$this->describeValue($second) . "] by " .
abs($first - $second);
}
-
+
/**
* Creates a human readable description of the
* difference between two floating point numbers.
@@ -228,7 +228,7 @@
$this->describeValue($second) . "] by " .
abs($first - $second);
}
-
+
/**
* Creates a human readable description of the
* difference between two arrays.
@@ -261,7 +261,7 @@
}
return "";
}
-
+
/**
* Compares two arrays to see if their key lists match.
* For an identical match, the ordering and types of the keys
@@ -282,7 +282,7 @@
sort($second_keys);
return ($first_keys == $second_keys);
}
-
+
/**
* Creates a human readable description of the
* difference between a resource and another variable.
@@ -295,7 +295,7 @@
function _describeResourceDifference($first, $second, $identical) {
return $this->_describeGenericDifference($first, $second);
}
-
+
/**
* Creates a human readable description of the
* difference between two objects.
@@ -314,7 +314,7 @@
get_object_vars($second),
$identical);
}
-
+
/**
* Find the first character position that differs
* in two strings by binary chop.
@@ -341,7 +341,7 @@
}
return $position;
}
-
+
/**
* Sends a formatted dump of a variable to a string.
* @param mixed $variable Variable to display.
@@ -349,7 +349,7 @@
* @access public
* @static
*/
- function dump($variable) {
+ static function dump($variable) {
ob_start();
print_r($variable);
$formatted = ob_get_contents();
@@ -364,7 +364,7 @@
* @access public
* @static
*/
- function getFormattedAssertionLine($stack) {
+ static function getFormattedAssertionLine($stack) {
foreach ($stack as $frame) {
if (isset($frame['file'])) {
if (strpos($frame['file'], SIMPLE_TEST) !== false) {
@@ -379,14 +379,14 @@
}
return '';
}
-
+
/**
* Tries to determine if the method call is an assertion.
* @param array $frame PHP stack frame.
* @access private
* @static
*/
- function _stackFrameIsAnAssertion($frame) {
+ static function _stackFrameIsAnAssertion($frame) {
if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) {
return true;
}
diff --git a/tests/test_tools/simpletest/expectation.php b/tests/test_tools/simpletest/expectation.php
index 9c514119..a27149ff 100644
--- a/tests/test_tools/simpletest/expectation.php
+++ b/tests/test_tools/simpletest/expectation.php
@@ -5,14 +5,14 @@
* @subpackage UnitTester
* @version $Id$
*/
-
+
/**#@+
* include other SimpleTest class files
*/
require_once(dirname(__FILE__) . '/dumper.php');
require_once(dirname(__FILE__) . '/compatibility.php');
/**#@-*/
-
+
/**
* Assertion that can display failure information.
* Also includes various helper methods.
@@ -23,7 +23,7 @@
class SimpleExpectation {
protected $_dumper;
protected $_message;
-
+
/**
* Creates a dumper for displaying values and sets
* the test message.
@@ -33,7 +33,7 @@
$this->_dumper = new SimpleDumper();
$this->_message = $message;
}
-
+
/**
* Tests the expectation. True if correct.
* @param mixed $compare Comparison value.
@@ -43,7 +43,7 @@
*/
function test($compare) {
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -54,7 +54,7 @@
*/
function testMessage($compare) {
}
-
+
/**
* Overlays the generated message onto the stored user
* message. An additional message can be interjected.
@@ -66,7 +66,7 @@
function overlayMessage($compare) {
return sprintf($this->_message, $this->testMessage($compare));
}
-
+
/**
* Accessor for the dumper.
* @return SimpleDumper Current value dumper.
@@ -75,7 +75,7 @@
function &_getDumper() {
return $this->_dumper;
}
-
+
/**
* Test to see if a value is an expectation object.
* A useful utility method.
@@ -86,12 +86,12 @@
* @access public
* @static
*/
- function isExpectation($expectation) {
+ static function isExpectation($expectation) {
return is_object($expectation) &&
SimpleTestCompatibility::isA($expectation, 'SimpleExpectation');
}
}
-
+
/**
* Test for equality.
* @package SimpleTest
@@ -99,7 +99,7 @@
*/
class EqualExpectation extends SimpleExpectation {
protected $_value;
-
+
/**
* Sets the value to compare against.
* @param mixed $value Test value to match.
@@ -110,7 +110,7 @@
$this->SimpleExpectation($message);
$this->_value = $value;
}
-
+
/**
* Tests the expectation. True if it matches the
* held value.
@@ -121,7 +121,7 @@
function test($compare) {
return (($this->_value == $compare) && ($compare == $this->_value));
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -147,14 +147,14 @@
return $this->_value;
}
}
-
+
/**
* Test for inequality.
* @package SimpleTest
* @subpackage UnitTester
*/
class NotEqualExpectation extends EqualExpectation {
-
+
/**
* Sets the value to compare against.
* @param mixed $value Test value to match.
@@ -164,7 +164,7 @@
function NotEqualExpectation($value, $message = '%s') {
$this->EqualExpectation($value, $message);
}
-
+
/**
* Tests the expectation. True if it differs from the
* held value.
@@ -175,7 +175,7 @@
function test($compare) {
return ! parent::test($compare);
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -195,7 +195,7 @@
}
}
}
-
+
/**
* Test for being within a range.
* @package SimpleTest
@@ -204,7 +204,7 @@
class WithinMarginExpectation extends SimpleExpectation {
protected $_upper;
protected $_lower;
-
+
/**
* Sets the value to compare against and the fuzziness of
* the match. Used for comparing floating point values.
@@ -218,7 +218,7 @@
$this->_upper = $value + $margin;
$this->_lower = $value - $margin;
}
-
+
/**
* Tests the expectation. True if it matches the
* held value.
@@ -229,7 +229,7 @@
function test($compare) {
return (($compare <= $this->_upper) && ($compare >= $this->_lower));
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -244,7 +244,7 @@
return $this->_outsideMessage($compare);
}
}
-
+
/**
* Creates a the message for being within the range.
* @param mixed $compare Value being tested.
@@ -254,7 +254,7 @@
return "Within expectation [" . $this->_dumper->describeValue($this->_lower) . "] and [" .
$this->_dumper->describeValue($this->_upper) . "]";
}
-
+
/**
* Creates a the message for being within the range.
* @param mixed $compare Value being tested.
@@ -270,14 +270,14 @@
}
}
}
-
+
/**
* Test for being outside of a range.
* @package SimpleTest
* @subpackage UnitTester
*/
class OutsideMarginExpectation extends WithinMarginExpectation {
-
+
/**
* Sets the value to compare against and the fuzziness of
* the match. Used for comparing floating point values.
@@ -289,7 +289,7 @@
function OutsideMarginExpectation($value, $margin, $message = '%s') {
$this->WithinMarginExpectation($value, $margin, $message);
}
-
+
/**
* Tests the expectation. True if it matches the
* held value.
@@ -300,7 +300,7 @@
function test($compare) {
return ! parent::test($compare);
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -316,14 +316,14 @@
}
}
}
-
+
/**
* Test for identity.
* @package SimpleTest
* @subpackage UnitTester
*/
class IdenticalExpectation extends EqualExpectation {
-
+
/**
* Sets the value to compare against.
* @param mixed $value Test value to match.
@@ -333,7 +333,7 @@
function IdenticalExpectation($value, $message = '%s') {
$this->EqualExpectation($value, $message);
}
-
+
/**
* Tests the expectation. True if it exactly
* matches the held value.
@@ -344,7 +344,7 @@
function test($compare) {
return SimpleTestCompatibility::isIdentical($this->_getValue(), $compare);
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -364,14 +364,14 @@
}
}
}
-
+
/**
* Test for non-identity.
* @package SimpleTest
* @subpackage UnitTester
*/
class NotIdenticalExpectation extends IdenticalExpectation {
-
+
/**
* Sets the value to compare against.
* @param mixed $value Test value to match.
@@ -381,7 +381,7 @@
function NotIdenticalExpectation($value, $message = '%s') {
$this->IdenticalExpectation($value, $message);
}
-
+
/**
* Tests the expectation. True if it differs from the
* held value.
@@ -392,7 +392,7 @@
function test($compare) {
return ! parent::test($compare);
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -410,7 +410,7 @@
}
}
}
-
+
/**
* Test for a pattern using Perl regex rules.
* @package SimpleTest
@@ -418,7 +418,7 @@
*/
class PatternExpectation extends SimpleExpectation {
protected $_pattern;
-
+
/**
* Sets the value to compare against.
* @param string $pattern Pattern to search for.
@@ -429,7 +429,7 @@
$this->SimpleExpectation($message);
$this->_pattern = $pattern;
}
-
+
/**
* Accessor for the pattern.
* @return string Perl regex as string.
@@ -438,7 +438,7 @@
function _getPattern() {
return $this->_pattern;
}
-
+
/**
* Tests the expectation. True if the Perl regex
* matches the comparison value.
@@ -449,7 +449,7 @@
function test($compare) {
return (boolean)preg_match($this->_getPattern(), $compare);
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
@@ -467,7 +467,7 @@
$dumper->describeValue($compare) . "]";
}
}
-
+
/**
* Describes a pattern match including the string
* found and it's position.
@@ -487,13 +487,13 @@
$dumper->clipString($subject, 100, $position) . "]";
}
}
-
+
/**
* @deprecated
*/
class WantedPatternExpectation extends PatternExpectation {
}
-
+
/**
* Fail if a pattern is detected within the
* comparison.
@@ -501,7 +501,7 @@
* @subpackage UnitTester
*/
class NoPatternExpectation extends PatternExpectation {
-
+
/**
* Sets the reject pattern
* @param string $pattern Pattern to search for.
@@ -511,7 +511,7 @@
function NoPatternExpectation($pattern, $message = '%s') {
$this->PatternExpectation($pattern, $message);
}
-
+
/**
* Tests the expectation. False if the Perl regex
* matches the comparison value.
@@ -522,7 +522,7 @@
function test($compare) {
return ! parent::test($compare);
}
-
+
/**
* Returns a human readable test message.
* @param string $compare Comparison value.
@@ -541,7 +541,7 @@
}
}
}
-
+
/**
* @package SimpleTest
* @subpackage UnitTester
@@ -549,7 +549,7 @@
*/
class UnwantedPatternExpectation extends NoPatternExpectation {
}
-
+
/**
* Tests either type or class name if it's an object.
* @package SimpleTest
@@ -557,7 +557,7 @@
*/
class IsAExpectation extends SimpleExpectation {
protected $_type;
-
+
/**
* Sets the type to compare with.
* @param string $type Type or class name.
@@ -568,7 +568,7 @@
$this->SimpleExpectation($message);
$this->_type = $type;
}
-
+
/**
* Accessor for type to check against.
* @return string Type or class name.
@@ -577,7 +577,7 @@
function _getType() {
return $this->_type;
}
-
+
/**
* Tests the expectation. True if the type or
* class matches the string value.
@@ -625,7 +625,7 @@
"] should be type [" . $this->_type . "]";
}
}
-
+
/**
* Tests either type or class name if it's an object.
* Will succeed if the type does not match.
@@ -634,7 +634,7 @@
*/
class NotAExpectation extends IsAExpectation {
protected $_type;
-
+
/**
* Sets the type to compare with.
* @param string $type Type or class name.
@@ -644,7 +644,7 @@
function NotAExpectation($type, $message = '%s') {
$this->IsAExpectation($type, $message);
}
-
+
/**
* Tests the expectation. False if the type or
* class matches the string value.
@@ -677,7 +677,7 @@
*/
class MethodExistsExpectation extends SimpleExpectation {
protected $_method;
-
+
/**
* Sets the value to compare against.
* @param string $method Method to check.
@@ -689,7 +689,7 @@
$this->SimpleExpectation($message);
$this->_method = $method;
}
-
+
/**
* Tests the expectation. True if the method exists in the test object.
* @param string $compare Comparison method name.
@@ -699,7 +699,7 @@
function test($compare) {
return (boolean)(is_object($compare) && method_exists($compare, $this->_method));
}
-
+
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
diff --git a/tests/test_tools/simpletest/mock_objects.php b/tests/test_tools/simpletest/mock_objects.php
index c7eb7cb6..6aa6a190 100644
--- a/tests/test_tools/simpletest/mock_objects.php
+++ b/tests/test_tools/simpletest/mock_objects.php
@@ -946,7 +946,7 @@
* @static
* @access public
*/
- function generate($class, $mock_class = false, $methods = false) {
+ static function generate($class, $mock_class = false, $methods = false) {
$generator = new MockGenerator($class, $mock_class);
return $generator->generate($methods);
}
@@ -963,7 +963,7 @@
* @static
* @access public
*/
- function generatePartial($class, $mock_class, $methods) {
+ static function generatePartial($class, $mock_class, $methods) {
$generator = new MockGenerator($class, $mock_class);
return $generator->generatePartial($methods);
}
@@ -978,7 +978,7 @@
* @access public
* @static
*/
- function getExpectationLine($stack = false) {
+ static function getExpectationLine($stack = false) {
if ($stack === false) {
$stack = SimpleTestCompatibility::getStackTrace();
}
diff --git a/tests/test_tools/simpletest/options.php b/tests/test_tools/simpletest/options.php
index e110fc45..e4bc97ea 100644
--- a/tests/test_tools/simpletest/options.php
+++ b/tests/test_tools/simpletest/options.php
@@ -4,24 +4,24 @@
* @package SimpleTest
* @version $Id$
*/
-
+
/**
* Static global directives and options.
* @package SimpleTest
*/
class SimpleTestOptions {
-
+
/**
* Reads the SimpleTest version from the release file.
* @return string Version string.
* @static
* @access public
*/
- function getVersion() {
+ static function getVersion() {
$content = file(dirname(__FILE__) . '/VERSION');
return trim($content[0]);
}
-
+
/**
* Sets the name of a test case to ignore, usually
* because the class is an abstract case that should
@@ -30,11 +30,11 @@
* @static
* @access public
*/
- function ignore($class) {
+ static function ignore($class) {
$registry =SimpleTestOptions::_getRegistry();
$registry['IgnoreList'][] = strtolower($class);
}
-
+
/**
* Test to see if a test case is in the ignore
* list.
@@ -43,11 +43,11 @@
* @access public
* @static
*/
- function isIgnored($class) {
+ static function isIgnored($class) {
$registry =SimpleTestOptions::_getRegistry();
return in_array(strtolower($class), $registry['IgnoreList']);
}
-
+
/**
* The base class name is settable here. This is the
* class that a new stub will inherited from.
@@ -58,22 +58,22 @@
* @static
* @access public
*/
- function setStubBaseClass($stub_base) {
+ static function setStubBaseClass($stub_base) {
$registry =SimpleTestOptions::_getRegistry();
$registry['StubBaseClass'] = $stub_base;
}
-
+
/**
* Accessor for the currently set stub base class.
* @return string Class name to inherit from.
* @static
* @access public
*/
- function getStubBaseClass() {
+ static function getStubBaseClass() {
$registry =SimpleTestOptions::_getRegistry();
return $registry['StubBaseClass'];
}
-
+
/**
* The base class name is settable here. This is the
* class that a new mock will inherited from.
@@ -84,22 +84,22 @@
* @static
* @access public
*/
- function setMockBaseClass($mock_base) {
+ static function setMockBaseClass($mock_base) {
$registry =SimpleTestOptions::_getRegistry();
$registry['MockBaseClass'] = $mock_base;
}
-
+
/**
* Accessor for the currently set mock base class.
* @return string Class name to inherit from.
* @static
* @access public
*/
- function getMockBaseClass() {
+ static function getMockBaseClass() {
$registry =SimpleTestOptions::_getRegistry();
return $registry['MockBaseClass'];
}
-
+
/**
* Adds additional mock code.
* @param string $code Extra code that can be added
@@ -109,11 +109,11 @@
* the mock base classes.
* @access public
*/
- function addPartialMockCode($code = '') {
+ static function addPartialMockCode($code = '') {
$registry =SimpleTestOptions::_getRegistry();
$registry['AdditionalPartialMockCode'] = $code;
}
-
+
/**
* Accessor for additional partial mock code.
* @return string Extra code.
@@ -123,7 +123,7 @@
$registry =SimpleTestOptions::_getRegistry();
return $registry['AdditionalPartialMockCode'];
}
-
+
/**
* Sets proxy to use on all requests for when
* testing from behind a firewall. Set host
@@ -134,13 +134,13 @@
* @param string $password Proxy password for authentication.
* @access public
*/
- function useProxy($proxy, $username = false, $password = false) {
+ static function useProxy($proxy, $username = false, $password = false) {
$registry =SimpleTestOptions::_getRegistry();
$registry['DefaultProxy'] = $proxy;
$registry['DefaultProxyUsername'] = $username;
$registry['DefaultProxyPassword'] = $password;
}
-
+
/**
* Accessor for default proxy host.
* @return string Proxy URL.
@@ -150,7 +150,7 @@
$registry =SimpleTestOptions::_getRegistry();
return $registry['DefaultProxy'];
}
-
+
/**
* Accessor for default proxy username.
* @return string Proxy username for authentication.
@@ -160,7 +160,7 @@
$registry =SimpleTestOptions::_getRegistry();
return $registry['DefaultProxyUsername'];
}
-
+
/**
* Accessor for default proxy password.
* @return string Proxy password for authentication.
@@ -170,28 +170,28 @@
$registry =SimpleTestOptions::_getRegistry();
return $registry['DefaultProxyPassword'];
}
-
+
/**
* Accessor for global registry of options.
* @return hash All stored values.
* @access private
* @static
*/
- function _getRegistry() {
+ static function _getRegistry() {
static $registry = false;
if (! $registry) {
$registry = SimpleTestOptions::_getDefaults();
}
return $registry;
}
-
+
/**
* Constant default values.
* @return hash All registry defaults.
* @access private
* @static
*/
- function _getDefaults() {
+ static function _getDefaults() {
return array(
'StubBaseClass' => 'SimpleStub',
'MockBaseClass' => 'SimpleMock',
@@ -202,14 +202,14 @@
'DefaultProxyPassword' => false);
}
}
-
+
/**
* Static methods for compatibility between different
* PHP versions.
* @package SimpleTest
*/
class SimpleTestCompatibility {
-
+
/**
* Identity test. Drops back to equality + types for PHP5
* objects as the === operator counts as the
@@ -219,7 +219,7 @@
* @access public
* @static
*/
- function isIdentical($first, $second) {
+ static function isIdentical($first, $second) {
if ($first != $second) {
return false;
}
@@ -228,7 +228,7 @@
}
return ($first === $second);
}
-
+
/**
* Recursive type test.
* @param mixed $first Test subject.
@@ -236,7 +236,7 @@
* @access private
* @static
*/
- function _isIdenticalType($first, $second) {
+ static function _isIdenticalType($first, $second) {
if (gettype($first) != gettype($second)) {
return false;
}
@@ -253,7 +253,7 @@
}
return true;
}
-
+
/**
* Recursive type test for each element of an array.
* @param mixed $first Test subject.
@@ -261,7 +261,7 @@
* @access private
* @static
*/
- function _isArrayOfIdenticalTypes($first, $second) {
+ static function _isArrayOfIdenticalTypes($first, $second) {
if (array_keys($first) != array_keys($second)) {
return false;
}
@@ -275,7 +275,7 @@
}
return true;
}
-
+
/**
* Test for two variables being aliases.
* @param mixed $first Test subject.
@@ -283,7 +283,7 @@
* @access public
* @static
*/
- function isReference($first, $second) {
+ static function isReference($first, $second) {
if (version_compare(phpversion(), '5', '>=')
&& is_object($first)) {
return ($first === $second);
@@ -294,7 +294,7 @@
$first = $temp;
return $is_ref;
}
-
+
/**
* Test to see if an object is a member of a
* class hiearchy.
@@ -303,7 +303,7 @@
* @access public
* @static
*/
- function isA($object, $class) {
+ static function isA($object, $class) {
if (version_compare(phpversion(), '5') >= 0) {
if (! class_exists($class, false)) {
return false;
@@ -317,7 +317,7 @@
return ((strtolower($class) == get_class($object))
or (is_subclass_of($object, $class)));
}
-
+
/**
* Autoload safe version of class_exists().
* @param string $class Name of class to look for.
@@ -325,14 +325,14 @@
* @access public
* @static
*/
- function classExists($class) {
+ static function classExists($class) {
if (version_compare(phpversion(), '5') >= 0) {
return class_exists($class, false);
} else {
return class_exists($class);
}
}
-
+
/**
* Sets a socket timeout for each chunk.
* @param resource $handle Socket handle.
@@ -340,7 +340,7 @@
* @access public
* @static
*/
- function setTimeout($handle, $timeout) {
+ static function setTimeout($handle, $timeout) {
if (function_exists('stream_set_timeout')) {
stream_set_timeout($handle, $timeout, 0);
} elseif (function_exists('socket_set_timeout')) {
@@ -349,14 +349,14 @@
set_socket_timeout($handle, $timeout, 0);
}
}
-
+
/**
* Gets the current stack trace topmost first.
* @return array List of stack frames.
* @access public
* @static
*/
- function getStackTrace() {
+ static function getStackTrace() {
if (function_exists('debug_backtrace')) {
return array_reverse(debug_backtrace());
}
diff --git a/tests/test_tools/simpletest/parser.php b/tests/test_tools/simpletest/parser.php
index 26519e49..5ac737cf 100644
--- a/tests/test_tools/simpletest/parser.php
+++ b/tests/test_tools/simpletest/parser.php
@@ -25,7 +25,7 @@
define('LEXER_SPECIAL', 5);
}
/**#@-*/
-
+
/**
* Compounded regular expression. Any of
* the contained patterns could match and
@@ -38,7 +38,7 @@
protected $_labels;
protected $_regex;
protected $_case;
-
+
/**
* Constructor. Starts with no patterns.
* @param boolean $case True for case sensitive, false
@@ -51,7 +51,7 @@
$this->_labels = array();
$this->_regex = null;
}
-
+
/**
* Adds a pattern with an optional label.
* @param string $pattern Perl style regex, but ( and )
@@ -66,7 +66,7 @@
$this->_labels[$count] = $label;
$this->_regex = null;
}
-
+
/**
* Attempts to match all patterns at once against
* a string.
@@ -92,7 +92,7 @@
}
return true;
}
-
+
/**
* Compounds the patterns into a single
* regular expression separated with the
@@ -113,7 +113,7 @@
}
return $this->_regex;
}
-
+
/**
* Accessor for perl regex mode flags to use.
* @return string Perl regex flags.
@@ -123,7 +123,7 @@
return ($this->_case ? "msS" : "msSi");
}
}
-
+
/**
* States for a stack machine.
* @package SimpleTest
@@ -131,7 +131,7 @@
*/
class SimpleStateStack {
protected $_stack;
-
+
/**
* Constructor. Starts in named state.
* @param string $start Starting state name.
@@ -140,7 +140,7 @@
function SimpleStateStack($start) {
$this->_stack = array($start);
}
-
+
/**
* Accessor for current state.
* @return string State.
@@ -149,7 +149,7 @@
function getCurrent() {
return $this->_stack[count($this->_stack) - 1];
}
-
+
/**
* Adds a state to the stack and sets it
* to be the current state.
@@ -159,7 +159,7 @@
function enter($state) {
array_push($this->_stack, $state);
}
-
+
/**
* Leaves the current state and reverts
* to the previous one.
@@ -175,7 +175,7 @@
return true;
}
}
-
+
/**
* Accepts text and breaks it into tokens.
* Some optimisation to make the sure the
@@ -191,7 +191,7 @@
protected $_mode;
protected $_mode_handlers;
protected $_case;
-
+
/**
* Sets up the lexer in case insensitive matching
* by default.
@@ -208,7 +208,7 @@
$this->_mode = new SimpleStateStack($start);
$this->_mode_handlers = array($start => $start);
}
-
+
/**
* Adds a token search pattern for a particular
* parsing mode. The pattern does not change the
@@ -229,7 +229,7 @@
$this->_mode_handlers[$mode] = $mode;
}
}
-
+
/**
* Adds a pattern that will enter a new parsing
* mode. Useful for entering parenthesis, strings,
@@ -252,7 +252,7 @@
$this->_mode_handlers[$new_mode] = $new_mode;
}
}
-
+
/**
* Adds a pattern that will exit the current mode
* and re-enter the previous one.
@@ -270,7 +270,7 @@
$this->_mode_handlers[$mode] = $mode;
}
}
-
+
/**
* Adds a pattern that has a special mode. Acts as an entry
* and exit pattern in one go, effectively calling a special
@@ -292,7 +292,7 @@
$this->_mode_handlers[$special] = $special;
}
}
-
+
/**
* Adds a mapping from a mode to another handler.
* @param string $mode Mode to be remapped.
@@ -302,7 +302,7 @@
function mapHandler($mode, $handler) {
$this->_mode_handlers[$mode] = $handler;
}
-
+
/**
* Splits the page text into tokens. Will fail
* if the handlers report an error or if no
@@ -336,7 +336,7 @@
}
return $this->_invokeParser($raw, LEXER_UNMATCHED);
}
-
+
/**
* Sends the matched token and any leading unmatched
* text to the parser changing the lexer to a new
@@ -372,7 +372,7 @@
$this->_mode->enter($mode);
return $this->_invokeParser($matched, LEXER_ENTER);
}
-
+
/**
* Tests to see if the new mode is actually to leave
* the current mode and pop an item from the matching
@@ -384,7 +384,7 @@
function _isModeEnd($mode) {
return ($mode === "__exit");
}
-
+
/**
* Test to see if the mode is one where this mode
* is entered for this token only and automatically
@@ -396,7 +396,7 @@
function _isSpecialMode($mode) {
return (strncmp($mode, "_", 1) == 0);
}
-
+
/**
* Strips the magic underscore marking single token
* modes.
@@ -407,7 +407,7 @@
function _decodeSpecial($mode) {
return substr($mode, 1);
}
-
+
/**
* Calls the parser method named after the current
* mode. Empty content will be ignored. The lexer
@@ -424,7 +424,7 @@
$handler = $this->_mode_handlers[$this->_mode->getCurrent()];
return $this->_parser->$handler($content, $is_match);
}
-
+
/**
* Tries to match a chunk of text and if successful
* removes the recognised chunk and any leading
@@ -449,14 +449,14 @@
return true;
}
}
-
+
/**
* Breas HTML into SAX events.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleHtmlLexer extends SimpleLexer {
-
+
/**
* Sets up the lexer with case insensitive matching
* and adds the HTML handlers.
@@ -473,7 +473,7 @@
}
$this->_addInTagTokens();
}
-
+
/**
* List of parsed tags. Others are ignored.
* @return array List of searched for tags.
@@ -483,7 +483,7 @@
return array('a', 'title', 'form', 'input', 'button', 'textarea', 'select',
'option', 'frameset', 'frame', 'label');
}
-
+
/**
* The lexer has to skip certain sections such
* as server code, client code and styles.
@@ -500,7 +500,7 @@
$this->addEntryPattern('<!--', 'text', 'comment');
$this->addExitPattern('-->', 'comment');
}
-
+
/**
* Pattern matches to start and end a tag.
* @param string $tag Name of tag to scan for.
@@ -510,7 +510,7 @@
$this->addSpecialPattern("</$tag>", 'text', 'acceptEndToken');
$this->addEntryPattern("<$tag", 'text', 'tag');
}
-
+
/**
* Pattern matches to parse the inside of a tag
* including the attributes and their quoting.
@@ -523,7 +523,7 @@
$this->addExitPattern('/>', 'tag');
$this->addExitPattern('>', 'tag');
}
-
+
/**
* Matches attributes that are either single quoted,
* double quoted or unquoted.
@@ -542,7 +542,7 @@
$this->addSpecialPattern('=\s*[^>\s]*', 'tag', 'uq_attribute');
}
}
-
+
/**
* Converts HTML tokens into selected SAX events.
* @package SimpleTest
@@ -554,7 +554,7 @@
protected $_tag;
protected $_attributes;
protected $_current_attribute;
-
+
/**
* Sets the listener.
* @param SimpleSaxListener $listener SAX event handler.
@@ -567,7 +567,7 @@
$this->_attributes = array();
$this->_current_attribute = '';
}
-
+
/**
* Runs the content through the lexer which
* should call back to the acceptors.
@@ -578,7 +578,7 @@
function parse($raw) {
return $this->_lexer->parse($raw);
}
-
+
/**
* Sets up the matching lexer. Starts in 'text' mode.
* @param SimpleSaxParser $parser Event generator, usually $self.
@@ -586,11 +586,11 @@
* @access public
* @static
*/
- function &createLexer($parser) {
+ static function &createLexer($parser) {
$lexer = new SimpleHtmlLexer($parser);
return $lexer;
}
-
+
/**
* Accepts a token from the tag mode. If the
* starting element completes then the element
@@ -621,7 +621,7 @@
}
return true;
}
-
+
/**
* Accepts a token from the end tag mode.
* The element name is converted to lower case.
@@ -636,7 +636,7 @@
}
return $this->_listener->endElement(strtolower($matches[1]));
}
-
+
/**
* Part of the tag data.
* @param string $token Incoming characters.
@@ -655,7 +655,7 @@
}
return true;
}
-
+
/**
* A character entity.
* @param string $token Incoming characters.
@@ -665,7 +665,7 @@
*/
function acceptEntityToken($token, $event) {
}
-
+
/**
* Character data between tags regarded as
* important.
@@ -677,7 +677,7 @@
function acceptTextToken($token, $event) {
return $this->_listener->addContent($token);
}
-
+
/**
* Incoming data to be ignored.
* @param string $token Incoming characters.
@@ -688,7 +688,7 @@
function ignore($token, $event) {
return true;
}
-
+
/**
* Decodes any HTML entities.
* @param string $html Incoming HTML.
@@ -696,14 +696,14 @@
* @access public
* @static
*/
- function decodeHtml($html) {
+ static function decodeHtml($html) {
static $translations;
if (! isset($translations)) {
$translations = array_flip(get_html_translation_table(HTML_ENTITIES));
}
return strtr($html, $translations);
}
-
+
/**
* Turns HTML into text browser visible text. Images
* are converted to their alt text and tags are supressed.
@@ -713,7 +713,7 @@
* @access public
* @static
*/
- function normalise($html) {
+ static function normalise($html) {
$text = preg_replace('|<!--.*?-->|', '', $html);
$text = preg_replace('|<img.*?alt\s*=\s*"(.*?)".*?>|', ' \1 ', $text);
$text = preg_replace('|<img.*?alt\s*=\s*\'(.*?)\'.*?>|', ' \1 ', $text);
@@ -724,7 +724,7 @@
return trim($text);
}
}
-
+
/**
* SAX event handler.
* @package SimpleTest
@@ -732,14 +732,14 @@
* @abstract
*/
class SimpleSaxListener {
-
+
/**
* Sets the document to write to.
* @access public
*/
function SimpleSaxListener() {
}
-
+
/**
* Start of element event.
* @param string $name Element name.
@@ -751,7 +751,7 @@
*/
function startElement($name, $attributes) {
}
-
+
/**
* End of element event.
* @param string $name Element name.
@@ -760,7 +760,7 @@
*/
function endElement($name) {
}
-
+
/**
* Unparsed, but relevant data.
* @param string $text May include unparsed tags.
diff --git a/tests/test_tools/simpletest/reporter.php b/tests/test_tools/simpletest/reporter.php
index 3e7b2766..1e30d2bf 100644
--- a/tests/test_tools/simpletest/reporter.php
+++ b/tests/test_tools/simpletest/reporter.php
@@ -58,7 +58,7 @@
* @access public
* @static
*/
- function sendNoCacheHeaders() {
+ static function sendNoCacheHeaders() {
if (! headers_sent()) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
diff --git a/tests/test_tools/simpletest/scorer.php b/tests/test_tools/simpletest/scorer.php
index 7cebae42..87a60e0e 100644
--- a/tests/test_tools/simpletest/scorer.php
+++ b/tests/test_tools/simpletest/scorer.php
@@ -379,7 +379,7 @@
* @access public
* @static
*/
- function inCli() {
+ static function inCli() {
return php_sapi_name() == 'cli';
}
}
diff --git a/tests/test_tools/simpletest/simple_test.php b/tests/test_tools/simpletest/simple_test.php
index 82d50ec0..ddc35b7f 100644
--- a/tests/test_tools/simpletest/simple_test.php
+++ b/tests/test_tools/simpletest/simple_test.php
@@ -267,7 +267,7 @@
* @access public
* @static
*/
- function getSize() {
+ static function getSize() {
return 1;
}
}
diff --git a/tests/test_tools/simpletest/simpletest.php b/tests/test_tools/simpletest/simpletest.php
index d2a56d26..fe4937b3 100644
--- a/tests/test_tools/simpletest/simpletest.php
+++ b/tests/test_tools/simpletest/simpletest.php
@@ -31,7 +31,7 @@
* @static
* @access public
*/
- function getVersion() {
+ static function getVersion() {
$content = file(dirname(__FILE__) . '/VERSION');
return trim($content[0]);
}
@@ -45,7 +45,7 @@
* @static
* @access public
*/
- function ignore($class) {
+ static function ignore($class) {
$registry = &SimpleTest::_getRegistry();
$registry['IgnoreList'][strtolower($class)] = true;
}
@@ -65,7 +65,7 @@
* @static
* @access public
*/
- function ignoreParentsIfIgnored($classes) {
+ static function ignoreParentsIfIgnored($classes) {
$registry = &SimpleTest::_getRegistry();
foreach ($classes as $class) {
if (SimpleTest::isIgnored($class)) {
@@ -88,7 +88,7 @@
* @access public
* @static
*/
- function isIgnored($class) {
+ static function isIgnored($class) {
$registry = &SimpleTest::_getRegistry();
return isset($registry['IgnoreList'][strtolower($class)]);
}
@@ -164,7 +164,7 @@
* @access public
* @static
*/
- function setCurrent($test) {
+ static function setCurrent($test) {
$registry = &SimpleTest::_getRegistry();
$registry['CurrentTestCase'] = $test;
}
@@ -175,7 +175,7 @@
* @access public
* @static
*/
- function &getCurrent() {
+ static function &getCurrent() {
$registry = &SimpleTest::_getRegistry();
return $registry['CurrentTestCase'];
}
@@ -186,7 +186,7 @@
* @access private
* @static
*/
- function &_getRegistry() {
+ static function &_getRegistry() {
static $registry = false;
if (! $registry) {
$registry = SimpleTest::_getDefaults();
@@ -200,7 +200,7 @@
* @access private
* @static
*/
- function _getDefaults() {
+ static function _getDefaults() {
return array(
'StubBaseClass' => 'SimpleStub',
'MockBaseClass' => 'SimpleMock',
@@ -219,21 +219,21 @@
/**
* @deprecated
*/
- function getVersion() {
+ static function getVersion() {
return Simpletest::getVersion();
}
/**
* @deprecated
*/
- function ignore($class) {
+ static function ignore($class) {
return Simpletest::ignore($class);
}
/**
* @deprecated
*/
- function isIgnored($class) {
+ static function isIgnored($class) {
return Simpletest::isIgnored($class);
}
diff --git a/tests/test_tools/simpletest/test_case.php b/tests/test_tools/simpletest/test_case.php
index ee64fb22..bc215640 100644
--- a/tests/test_tools/simpletest/test_case.php
+++ b/tests/test_tools/simpletest/test_case.php
@@ -378,7 +378,7 @@
* @access public
* @static
*/
- function getSize() {
+ static function getSize() {
return 1;
}
}
diff --git a/tests/test_tools/simpletest/url.php b/tests/test_tools/simpletest/url.php
index 1de276a2..dce7d455 100644
--- a/tests/test_tools/simpletest/url.php
+++ b/tests/test_tools/simpletest/url.php
@@ -35,7 +35,7 @@
protected $_y;
protected $_target;
protected $_raw = false;
-
+
/**
* Constructor. Parses URL into sections.
* @param string $url Incoming URL.
@@ -57,7 +57,7 @@
$this->_fragment = (strncmp($url, "#", 1) == 0 ? substr($url, 1) : false);
$this->_target = false;
}
-
+
/**
* Extracts the X, Y coordinate pair from an image map.
* @param string $url URL so far. The coordinates will be
@@ -72,7 +72,7 @@
}
return array(false, false);
}
-
+
/**
* Extracts the scheme part of an incoming URL.
* @param string $url URL so far. The scheme will be
@@ -87,7 +87,7 @@
}
return false;
}
-
+
/**
* Extracts the username and password from the
* incoming URL. The // prefix will be reattached
@@ -114,7 +114,7 @@
$url = $prefix . $url;
return array(false, false);
}
-
+
/**
* Extracts the host part of an incoming URL.
* Includes the port number part. Will extract
@@ -143,7 +143,7 @@
}
return false;
}
-
+
/**
* Extracts the path information from the incoming
* URL. Strips this path from the URL.
@@ -159,7 +159,7 @@
}
return '';
}
-
+
/**
* Strips off the request data.
* @param string $url URL so far. The request will be
@@ -174,7 +174,7 @@
}
return '';
}
-
+
/**
* Breaks the request down into an object.
* @param string $raw Raw request.
@@ -193,7 +193,7 @@
}
return $request;
}
-
+
/**
* Accessor for protocol part.
* @param string $default Value to use if not present.
@@ -203,7 +203,7 @@
function getScheme($default = false) {
return $this->_scheme ? $this->_scheme : $default;
}
-
+
/**
* Accessor for user name.
* @return string Username preceding host.
@@ -212,7 +212,7 @@
function getUsername() {
return $this->_username;
}
-
+
/**
* Accessor for password.
* @return string Password preceding host.
@@ -221,7 +221,7 @@
function getPassword() {
return $this->_password;
}
-
+
/**
* Accessor for hostname and port.
* @param string $default Value to use if not present.
@@ -231,7 +231,7 @@
function getHost($default = false) {
return $this->_host ? $this->_host : $default;
}
-
+
/**
* Accessor for top level domain.
* @return string Last part of host.
@@ -241,7 +241,7 @@
$path_parts = pathinfo($this->getHost());
return (isset($path_parts['extension']) ? $path_parts['extension'] : false);
}
-
+
/**
* Accessor for port number.
* @return integer TCP/IP port number.
@@ -249,8 +249,8 @@
*/
function getPort() {
return $this->_port;
- }
-
+ }
+
/**
* Accessor for path.
* @return string Full path including leading slash if implied.
@@ -262,7 +262,7 @@
}
return $this->_path;
}
-
+
/**
* Accessor for page if any. This may be a
* directory name if ambiguious.
@@ -275,7 +275,7 @@
}
return $matches[1];
}
-
+
/**
* Gets the path to the page.
* @return string Path less the page.
@@ -287,7 +287,7 @@
}
return $matches[1];
}
-
+
/**
* Accessor for fragment at end of URL after the "#".
* @return string Part after "#".
@@ -296,7 +296,7 @@
function getFragment() {
return $this->_fragment;
}
-
+
/**
* Sets image coordinates. Set to false to clear
* them.
@@ -312,7 +312,7 @@
$this->_x = (integer)$x;
$this->_y = (integer)$y;
}
-
+
/**
* Accessor for horizontal image coordinate.
* @return integer X value.
@@ -321,7 +321,7 @@
function getX() {
return $this->_x;
}
-
+
/**
* Accessor for vertical image coordinate.
* @return integer Y value.
@@ -330,7 +330,7 @@
function getY() {
return $this->_y;
}
-
+
/**
* Accessor for current request parameters
* in URL string form. Will return teh original request
@@ -350,7 +350,7 @@
}
return '';
}
-
+
/**
* Adds an additional parameter to the request.
* @param string $key Name of parameter.
@@ -361,7 +361,7 @@
$this->_raw = false;
$this->_request->add($key, $value);
}
-
+
/**
* Adds additional parameters to the request.
* @param hash/SimpleFormEncoding $parameters Additional
@@ -372,7 +372,7 @@
$this->_raw = false;
$this->_request->merge($parameters);
}
-
+
/**
* Clears down all parameters.
* @access public
@@ -381,7 +381,7 @@
$this->_raw = false;
$this->_request = new SimpleGetEncoding();
}
-
+
/**
* Gets the frame target if present. Although
* not strictly part of the URL specification it
@@ -392,7 +392,7 @@
function getTarget() {
return $this->_target;
}
-
+
/**
* Attaches a frame target.
* @param string $frame Name of frame.
@@ -402,7 +402,7 @@
$this->_raw = false;
$this->_target = $frame;
}
-
+
/**
* Renders the URL back into a string.
* @return string URL in canonical form.
@@ -425,7 +425,7 @@
$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
return "$scheme://$identity$host$path$encoded$fragment$coords";
}
-
+
/**
* Replaces unknown sections to turn a relative
* URL into an absolute one. The base URL can
@@ -456,7 +456,7 @@
$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords");
}
-
+
/**
* Replaces unknown sections of the path with base parts
* to return a complete absolute one.
@@ -476,7 +476,7 @@
}
return $base->getPath();
}
-
+
/**
* Simple test to see if a path part is relative.
* @param string $path Path to test.
@@ -486,7 +486,7 @@
function _isRelativePath($path) {
return (substr($path, 0, 1) != '/');
}
-
+
/**
* Extracts the username and password for use in rendering
* a URL.
@@ -499,7 +499,7 @@
}
return false;
}
-
+
/**
* Replaces . and .. sections of the path.
* @param string $path Unoptimised path.
@@ -510,7 +510,7 @@
$path = preg_replace('|/[^/]+/\.\./|', '/', $path);
return preg_replace('|/\./|', '/', $path);
}
-
+
/**
* A pipe seperated list of all TLDs that result in two part
* domain names.
@@ -518,7 +518,7 @@
* @access public
* @static
*/
- function getAllTopLevelDomains() {
+ static function getAllTopLevelDomains() {
return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum';
}
}