diff options
35 files changed, 233 insertions, 290 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php index 3b1680d..32bfa92 100644 --- a/Auth/OpenID.php +++ b/Auth/OpenID.php @@ -118,7 +118,7 @@ class Auth_OpenID { * * @access private */ - function isFailure($thing) + static function isFailure($thing) { return is_a($thing, 'Auth_OpenID_FailureResponse'); } @@ -142,7 +142,7 @@ class Auth_OpenID { * * @access private */ - function getQuery($query_str=null) + static function getQuery($query_str=null) { $data = array(); @@ -178,7 +178,7 @@ class Auth_OpenID { return $data; } - function params_from_string($str) + static function params_from_string($str) { $chunks = explode("&", $str); @@ -204,7 +204,7 @@ class Auth_OpenID { * * @access private */ - function ensureDir($dir_name) + static function ensureDir($dir_name) { if (is_dir($dir_name) || @mkdir($dir_name)) { return true; @@ -226,7 +226,7 @@ class Auth_OpenID { * * @access private */ - function addPrefix($values, $prefix) + static function addPrefix($values, $prefix) { $new_values = array(); foreach ($values as $s) { @@ -242,7 +242,7 @@ class Auth_OpenID { * * @access private */ - function arrayGet($arr, $key, $fallback = null) + static function arrayGet($arr, $key, $fallback = null) { if (is_array($arr)) { if (array_key_exists($key, $arr)) { @@ -262,7 +262,7 @@ class Auth_OpenID { /** * Replacement for PHP's broken parse_str. */ - function parse_str($query) + static function parse_str($query) { if ($query === null) { return null; @@ -296,7 +296,7 @@ class Auth_OpenID { * pairs from $data into a URL query string * (e.g. "username=bob&id=56"). */ - function httpBuildQuery($data) + static function httpBuildQuery($data) { $pairs = array(); foreach ($data as $key => $value) { @@ -324,7 +324,7 @@ class Auth_OpenID { * @return string $url The original URL with the new parameters added. * */ - function appendArgs($url, $args) + static function appendArgs($url, $args) { if (count($args) == 0) { return $url; @@ -368,7 +368,7 @@ class Auth_OpenID { * @return string $url The URL resulting from assembling the * specified components. */ - function urlunparse($scheme, $host, $port = null, $path = '/', + static function urlunparse($scheme, $host, $port = null, $path = '/', $query = '', $fragment = '') { @@ -413,7 +413,7 @@ class Auth_OpenID { * @return mixed $new_url The URL after normalization, or null if * $url was malformed. */ - function normalizeUrl($url) + static function normalizeUrl($url) { @$parsed = parse_url($url); @@ -444,7 +444,7 @@ class Auth_OpenID { * * @access private */ - function intval($value) + static function intval($value) { $re = "/^\\d+$/"; @@ -462,7 +462,7 @@ class Auth_OpenID { * @param string $str The string of bytes to count. * @return int The number of bytes in $str. */ - function bytes($str) + static function bytes($str) { return strlen(bin2hex($str)) / 2; } @@ -471,7 +471,7 @@ class Auth_OpenID { * Get the bytes in a string independently of multibyte support * conditions. */ - function toBytes($str) + static function toBytes($str) { $hex = bin2hex($str); @@ -487,7 +487,7 @@ class Auth_OpenID { return $b; } - function urldefrag($url) + static function urldefrag($url) { $parts = explode("#", $url, 2); @@ -498,7 +498,7 @@ class Auth_OpenID { } } - function filter($callback, &$sequence) + static function filter($callback, &$sequence) { $result = array(); @@ -511,7 +511,7 @@ class Auth_OpenID { return $result; } - function update(&$dest, &$src) + static function update(&$dest, &$src) { foreach ($src as $k => $v) { $dest[$k] = $v; @@ -525,14 +525,14 @@ class Auth_OpenID { * * @param string $format_string The sprintf format for the message */ - function log($format_string) + static function log($format_string) { $args = func_get_args(); $message = call_user_func_array('sprintf', $args); error_log($message); } - function autoSubmitHTML($form, $title="OpenId transaction in progress") + static function autoSubmitHTML($form, $title="OpenId transaction in progress") { return("<html>". "<head><title>". diff --git a/Auth/OpenID/AX.php b/Auth/OpenID/AX.php index 516adec..62cdee4 100644 --- a/Auth/OpenID/AX.php +++ b/Auth/OpenID/AX.php @@ -38,7 +38,7 @@ class Auth_OpenID_AX { * @return bool true if $thing is an Auth_OpenID_AX_Error; false * if not. */ - function isError($thing) + static function isError($thing) { return is_a($thing, 'Auth_OpenID_AX_Error'); } @@ -191,7 +191,7 @@ class Auth_OpenID_AX_AttrInfo { * Construct an attribute information object. For parameter * details, see the constructor. */ - function make($type_uri, $count=1, $required=false, + static function make($type_uri, $count=1, $required=false, $alias=null) { if ($alias !== null) { @@ -235,7 +235,7 @@ class Auth_OpenID_AX_AttrInfo { * return null If an alias is present in the list of aliases but * is not present in the namespace map. */ -function Auth_OpenID_AX_toTypeURIs(&$namespace_map, $alias_list_s) +function Auth_OpenID_AX_toTypeURIs($namespace_map, $alias_list_s) { $uris = array(); @@ -386,7 +386,7 @@ class Auth_OpenID_AX_FetchRequest extends Auth_OpenID_AX_Message { * Auth_OpenID_AX_FetchRequest extracted from the request message if * successful */ - function &fromOpenIDRequest($request) + static function fromOpenIDRequest($request) { $m = $request->message; $obj = new Auth_OpenID_AX_FetchRequest(); @@ -484,7 +484,7 @@ class Auth_OpenID_AX_FetchRequest extends Auth_OpenID_AX_Message { Auth_OpenID::arrayGet($ax_args, 'required')); foreach ($required as $type_uri) { - $attrib =& $this->requested_attributes[$type_uri]; + $attrib = $this->requested_attributes[$type_uri]; $attrib->required = true; } @@ -587,7 +587,7 @@ class Auth_OpenID_AX_KeyValueMessage extends Auth_OpenID_AX_Message { * * @access private */ - function _getExtensionKVArgs(&$aliases) + function _getExtensionKVArgs($aliases) { if ($aliases === null) { $aliases = new Auth_OpenID_NamespaceMap(); @@ -922,7 +922,7 @@ class Auth_OpenID_AX_FetchResponse extends Auth_OpenID_AX_KeyValueMessage { * @return $response A FetchResponse containing the data from the * OpenID message */ - function fromSuccessResponse($success_response, $signed=true) + static function fromSuccessResponse($success_response, $signed=true) { $obj = new Auth_OpenID_AX_FetchResponse(); if ($signed) { @@ -980,7 +980,7 @@ class Auth_OpenID_AX_StoreResponse extends Auth_OpenID_AX_Message { * Returns Auth_OpenID_AX_Error on error or an * Auth_OpenID_AX_StoreResponse object on success. */ - function &make($succeeded=true, $error_message=null) + function make($succeeded=true, $error_message=null) { if (($succeeded) && ($error_message !== null)) { return new Auth_OpenID_AX_Error('An error message may only be '. diff --git a/Auth/OpenID/Association.php b/Auth/OpenID/Association.php index 07aaee1..d1ac1ed 100644 --- a/Auth/OpenID/Association.php +++ b/Auth/OpenID/Association.php @@ -94,7 +94,7 @@ class Auth_OpenID_Association { * @return association An {@link Auth_OpenID_Association} * instance. */ - function fromExpiresIn($expires_in, $handle, $secret, $assoc_type) + static function fromExpiresIn($expires_in, $handle, $secret, $assoc_type) { $issued = time(); $lifetime = $expires_in; @@ -206,7 +206,7 @@ class Auth_OpenID_Association { * @param string $assoc_s Association as serialized by serialize() * @return Auth_OpenID_Association $result instance of this class */ - function deserialize($class_name, $assoc_s) + static function deserialize($class_name, $assoc_s) { $pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true); $keys = array(); @@ -327,7 +327,7 @@ class Auth_OpenID_Association { * * @access private */ - function _makePairs(&$message) + function _makePairs($message) { $signed = $message->getArg(Auth_OpenID_OPENID_NS, 'signed'); if (!$signed || Auth_OpenID::isFailure($signed)) { @@ -352,7 +352,7 @@ class Auth_OpenID_Association { * * @access private */ - function getMessageSignature(&$message) + function getMessageSignature($message) { $pairs = $this->_makePairs($message); return base64_encode($this->sign($pairs)); @@ -364,7 +364,7 @@ class Auth_OpenID_Association { * * @access private */ - function checkMessageSignature(&$message) + function checkMessageSignature($message) { $sig = $message->getArg(Auth_OpenID_OPENID_NS, 'sig'); @@ -469,18 +469,16 @@ function Auth_OpenID_getOnlyEncryptedOrder() return $result; } -function &Auth_OpenID_getDefaultNegotiator() +function Auth_OpenID_getDefaultNegotiator() { - $x = new Auth_OpenID_SessionNegotiator( + return new Auth_OpenID_SessionNegotiator( Auth_OpenID_getDefaultAssociationOrder()); - return $x; } -function &Auth_OpenID_getEncryptedNegotiator() +function Auth_OpenID_getEncryptedNegotiator() { - $x = new Auth_OpenID_SessionNegotiator( + return new Auth_OpenID_SessionNegotiator( Auth_OpenID_getOnlyEncryptedOrder()); - return $x; } /** diff --git a/Auth/OpenID/BigMath.php b/Auth/OpenID/BigMath.php index f787482..58b46bf 100644 --- a/Auth/OpenID/BigMath.php +++ b/Auth/OpenID/BigMath.php @@ -351,8 +351,7 @@ function Auth_OpenID_math_extensions() 'class' => 'Auth_OpenID_GmpMathWrapper'); } - $result[] = array( - 'modules' => array('bcmath', 'php_bcmath'), + $result[] = array('modules' => array('bcmath', 'php_bcmath'), 'extension' => 'bcmath', 'class' => 'Auth_OpenID_BcMathWrapper'); @@ -367,26 +366,7 @@ function Auth_OpenID_detectMathLibrary($exts) $loaded = false; foreach ($exts as $extension) { - // See if the extension specified is already loaded. - if ($extension['extension'] && - extension_loaded($extension['extension'])) { - $loaded = true; - } - - // Try to load dynamic modules. - if (!$loaded) { - foreach ($extension['modules'] as $module) { - if (@dl($module . "." . PHP_SHLIB_SUFFIX)) { - $loaded = true; - break; - } - } - } - - // If the load succeeded, supply an instance of - // Auth_OpenID_MathWrapper which wraps the specified - // module's functionality. - if ($loaded) { + if (extension_loaded($extension['extension'])) { return $extension; } } @@ -405,7 +385,7 @@ function Auth_OpenID_detectMathLibrary($exts) * instance of a wrapper for that extension module. If no extension * module is found, an instance of {@link Auth_OpenID_MathWrapper} is * returned, which wraps the native PHP integer implementation. The - * proper calling convention for this method is $lib =& + * proper calling convention for this method is $lib = * Auth_OpenID_getMathLib(). * * This function checks for the existence of specific long number @@ -416,7 +396,7 @@ function Auth_OpenID_detectMathLibrary($exts) * * @package OpenID */ -function &Auth_OpenID_getMathLib() +function Auth_OpenID_getMathLib() { // The instance of Auth_OpenID_MathWrapper that we choose to // supply will be stored here, so that subseqent calls to this diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index 987ba90..92466cf 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -258,19 +258,19 @@ class Auth_OpenID_Consumer { * when creating the internal consumer object. This is used for * testing. */ - function Auth_OpenID_Consumer(&$store, $session = null, + function Auth_OpenID_Consumer($store, $session = null, $consumer_cls = null) { if ($session === null) { $session = new Auth_Yadis_PHPSession(); } - $this->session =& $session; + $this->session = $session; if ($consumer_cls !== null) { - $this->consumer =& new $consumer_cls($store); + $this->consumer = new $consumer_cls($store); } else { - $this->consumer =& new Auth_OpenID_GenericConsumer($store); + $this->consumer = new Auth_OpenID_GenericConsumer($store); } $this->_token_key = $this->session_key_prefix . $this->_token_suffix; @@ -281,7 +281,7 @@ class Auth_OpenID_Consumer { * * @access private */ - function getDiscoveryObject(&$session, $openid_url, + function getDiscoveryObject($session, $openid_url, $session_key_prefix) { return new Auth_Yadis_Discovery($session, $openid_url, @@ -339,7 +339,7 @@ class Auth_OpenID_Consumer { $this->consumer->fetcher); // Reset the 'stale' attribute of the manager. - $m =& $disco->getManager(); + $m = $disco->getManager(); if ($m) { $m->stale = false; $disco->session->set($disco->session_key, @@ -370,7 +370,7 @@ class Auth_OpenID_Consumer { * @return Auth_OpenID_AuthRequest $auth_request An OpenID * authentication request object. */ - function &beginWithoutDiscovery($endpoint, $anonymous=false) + function beginWithoutDiscovery($endpoint, $anonymous=false) { $loader = new Auth_OpenID_ServiceEndpointLoader(); $auth_req = $this->consumer->begin($endpoint); @@ -467,7 +467,7 @@ class Auth_OpenID_DiffieHellmanSHA1ConsumerSession { function getRequest() { - $math =& Auth_OpenID_getMathLib(); + $math = Auth_OpenID_getMathLib(); $cpub = $math->longToBase64($this->dh->public); @@ -496,7 +496,7 @@ class Auth_OpenID_DiffieHellmanSHA1ConsumerSession { return null; } - $math =& Auth_OpenID_getMathLib(); + $math = Auth_OpenID_getMathLib(); $spub = $math->base64ToLong($response->getArg(Auth_OpenID_OPENID_NS, 'dh_server_public')); @@ -611,10 +611,10 @@ class Auth_OpenID_GenericConsumer { * in the module description. The default value is False, which * disables immediate mode. */ - function Auth_OpenID_GenericConsumer(&$store) + function Auth_OpenID_GenericConsumer($store) { - $this->store =& $store; - $this->negotiator =& Auth_OpenID_getDefaultNegotiator(); + $this->store = $store; + $this->negotiator = Auth_OpenID_getDefaultNegotiator(); $this->_use_assocs = (is_null($this->store) ? false : true); $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); @@ -665,14 +665,14 @@ class Auth_OpenID_GenericConsumer { $method = Auth_OpenID::arrayGet($mode_methods, $mode, '_completeInvalid'); - return call_user_func_array(array(&$this, $method), + return call_user_func_array(array($this, $method), array($message, $endpoint, $return_to)); } /** * @access private */ - function _completeInvalid($message, &$endpoint, $unused) + function _completeInvalid($message, $endpoint, $unused) { $mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode', '<No mode set>'); @@ -684,7 +684,7 @@ class Auth_OpenID_GenericConsumer { /** * @access private */ - function _complete_cancel($message, &$endpoint, $unused) + function _complete_cancel($message, $endpoint, $unused) { return new Auth_OpenID_CancelResponse($endpoint); } @@ -692,7 +692,7 @@ class Auth_OpenID_GenericConsumer { /** * @access private */ - function _complete_error($message, &$endpoint, $unused) + function _complete_error($message, $endpoint, $unused) { $error = $message->getArg(Auth_OpenID_OPENID_NS, 'error'); $contact = $message->getArg(Auth_OpenID_OPENID_NS, 'contact'); @@ -705,7 +705,7 @@ class Auth_OpenID_GenericConsumer { /** * @access private */ - function _complete_setup_needed($message, &$endpoint, $unused) + function _complete_setup_needed($message, $endpoint, $unused) { if (!$message->isOpenID2()) { return $this->_completeInvalid($message, $endpoint); @@ -719,7 +719,7 @@ class Auth_OpenID_GenericConsumer { /** * @access private */ - function _complete_id_res($message, &$endpoint, $return_to) + function _complete_id_res($message, $endpoint, $return_to) { $user_setup_url = $message->getArg(Auth_OpenID_OPENID1_NS, 'user_setup_url'); @@ -1197,7 +1197,7 @@ class Auth_OpenID_GenericConsumer { * @access private */ function _verifyDiscoveryServices($claimed_id, - &$services, &$to_match_endpoints) + $services, $to_match_endpoints) { // Search the services resulting from discovery to find one // that matches the information from the assertion @@ -1397,7 +1397,7 @@ class Auth_OpenID_GenericConsumer { * * @access private */ - function _httpResponseToMessage($response, $server_url) + static function _httpResponseToMessage($response, $server_url) { // Should this function be named Message.fromHTTPResponse instead? $response_message = Auth_OpenID_Message::fromKVForm($response->body); @@ -1461,7 +1461,7 @@ class Auth_OpenID_GenericConsumer { * * @access private */ - function _extractSupportedAssociationType(&$server_error, &$endpoint, + function _extractSupportedAssociationType($server_error, $endpoint, $assoc_type) { // Any error message whose code is not 'unsupported-type' @@ -1566,7 +1566,7 @@ class Auth_OpenID_GenericConsumer { /** * @access private */ - function _extractAssociation(&$assoc_response, &$assoc_session) + function _extractAssociation($assoc_response, $assoc_session) { // Extract the common fields from the response, raising an // exception if they are not found @@ -1748,10 +1748,10 @@ class Auth_OpenID_AuthRequest { * class. Instances of this class are created by the library when * needed. */ - function Auth_OpenID_AuthRequest(&$endpoint, $assoc) + function Auth_OpenID_AuthRequest($endpoint, $assoc) { $this->assoc = $assoc; - $this->endpoint =& $endpoint; + $this->endpoint = $endpoint; $this->return_to_args = array(); $this->message = new Auth_OpenID_Message( $endpoint->preferredNamespace()); @@ -1764,7 +1764,7 @@ class Auth_OpenID_AuthRequest { * $extension_request: An object that implements the extension * request interface for adding arguments to an OpenID message. */ - function addExtension(&$extension_request) + function addExtension($extension_request) { $extension_request->toMessage($this->message); } @@ -2167,7 +2167,7 @@ class Auth_OpenID_ServerErrorContainer { /** * @access private */ - function fromMessage($message) + static function fromMessage($message) { $error_text = $message->getArg( Auth_OpenID_OPENID_NS, 'error', '<no error message supplied>'); diff --git a/Auth/OpenID/CryptUtil.php b/Auth/OpenID/CryptUtil.php index 28433b7..a926267 100644 --- a/Auth/OpenID/CryptUtil.php +++ b/Auth/OpenID/CryptUtil.php @@ -37,7 +37,7 @@ class Auth_OpenID_CryptUtil { * @param int $num_bytes The length of the return value * @return string $bytes random bytes */ - function getBytes($num_bytes) + static function getBytes($num_bytes) { static $f = null; $bytes = ''; @@ -77,7 +77,7 @@ class Auth_OpenID_CryptUtil { * @return string $result A string of randomly-chosen characters * from $chrs */ - function randomString($length, $population = null) + static function randomString($length, $population = null) { if ($population === null) { return Auth_OpenID_CryptUtil::getBytes($length); diff --git a/Auth/OpenID/DiffieHellman.php b/Auth/OpenID/DiffieHellman.php index f1006c1..3e25b7d 100644 --- a/Auth/OpenID/DiffieHellman.php +++ b/Auth/OpenID/DiffieHellman.php @@ -51,9 +51,9 @@ class Auth_OpenID_DiffieHellman { $private = null, $lib = null) { if ($lib === null) { - $this->lib =& Auth_OpenID_getMathLib(); + $this->lib = Auth_OpenID_getMathLib(); } else { - $this->lib =& $lib; + $this->lib = $lib; } if ($mod === null) { diff --git a/Auth/OpenID/Discover.php b/Auth/OpenID/Discover.php index efd4a74..7b0c640 100644 --- a/Auth/OpenID/Discover.php +++ b/Auth/OpenID/Discover.php @@ -150,7 +150,7 @@ class Auth_OpenID_ServiceEndpoint { return in_array(Auth_OpenID_TYPE_2_0_IDP, $this->type_uris); } - function fromOPEndpointURL($op_endpoint_url) + static function fromOPEndpointURL($op_endpoint_url) { // Construct an OP-Identifier OpenIDServiceEndpoint object for // a given OP Endpoint URL @@ -222,9 +222,9 @@ class Auth_OpenID_ServiceEndpoint { * @return array of Auth_OpenID_ServiceEndpoint or null if the * document cannot be parsed. */ - function fromXRDS($uri, $xrds_text) + static function fromXRDS($uri, $xrds_text) { - $xrds =& Auth_Yadis_XRDS::parseXRDS($xrds_text); + $xrds = Auth_Yadis_XRDS::parseXRDS($xrds_text); if ($xrds) { $yadis_services = @@ -242,7 +242,7 @@ class Auth_OpenID_ServiceEndpoint { * @return array of Auth_OpenID_ServiceEndpoint or null if * endpoints cannot be created. */ - function fromDiscoveryResult($discoveryResult) + static function fromDiscoveryResult($discoveryResult) { if ($discoveryResult->isXRDS()) { return Auth_OpenID_ServiceEndpoint::fromXRDS( @@ -255,7 +255,7 @@ class Auth_OpenID_ServiceEndpoint { } } - function fromHTML($uri, $html) + static function fromHTML($uri, $html) { $discovery_types = array( array(Auth_OpenID_TYPE_2_0, @@ -318,7 +318,7 @@ function Auth_OpenID_findOPLocalIdentifier($service, $type_uris) $service->parser->registerNamespace('xrd', Auth_Yadis_XMLNS_XRD_2_0); - $parser =& $service->parser; + $parser = $service->parser; $permitted_tags = array(); @@ -350,7 +350,7 @@ function Auth_OpenID_findOPLocalIdentifier($service, $type_uris) return $local_id; } -function filter_MatchesAnyOpenIDType(&$service) +function filter_MatchesAnyOpenIDType($service) { $uris = $service->getTypes(); @@ -473,7 +473,7 @@ function Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services) return $s; } -function Auth_OpenID_discoverWithYadis($uri, &$fetcher, +function Auth_OpenID_discoverWithYadis($uri, $fetcher, $endpoint_filter='Auth_OpenID_getOPOrUserServices', $discover_function=null) { @@ -523,13 +523,13 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher, return array($yadis_url, $openid_services); } -function Auth_OpenID_discoverURI($uri, &$fetcher) +function Auth_OpenID_discoverURI($uri, $fetcher) { $uri = Auth_OpenID::normalizeUrl($uri); return Auth_OpenID_discoverWithYadis($uri, $fetcher); } -function Auth_OpenID_discoverWithoutYadis($uri, &$fetcher) +function Auth_OpenID_discoverWithoutYadis($uri, $fetcher) { $http_resp = @$fetcher->get($uri); @@ -548,7 +548,7 @@ function Auth_OpenID_discoverWithoutYadis($uri, &$fetcher) return array($identity_url, $openid_services); } -function Auth_OpenID_discoverXRI($iname, &$fetcher) +function Auth_OpenID_discoverXRI($iname, $fetcher) { $resolver = new Auth_Yadis_ProxyResolver($fetcher); list($canonicalID, $yadis_services) = @@ -571,7 +571,7 @@ function Auth_OpenID_discoverXRI($iname, &$fetcher) return array($iname, $openid_services); } -function Auth_OpenID_discover($uri, &$fetcher) +function Auth_OpenID_discover($uri, $fetcher) { // If the fetcher (i.e., PHP) doesn't support SSL, we can't do // discovery on an HTTPS URL. diff --git a/Auth/OpenID/Extension.php b/Auth/OpenID/Extension.php index 4c869f8..c4e38c0 100644 --- a/Auth/OpenID/Extension.php +++ b/Auth/OpenID/Extension.php @@ -39,7 +39,7 @@ class Auth_OpenID_Extension { * * Returns the message with the extension arguments added. */ - function toMessage(&$message) + function toMessage($message) { $implicit = $message->isOpenID1(); $added = $message->namespaces->addAlias($this->ns_uri, diff --git a/Auth/OpenID/FileStore.php b/Auth/OpenID/FileStore.php index 187234e..074421a 100644 --- a/Auth/OpenID/FileStore.php +++ b/Auth/OpenID/FileStore.php @@ -519,7 +519,7 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore { /** * @access private */ - function _mkdtemp($dir) + static function _mkdtemp($dir) { foreach (range(0, 4) as $i) { $name = $dir . strval(DIRECTORY_SEPARATOR) . strval(getmypid()) . diff --git a/Auth/OpenID/KVForm.php b/Auth/OpenID/KVForm.php index 18ae7ac..dd02661 100644 --- a/Auth/OpenID/KVForm.php +++ b/Auth/OpenID/KVForm.php @@ -26,7 +26,7 @@ class Auth_OpenID_KVForm { * @static * @access private */ - function toArray($kvs, $strict=false) + static function toArray($kvs, $strict=false) { $lines = explode("\n", $kvs); @@ -78,7 +78,7 @@ class Auth_OpenID_KVForm { * @static * @access private */ - function fromArray($values) + static function fromArray($values) { if ($values === null) { return null; diff --git a/Auth/OpenID/Message.php b/Auth/OpenID/Message.php index d53e93d..9aa1fa4 100644 --- a/Auth/OpenID/Message.php +++ b/Auth/OpenID/Message.php @@ -143,7 +143,7 @@ class Auth_OpenID_Mapping { * Returns true if $thing is an Auth_OpenID_Mapping object; false * if not. */ - function isA($thing) + static function isA($thing) { return (is_object($thing) && strtolower(get_class($thing)) == 'auth_openid_mapping'); @@ -442,7 +442,7 @@ class Auth_OpenID_Message { return $this->getOpenIDNamespace() == Auth_OpenID_OPENID2_NS; } - function fromPostArgs($args) + static function fromPostArgs($args) { // Construct a Message containing a set of POST arguments $obj = new Auth_OpenID_Message(); @@ -477,7 +477,7 @@ class Auth_OpenID_Message { } } - function fromOpenIDArgs($openid_args) + static function fromOpenIDArgs($openid_args) { // Takes an array. @@ -594,7 +594,7 @@ class Auth_OpenID_Message { return $this->_openid_ns_uri; } - function fromKVForm($kvform_string) + static function fromKVForm($kvform_string) { // Create a Message from a KVForm string return Auth_OpenID_Message::fromOpenIDArgs( diff --git a/Auth/OpenID/PAPE.php b/Auth/OpenID/PAPE.php index 3876b28..f08ca8b 100644 --- a/Auth/OpenID/PAPE.php +++ b/Auth/OpenID/PAPE.php @@ -21,7 +21,7 @@ define('PAPE_AUTH_PHISHING_RESISTANT', 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant'); define('PAPE_TIME_VALIDATOR', - '^[0-9]{4,4}-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z$'); + '/^[0-9]{4,4}-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z$/'); /** * A Provider Authentication Policy request, sent from a relying party * to a provider @@ -82,7 +82,7 @@ class Auth_OpenID_PAPE_Request extends Auth_OpenID_Extension { * Instantiate a Request object from the arguments in a checkid_* * OpenID message */ - function fromOpenIDRequest($request) + static function fromOpenIDRequest($request) { $obj = new Auth_OpenID_PAPE_Request(); $args = $request->message->getArgs(Auth_OpenID_PAPE_NS_URI); @@ -201,7 +201,7 @@ class Auth_OpenID_PAPE_Response extends Auth_OpenID_Extension { * @returns: A provider authentication policy response from the * data that was supplied with the id_res response. */ - function fromSuccessResponse($success_response) + static function fromSuccessResponse($success_response) { $obj = new Auth_OpenID_PAPE_Response(); @@ -262,7 +262,7 @@ class Auth_OpenID_PAPE_Response extends Auth_OpenID_Extension { $auth_time = Auth_OpenID::arrayGet($args, 'auth_time'); if ($auth_time !== null) { - if (ereg(PAPE_TIME_VALIDATOR, $auth_time)) { + if (preg_match(PAPE_TIME_VALIDATOR, $auth_time)) { $this->auth_time = $auth_time; } else if ($strict) { return false; @@ -287,7 +287,7 @@ class Auth_OpenID_PAPE_Response extends Auth_OpenID_Extension { } if ($this->auth_time !== null) { - if (!ereg(PAPE_TIME_VALIDATOR, $this->auth_time)) { + if (!preg_match(PAPE_TIME_VALIDATOR, $this->auth_time)) { return false; } diff --git a/Auth/OpenID/SReg.php b/Auth/OpenID/SReg.php index f8cccfd..5ece707 100644 --- a/Auth/OpenID/SReg.php +++ b/Auth/OpenID/SReg.php @@ -94,7 +94,7 @@ Auth_OpenID_registerNamespaceAlias(Auth_OpenID_SREG_NS_URI_1_1, 'sreg'); * $endpoint: The endpoint object as returned by OpenID discovery. * returns whether an sreg type was advertised by the endpoint */ -function Auth_OpenID_supportsSReg(&$endpoint) +function Auth_OpenID_supportsSReg($endpoint) { return ($endpoint->usesExtension(Auth_OpenID_SREG_NS_URI_1_1) || $endpoint->usesExtension(Auth_OpenID_SREG_NS_URI_1_0)); @@ -122,7 +122,7 @@ class Auth_OpenID_SRegBase extends Auth_OpenID_Extension { * * @access private */ - function _getSRegNS(&$message) + static function _getSRegNS($message) { $alias = null; $found_ns_uri = null; @@ -173,7 +173,7 @@ class Auth_OpenID_SRegRequest extends Auth_OpenID_SRegBase { /** * Initialize an empty simple registration request. */ - function build($required=null, $optional=null, + static function build($required=null, $optional=null, $policy_url=null, $sreg_ns_uri=Auth_OpenID_SREG_NS_URI, $cls='Auth_OpenID_SRegRequest') @@ -213,7 +213,7 @@ class Auth_OpenID_SRegRequest extends Auth_OpenID_SRegBase { * * Returns the newly created simple registration request */ - function fromOpenIDRequest($request, $cls='Auth_OpenID_SRegRequest') + static function fromOpenIDRequest($request, $cls='Auth_OpenID_SRegRequest') { $obj = call_user_func_array(array($cls, 'build'), @@ -442,7 +442,7 @@ class Auth_OpenID_SRegResponse extends Auth_OpenID_SRegBase { * string (unicode) value. For instance, the nickname should be * stored under the key 'nickname'. */ - function extractResponse($request, $data) + static function extractResponse($request, $data) { $obj = new Auth_OpenID_SRegResponse(); $obj->ns_uri = $request->ns_uri; @@ -471,7 +471,7 @@ class Auth_OpenID_SRegResponse extends Auth_OpenID_SRegBase { * Returns a simple registration response containing the data that * was supplied with the C{id_res} response. */ - function fromSuccessResponse(&$success_response, $signed_only=true) + static function fromSuccessResponse($success_response, $signed_only=true) { global $Auth_OpenID_sreg_data_fields; diff --git a/Auth/OpenID/Server.php b/Auth/OpenID/Server.php index 1a2f2e7..b642f91 100644 --- a/Auth/OpenID/Server.php +++ b/Auth/OpenID/Server.php @@ -365,7 +365,7 @@ class Auth_OpenID_CheckAuthRequest extends Auth_OpenID_Request { $this->message = null; } - function fromMessage($message, $server=null) + static function fromMessage($message, $server=null) { $required_keys = array('assoc_handle', 'sig', 'signed'); @@ -396,7 +396,7 @@ class Auth_OpenID_CheckAuthRequest extends Auth_OpenID_Request { return $result; } - function answer(&$signatory) + function answer($signatory) { $is_valid = $signatory->verify($this->assoc_handle, $this->signed); @@ -436,7 +436,7 @@ class Auth_OpenID_PlainTextServerSession { var $needs_math = false; var $allowed_assoc_types = array('HMAC-SHA1', 'HMAC-SHA256'); - function fromMessage($unused_request) + static function fromMessage($unused_request) { return new Auth_OpenID_PlainTextServerSession(); } @@ -469,7 +469,7 @@ class Auth_OpenID_DiffieHellmanSHA1ServerSession { $this->consumer_pubkey = $consumer_pubkey; } - function getDH($message) + static function getDH($message) { $dh_modulus = $message->getArg(Auth_OpenID_OPENID_NS, 'dh_modulus'); $dh_gen = $message->getArg(Auth_OpenID_OPENID_NS, 'dh_gen'); @@ -489,7 +489,7 @@ class Auth_OpenID_DiffieHellmanSHA1ServerSession { $missing); } - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); if ($dh_modulus || $dh_gen) { $dh_modulus = $lib->base64ToLong($dh_modulus); @@ -523,7 +523,7 @@ class Auth_OpenID_DiffieHellmanSHA1ServerSession { return array($dh, $consumer_pubkey); } - function fromMessage($message) + static function fromMessage($message) { $result = Auth_OpenID_DiffieHellmanSHA1ServerSession::getDH($message); @@ -538,7 +538,7 @@ class Auth_OpenID_DiffieHellmanSHA1ServerSession { function answer($secret) { - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $mac_key = $this->dh->xorSecret($this->consumer_pubkey, $secret, $this->hash_func); return array( @@ -560,7 +560,7 @@ class Auth_OpenID_DiffieHellmanSHA256ServerSession var $hash_func = 'Auth_OpenID_SHA256'; var $allowed_assoc_types = array('HMAC-SHA256'); - function fromMessage($message) + static function fromMessage($message) { $result = Auth_OpenID_DiffieHellmanSHA1ServerSession::getDH($message); @@ -582,7 +582,7 @@ class Auth_OpenID_DiffieHellmanSHA256ServerSession class Auth_OpenID_AssociateRequest extends Auth_OpenID_Request { var $mode = "associate"; - function getSessionClasses() + static function getSessionClasses() { return array( 'no-encryption' => 'Auth_OpenID_PlainTextServerSession', @@ -590,14 +590,14 @@ class Auth_OpenID_AssociateRequest extends Auth_OpenID_Request { 'DH-SHA256' => 'Auth_OpenID_DiffieHellmanSHA256ServerSession'); } - function Auth_OpenID_AssociateRequest(&$session, $assoc_type) + function Auth_OpenID_AssociateRequest($session, $assoc_type) { - $this->session =& $session; + $this->session = $session; $this->namespace = Auth_OpenID_OPENID2_NS; $this->assoc_type = $assoc_type; } - function fromMessage($message, $server=null) + static function fromMessage($message, $server=null) { if ($message->isOpenID1()) { $session_type = $message->getArg(Auth_OpenID_OPENID_NS, @@ -696,7 +696,7 @@ class Auth_OpenID_AssociateRequest extends Auth_OpenID_Request { 'session_type', $preferred_session_type); } - + $response->code = AUTH_OPENID_HTTP_ERROR; return $response; } } @@ -734,7 +734,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { */ var $namespace; - function make(&$message, $identity, $return_to, $trust_root = null, + static function make($message, $identity, $return_to, $trust_root = null, $immediate = false, $assoc_handle = null, $server = null) { if ($server === null) { @@ -752,7 +752,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { $assoc_handle, $server); $r->namespace = $message->getOpenIDNamespace(); - $r->message =& $message; + $r->message = $message; if (!$r->trustRootValid()) { return new Auth_OpenID_UntrustedReturnURL($message, @@ -778,7 +778,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { } $this->return_to = $return_to; $this->trust_root = $trust_root; - $this->server =& $server; + $this->server = $server; if ($immediate) { $this->immediate = true; @@ -821,7 +821,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { array($this->trust_root, $this->return_to)); } - function fromMessage(&$message, $server) + static function fromMessage($message, $server) { $mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode'); $immediate = null; @@ -1097,7 +1097,7 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { in OpenID 1.x immediate mode.'); } - $setup_request =& new Auth_OpenID_CheckIDRequest( + $setup_request = new Auth_OpenID_CheckIDRequest( $this->identity, $this->return_to, $this->trust_root, @@ -1183,9 +1183,9 @@ class Auth_OpenID_CheckIDRequest extends Auth_OpenID_Request { */ class Auth_OpenID_ServerResponse { - function Auth_OpenID_ServerResponse(&$request) + function Auth_OpenID_ServerResponse($request) { - $this->request =& $request; + $this->request = $request; $this->fields = new Auth_OpenID_Message($this->request->namespace); } @@ -1310,10 +1310,10 @@ class Auth_OpenID_Signatory { /** * Create a new signatory using a given store. */ - function Auth_OpenID_Signatory(&$store) + function Auth_OpenID_Signatory($store) { // assert store is not None - $this->store =& $store; + $this->store = $store; } /** @@ -1447,7 +1447,7 @@ class Auth_OpenID_Encoder { * Encode an {@link Auth_OpenID_ServerResponse} and return an * {@link Auth_OpenID_WebResponse}. */ - function encode(&$response) + function encode($response) { $cls = $this->responseFactory; @@ -1467,6 +1467,10 @@ class Auth_OpenID_Encoder { } else { return new Auth_OpenID_EncodingError($response); } + /* Allow the response to carry a custom error code (ex: for Association errors) */ + if($response->code) { + $wr->code = $response->code; + } return $wr; } } @@ -1478,16 +1482,16 @@ class Auth_OpenID_Encoder { */ class Auth_OpenID_SigningEncoder extends Auth_OpenID_Encoder { - function Auth_OpenID_SigningEncoder(&$signatory) + function Auth_OpenID_SigningEncoder($signatory) { - $this->signatory =& $signatory; + $this->signatory = $signatory; } /** * Sign an {@link Auth_OpenID_ServerResponse} and return an * {@link Auth_OpenID_WebResponse}. */ - function encode(&$response) + function encode($response) { // the isinstance is a bit of a kludge... it means there isn't // really an adapter to make the interfaces quite match. @@ -1516,9 +1520,9 @@ class Auth_OpenID_SigningEncoder extends Auth_OpenID_Encoder { */ class Auth_OpenID_Decoder { - function Auth_OpenID_Decoder(&$server) + function Auth_OpenID_Decoder($server) { - $this->server =& $server; + $this->server = $server; $this->handlers = array( 'checkid_setup' => 'Auth_OpenID_CheckIDRequest', @@ -1599,9 +1603,9 @@ class Auth_OpenID_Decoder { * @package OpenID */ class Auth_OpenID_EncodingError { - function Auth_OpenID_EncodingError(&$response) + function Auth_OpenID_EncodingError($response) { - $this->response =& $response; + $this->response = $response; } } @@ -1674,14 +1678,14 @@ class Auth_OpenID_UntrustedReturnURL extends Auth_OpenID_ServerError { * @package OpenID */ class Auth_OpenID_Server { - function Auth_OpenID_Server(&$store, $op_endpoint=null) + function Auth_OpenID_Server($store, $op_endpoint=null) { - $this->store =& $store; - $this->signatory =& new Auth_OpenID_Signatory($this->store); - $this->encoder =& new Auth_OpenID_SigningEncoder($this->signatory); - $this->decoder =& new Auth_OpenID_Decoder($this); + $this->store = $store; + $this->signatory = new Auth_OpenID_Signatory($this->store); + $this->encoder = new Auth_OpenID_SigningEncoder($this->signatory); + $this->decoder = new Auth_OpenID_Decoder($this); $this->op_endpoint = $op_endpoint; - $this->negotiator =& Auth_OpenID_getDefaultNegotiator(); + $this->negotiator = Auth_OpenID_getDefaultNegotiator(); } /** @@ -1707,7 +1711,7 @@ class Auth_OpenID_Server { /** * The callback for 'check_authentication' messages. */ - function openid_check_authentication(&$request) + function openid_check_authentication($request) { return $request->answer($this->signatory); } @@ -1715,7 +1719,7 @@ class Auth_OpenID_Server { /** * The callback for 'associate' messages. */ - function openid_associate(&$request) + function openid_associate($request) { $assoc_type = $request->assoc_type; $session_type = $request->session->session_type; @@ -1738,7 +1742,7 @@ class Auth_OpenID_Server { * Encodes as response in the appropriate format suitable for * sending to the user agent. */ - function encodeResponse(&$response) + function encodeResponse($response) { return $this->encoder->encode($response); } diff --git a/Auth/OpenID/TrustRoot.php b/Auth/OpenID/TrustRoot.php index 2d9f294..0f53958 100644 --- a/Auth/OpenID/TrustRoot.php +++ b/Auth/OpenID/TrustRoot.php @@ -58,7 +58,7 @@ class Auth_OpenID_TrustRoot { * @return The URL upon which relying party discovery should be * run in order to verify the return_to URL */ - function buildDiscoveryURL($realm) + static function buildDiscoveryURL($realm) { $parsed = Auth_OpenID_TrustRoot::_parse($realm); @@ -93,7 +93,7 @@ class Auth_OpenID_TrustRoot { * @return mixed $parsed Either an associative array of trust root * parts or false if parsing failed. */ - function _parse($trust_root) + static function _parse($trust_root) { $trust_root = Auth_OpenID_urinorm($trust_root); if ($trust_root === null) { @@ -199,7 +199,7 @@ class Auth_OpenID_TrustRoot { * @param string $trust_root The trust root to check * @return bool $sanity Whether the trust root looks OK */ - function isSane($trust_root) + static function isSane($trust_root) { $parts = Auth_OpenID_TrustRoot::_parse($trust_root); if ($parts === false) { @@ -269,7 +269,7 @@ class Auth_OpenID_TrustRoot { * @return bool $matches Whether the URL matches against the * trust root */ - function match($trust_root, $url) + static function match($trust_root, $url) { $trust_root_parsed = Auth_OpenID_TrustRoot::_parse($trust_root); $url_parsed = Auth_OpenID_TrustRoot::_parse($url); @@ -341,7 +341,7 @@ class Auth_OpenID_TrustRoot { * @returns: The endpoint URL or None if the endpoint is not a * relying party endpoint. */ -function filter_extractReturnURL(&$endpoint) +function filter_extractReturnURL($endpoint) { if ($endpoint->matchTypes(array(Auth_OpenID_RP_RETURN_TO_URL_TYPE))) { return $endpoint; @@ -394,7 +394,7 @@ function Auth_OpenID_returnToMatches($allowed_return_to_urls, $return_to) * Given a relying party discovery URL return a list of return_to * URLs. */ -function Auth_OpenID_getAllowedReturnURLs($relying_party_url, &$fetcher, +function Auth_OpenID_getAllowedReturnURLs($relying_party_url, $fetcher, $discover_function=null) { if ($discover_function === null) { @@ -435,7 +435,7 @@ function Auth_OpenID_getAllowedReturnURLs($relying_party_url, &$fetcher, * * @return true if the return_to URL is valid for the realm */ -function Auth_OpenID_verifyReturnTo($realm_str, $return_to, &$fetcher, +function Auth_OpenID_verifyReturnTo($realm_str, $return_to, $fetcher, $_vrfy='Auth_OpenID_getAllowedReturnURLs') { $disco_url = Auth_OpenID_TrustRoot::buildDiscoveryURL($realm_str); @@ -445,7 +445,7 @@ function Auth_OpenID_verifyReturnTo($realm_str, $return_to, &$fetcher, } $allowable_urls = call_user_func_array($_vrfy, - array($disco_url, &$fetcher)); + array($disco_url, $fetcher)); // The realm_str could not be parsed. if ($allowable_urls === false) { diff --git a/Auth/Yadis/Manager.php b/Auth/Yadis/Manager.php index 5b3ce62..5829de6 100644 --- a/Auth/Yadis/Manager.php +++ b/Auth/Yadis/Manager.php @@ -387,11 +387,11 @@ class Auth_Yadis_Discovery { * @param string $session_key_suffix The optional session key * suffix override. */ - function Auth_Yadis_Discovery(&$session, $url, + function Auth_Yadis_Discovery($session, $url, $session_key_suffix = null) { /// Initialize a discovery object - $this->session =& $session; + $this->session = $session; $this->url = $url; if ($session_key_suffix === null) { $session_key_suffix = $this->DEFAULT_SUFFIX; @@ -405,7 +405,7 @@ class Auth_Yadis_Discovery { * Return the next authentication service for the pair of * user_input and session. This function handles fallback. */ - function getNextService($discover_cb, &$fetcher) + function getNextService($discover_cb, $fetcher) { $manager = $this->getManager(); if (!$manager || (!$manager->services)) { @@ -466,7 +466,7 @@ class Auth_Yadis_Discovery { * @param $force True if the manager should be returned regardless * of whether it's a manager for $this->url. */ - function &getManager($force=false) + function getManager($force=false) { // Extract the YadisServiceManager for this object's URL and // suffix from the session. @@ -481,16 +481,13 @@ class Auth_Yadis_Discovery { if ($manager && ($manager->forURL($this->url) || $force)) { return $manager; - } else { - $unused = null; - return $unused; } } /** * @access private */ - function &createManager($services, $yadis_url = null) + function createManager($services, $yadis_url = null) { $key = $this->getSessionKey(); if ($this->getManager()) { @@ -504,10 +501,6 @@ class Auth_Yadis_Discovery { $this->session->set($this->session_key, serialize($loader->toSession($manager))); return $manager; - } else { - // Oh, PHP. - $unused = null; - return $unused; } } diff --git a/Auth/Yadis/XML.php b/Auth/Yadis/XML.php index fb4a16a..cf1f5c4 100644 --- a/Auth/Yadis/XML.php +++ b/Auth/Yadis/XML.php @@ -310,20 +310,16 @@ $__Auth_Yadis_defaultParser = null; * @param Auth_Yadis_XMLParser $parser An instance of a * Auth_Yadis_XMLParser subclass. */ -function Auth_Yadis_setDefaultParser(&$parser) +function Auth_Yadis_setDefaultParser($parser) { global $__Auth_Yadis_defaultParser; - $__Auth_Yadis_defaultParser =& $parser; + $__Auth_Yadis_defaultParser = $parser; } function Auth_Yadis_getSupportedExtensions() { - return array( - 'dom' => array('classname' => 'Auth_Yadis_dom', - 'libname' => array('dom.so', 'dom.dll')), - 'domxml' => array('classname' => 'Auth_Yadis_domxml', - 'libname' => array('domxml.so', 'php_domxml.dll')), - ); + return array('dom' => 'Auth_Yadis_dom', + 'domxml' => 'Auth_Yadis_domxml'); } /** @@ -332,43 +328,25 @@ function Auth_Yadis_getSupportedExtensions() * Auth_Yadis_setDefaultParser has been called, the parser used in * that call will be returned instead. */ -function &Auth_Yadis_getXMLParser() +function Auth_Yadis_getXMLParser() { global $__Auth_Yadis_defaultParser; - + if (isset($__Auth_Yadis_defaultParser)) { return $__Auth_Yadis_defaultParser; } - - $p = null; - $classname = null; - - $extensions = Auth_Yadis_getSupportedExtensions(); - - // Return a wrapper for the resident implementation, if any. - foreach ($extensions as $name => $params) { - if (!extension_loaded($name)) { - foreach ($params['libname'] as $libname) { - if (@dl($libname)) { - $classname = $params['classname']; - } - } - } else { - $classname = $params['classname']; - } - if (isset($classname)) { - $p = new $classname(); - return $p; - } - } - - if (!isset($p)) { - trigger_error('No XML parser was found', E_USER_ERROR); - } else { + + foreach(Auth_Yadis_getSupportedExtensions() as $extension => $classname) + { + if (extension_loaded($extension)) + { + $p = new $classname(); Auth_Yadis_setDefaultParser($p); + return $p; + } } - - return $p; + + return false; } diff --git a/Auth/Yadis/XRDS.php b/Auth/Yadis/XRDS.php index 107818b..1960952 100644 --- a/Auth/Yadis/XRDS.php +++ b/Auth/Yadis/XRDS.php @@ -255,11 +255,11 @@ class Auth_Yadis_XRDS { * Instantiate a Auth_Yadis_XRDS object. Requires an XPath * instance which has been used to parse a valid XRDS document. */ - function Auth_Yadis_XRDS(&$xmlParser, &$xrdNodes) + function Auth_Yadis_XRDS($xmlParser, $xrdNodes) { - $this->parser =& $xmlParser; + $this->parser = $xmlParser; $this->xrdNode = $xrdNodes[count($xrdNodes) - 1]; - $this->allXrdNodes =& $xrdNodes; + $this->allXrdNodes = $xrdNodes; $this->serviceList = array(); $this->_parse(); } @@ -273,7 +273,7 @@ class Auth_Yadis_XRDS { * @return mixed $xrds An instance of Auth_Yadis_XRDS or null, * depending on the validity of $xml_string */ - function &parseXRDS($xml_string, $extra_ns_map = null) + static function parseXRDS($xml_string, $extra_ns_map = null) { $_null = null; @@ -352,9 +352,9 @@ class Auth_Yadis_XRDS { $services = $this->parser->evalXPath('xrd:Service', $this->xrdNode); foreach ($services as $node) { - $s =& new Auth_Yadis_Service(); + $s = new Auth_Yadis_Service(); $s->element = $node; - $s->parser =& $this->parser; + $s->parser = $this->parser; $priority = $s->getPriority(); diff --git a/Auth/Yadis/XRI.php b/Auth/Yadis/XRI.php index dd41593..0143a69 100644 --- a/Auth/Yadis/XRI.php +++ b/Auth/Yadis/XRI.php @@ -190,7 +190,7 @@ function Auth_Yadis_getCanonicalID($iname, $xrds) // Now nodes are in reverse order. $xrd_list = array_reverse($xrds->allXrdNodes); - $parser =& $xrds->parser; + $parser = $xrds->parser; $node = $xrd_list[0]; $canonicalID_nodes = $parser->evalXPath('xrd:CanonicalID', $node); diff --git a/Auth/Yadis/XRIRes.php b/Auth/Yadis/XRIRes.php index 0f4ea10..5e11587 100644 --- a/Auth/Yadis/XRIRes.php +++ b/Auth/Yadis/XRIRes.php @@ -8,9 +8,9 @@ require_once 'Auth/Yadis/XRDS.php'; require_once 'Auth/Yadis/XRI.php'; class Auth_Yadis_ProxyResolver { - function Auth_Yadis_ProxyResolver(&$fetcher, $proxy_url = null) + function Auth_Yadis_ProxyResolver($fetcher, $proxy_url = null) { - $this->fetcher =& $fetcher; + $this->fetcher = $fetcher; $this->proxy_url = $proxy_url; if (!$this->proxy_url) { $this->proxy_url = Auth_Yadis_getDefaultProxy(); diff --git a/Auth/Yadis/Yadis.php b/Auth/Yadis/Yadis.php index 6b87c0f..f885367 100644 --- a/Auth/Yadis/Yadis.php +++ b/Auth/Yadis/Yadis.php @@ -196,7 +196,7 @@ function Auth_Yadis_getServiceEndpoints($input_url, $xrds_parse_func, * The filter functions (whose names appear in the array passed to * services()) take the following form: * - * <pre> function myFilter(&$service) { + * <pre> function myFilter($service) { * // Query $service object here. Return true if the service * // matches your query; false if not. * }</pre> @@ -207,7 +207,7 @@ function Auth_Yadis_getServiceEndpoints($input_url, $xrds_parse_func, * this contrived example): * * <pre> - * function URIMatcher(&$service) { + * function URIMatcher($service) { * foreach ($service->getElements('xrd:URI') as $uri) { * if (preg_match("/some_pattern/", * $service->parser->content($uri))) { @@ -250,7 +250,7 @@ class Auth_Yadis_Yadis { * If Auth_Yadis_CURL_OVERRIDE is defined, this method will always * return a {@link Auth_Yadis_PlainHTTPFetcher}. */ - function getHTTPFetcher($timeout = 20) + static function getHTTPFetcher($timeout = 20) { if (Auth_Yadis_Yadis::curlPresent() && (!defined('Auth_Yadis_CURL_OVERRIDE'))) { @@ -261,7 +261,7 @@ class Auth_Yadis_Yadis { return $fetcher; } - function curlPresent() + static function curlPresent() { return function_exists('curl_init'); } @@ -269,7 +269,7 @@ class Auth_Yadis_Yadis { /** * @access private */ - function _getHeader($header_list, $names) + static function _getHeader($header_list, $names) { foreach ($header_list as $name => $value) { foreach ($names as $n) { @@ -285,7 +285,7 @@ class Auth_Yadis_Yadis { /** * @access private */ - function _getContentType($content_type_header) + static function _getContentType($content_type_header) { if ($content_type_header) { $parts = explode(";", $content_type_header); @@ -317,7 +317,7 @@ class Auth_Yadis_Yadis { * Auth_Yadis_Yadis, depending on whether the discovery * succeeded. */ - function discover($uri, &$fetcher, + static function discover($uri, $fetcher, $extra_ns_map = null, $timeout = 20) { $result = new Auth_Yadis_DiscoveryResult($uri); diff --git a/Tests/Auth/OpenID/BigMath.php b/Tests/Auth/OpenID/BigMath.php index fb258d9..acab4d9 100644 --- a/Tests/Auth/OpenID/BigMath.php +++ b/Tests/Auth/OpenID/BigMath.php @@ -159,7 +159,7 @@ class Tests_Auth_OpenID_BigMath extends PHPUnit_Framework_TestSuite { function _addB64Tests() { - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $count = defined('Tests_Auth_OpenID_thorough') ? -1 : 2; $data = $this->_parseBase64Data(); foreach ($data as $b64 => $num_s) { diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php index 73f2a21..761f9f2 100644 --- a/Tests/Auth/OpenID/Consumer.php +++ b/Tests/Auth/OpenID/Consumer.php @@ -1693,12 +1693,12 @@ class Tests_Auth_OpenID_AuthRequestHTMLMarkup extends PHPUnit_Framework_TestCase { $html = $this->request->htmlMarkup('http://realm.com/', 'http://realm.com/return_to'); - $this->assertTrue(substr($html,"<html>") !== false); - $this->assertTrue(substr($html,"</html>") !== false); - $this->assertTrue(substr($html,"<body onload") !== false); - $this->assertTrue(substr($html,"</body>") !== false); - $this->assertTrue(substr($html,"<form") !== false); - $this->assertTrue(substr($html,"</form>") !== false); + $this->assertTrue(strpos($html,"<html>") !== false); + $this->assertTrue(strpos($html,"</html>") !== false); + $this->assertTrue(strpos($html,"<body onload") !== false); + $this->assertTrue(strpos($html,"</body>") !== false); + $this->assertTrue(strpos($html,"<form") !== false); + $this->assertTrue(strpos($html,"</form>") !== false); } } @@ -1817,9 +1817,9 @@ class Tests_Auth_OpenID_DiscoFailure extends PHPUnit_Framework_TestCase { $this->store = null; $this->session = new Auth_Yadis_PHPSession(); $cls = $this->consumerClass; - $this->consumer =& new $cls($this->store, $this->session); - $this->consumer->consumer =& new _StubConsumer(); - $this->discovery =& new Auth_Yadis_Discovery($this->session, + $this->consumer = new $cls($this->store, $this->session); + $this->consumer->consumer = new _StubConsumer(); + $this->discovery = new Auth_Yadis_Discovery($this->session, $this->claimed_id, $this->consumer->session_key_prefix); } @@ -1848,9 +1848,9 @@ class Tests_Auth_OpenID_ConsumerTest2 extends PHPUnit_Framework_TestCase { $this->endpoint->claimed_id = $this->claimed_id; $this->store = null; $this->session = new Auth_Yadis_PHPSession(); - $this->consumer =& new Auth_OpenID_Consumer($this->store, $this->session); - $this->consumer->consumer =& new _StubConsumer(); - $this->discovery =& new Auth_Yadis_Discovery($this->session, + $this->consumer = new Auth_OpenID_Consumer($this->store, $this->session); + $this->consumer->consumer = new _StubConsumer(); + $this->discovery = new Auth_Yadis_Discovery($this->session, $this->claimed_id, $this->consumer->session_key_prefix); } @@ -2385,7 +2385,7 @@ class TestDiffieHellmanResponseParameters extends PHPUnit_Framework_TestCase { $this->server_dh = new Auth_OpenID_DiffieHellman(100389557, 2); $this->consumer_dh = new Auth_OpenID_DiffieHellman(100389557, 2); - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $cls = $this->session_cls; $this->consumer_session = new $cls($this->consumer_dh); diff --git a/Tests/Auth/OpenID/DiffieHellman.php b/Tests/Auth/OpenID/DiffieHellman.php index 3336061..524c011 100644 --- a/Tests/Auth/OpenID/DiffieHellman.php +++ b/Tests/Auth/OpenID/DiffieHellman.php @@ -57,7 +57,7 @@ class Tests_Auth_OpenID_DiffieHellman_Exch extends PHPUnit_Framework_TestCase { function runTest() { - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $shared = $lib->init($this->shared); $dh1 = new Auth_OpenID_DiffieHellman(null, null, $this->p1); $dh2 = new Auth_OpenID_DiffieHellman(null, null, $this->p2); diff --git a/Tests/Auth/OpenID/Discover_OpenID.php b/Tests/Auth/OpenID/Discover_OpenID.php index 03d25dc..740548d 100644 --- a/Tests/Auth/OpenID/Discover_OpenID.php +++ b/Tests/Auth/OpenID/Discover_OpenID.php @@ -715,7 +715,7 @@ class Tests_Auth_OpenID_SSLSupport extends PHPUnit_Framework_TestCase { Tests_Auth_OpenID_readdata('test_discover_openid_ssl.xml')) ); - $f =& new _FetcherWithoutSSL($d); + $f = new _FetcherWithoutSSL($d); $result = Auth_OpenID_discover($id_url, $f); @@ -742,7 +742,7 @@ class Tests_Auth_OpenID_SSLSupport extends PHPUnit_Framework_TestCase { Tests_Auth_OpenID_readdata('test_discover_openid_ssl.xml')) ); - $f =& new _FetcherWithSSL($d); + $f = new _FetcherWithSSL($d); $result = Auth_OpenID_discover($id_url, $f); @@ -765,7 +765,7 @@ class Tests_Auth_OpenID_SSLSupport extends PHPUnit_Framework_TestCase { $id_url = 'https://unsupported/'; - $f =& new _NonFetcher(); + $f = new _NonFetcher(); $result = Auth_OpenID_discover($id_url, $f); diff --git a/Tests/Auth/OpenID/MemStore.php b/Tests/Auth/OpenID/MemStore.php index 68a085f..7724719 100644 --- a/Tests/Auth/OpenID/MemStore.php +++ b/Tests/Auth/OpenID/MemStore.php @@ -85,7 +85,7 @@ class Tests_Auth_OpenID_MemStore extends Auth_OpenID_OpenIDStore { function &_getServerAssocs($server_url) { if (!array_key_exists($server_url, $this->server_assocs)) { - $this->server_assocs[$server_url] =& new ServerAssocs(); + $this->server_assocs[$server_url] = new ServerAssocs(); } return $this->server_assocs[$server_url]; diff --git a/Tests/Auth/OpenID/Message.php b/Tests/Auth/OpenID/Message.php index 88706e5..0205fc4 100644 --- a/Tests/Auth/OpenID/Message.php +++ b/Tests/Auth/OpenID/Message.php @@ -980,7 +980,7 @@ class Tests_Auth_OpenID_GeneralMessageTest extends PHPUnit_Framework_TestCase { function _checkForm($html, $message_, $action_url, $form_tag_attrs, $submit_text) { - $parser =& Auth_Yadis_getXMLParser(); + $parser = Auth_Yadis_getXMLParser(); // Parse HTML source $this->assertTrue($parser->init($html, array())); diff --git a/Tests/Auth/OpenID/RPVerify.php b/Tests/Auth/OpenID/RPVerify.php index e09138a..1482af4 100644 --- a/Tests/Auth/OpenID/RPVerify.php +++ b/Tests/Auth/OpenID/RPVerify.php @@ -9,9 +9,6 @@ require_once 'Auth/OpenID/TrustRoot.php'; require_once 'Auth/Yadis/Yadis.php'; -// Because "null" cannot be passed by reference. -$NULL_FETCHER = null; - /* * Tests for building the discovery URL from a realm and a return_to * URL @@ -67,7 +64,7 @@ class Tests_Auth_OpenID_ExtractReturnToURLs extends PHPUnit_Framework_TestCase { function failUnlessXRDSHasReturnURLs($data, $expected_return_urls) { $discover_object = new _MockDiscover($data); - $actual_return_urls = Auth_OpenID_getAllowedReturnURLs($this->disco_url, $NULL_FETCHER, array($discover_object, 'mockDiscover')); + $actual_return_urls = Auth_OpenID_getAllowedReturnURLs($this->disco_url, null, array($discover_object, 'mockDiscover')); $this->assertEquals($expected_return_urls, $actual_return_urls); } @@ -75,7 +72,7 @@ class Tests_Auth_OpenID_ExtractReturnToURLs extends PHPUnit_Framework_TestCase { function failUnlessDiscoveryFailure($text) { $discover_object = new _MockDiscover($text); - $this->assertFalse(Auth_OpenID_getAllowedReturnURLs($this->disco_url, $NULL_FETCHER, array($discover_object, 'mockDiscover'))); + $this->assertFalse(Auth_OpenID_getAllowedReturnURLs($this->disco_url, null, array($discover_object, 'mockDiscover'))); } function test_empty() @@ -244,7 +241,7 @@ class Tests_Auth_OpenID_VerifyReturnTo extends PHPUnit_Framework_TestCase { function test_bogusRealm() { - $this->assertFalse(Auth_OpenID_verifyReturnTo('', 'http://example.com/', $NULL_FETCHER)); + $this->assertFalse(Auth_OpenID_verifyReturnTo('', 'http://example.com/', null)); } function test_verifyWithDiscoveryCalled() @@ -254,7 +251,7 @@ class Tests_Auth_OpenID_VerifyReturnTo extends PHPUnit_Framework_TestCase { $v = new Verifier($this, $return_to); - $this->assertTrue(Auth_OpenID_verifyReturnTo($realm, $return_to, $NULL_FETCHER, array($v, 'verify'))); + $this->assertTrue(Auth_OpenID_verifyReturnTo($realm, $return_to, null, array($v, 'verify'))); } function test_verifyFailWithDiscoveryCalled() @@ -264,7 +261,7 @@ class Tests_Auth_OpenID_VerifyReturnTo extends PHPUnit_Framework_TestCase { $v = new Verifier($this, 'http://something-else.invalid/'); - $this->assertFalse(Auth_OpenID_verifyReturnTo($realm, $return_to, $NULL_FETCHER, array($v, 'verify'))); + $this->assertFalse(Auth_OpenID_verifyReturnTo($realm, $return_to, null, array($v, 'verify'))); } function test_verifyFailIfDiscoveryRedirects() @@ -274,7 +271,7 @@ class Tests_Auth_OpenID_VerifyReturnTo extends PHPUnit_Framework_TestCase { $v = new Verifier($this, false); - $this->assertFalse(Auth_OpenID_verifyReturnTo($realm, $return_to, $NULL_FETCHER, array($v, 'verify'))); + $this->assertFalse(Auth_OpenID_verifyReturnTo($realm, $return_to, null, array($v, 'verify'))); } } diff --git a/Tests/Auth/OpenID/SReg.php b/Tests/Auth/OpenID/SReg.php index 5546600..db5cd51 100644 --- a/Tests/Auth/OpenID/SReg.php +++ b/Tests/Auth/OpenID/SReg.php @@ -209,14 +209,14 @@ function &__getTestCase() { } class TestingReq extends Auth_OpenID_SRegRequest { - function fromOpenIDRequest($thing, $test_case) + static function fromOpenIDRequest($thing, $test_case) { __setTestCase($test_case); $obj = parent::fromOpenIDRequest($thing, 'TestingReq'); return $obj; } - function _getSRegNS($unused) + static function _getSRegNS($unused) { global $__ns_sentinel; return $__ns_sentinel; diff --git a/Tests/Auth/OpenID/Server.php b/Tests/Auth/OpenID/Server.php index bcb4f2a..d5dea91 100644 --- a/Tests/Auth/OpenID/Server.php +++ b/Tests/Auth/OpenID/Server.php @@ -12,7 +12,7 @@ require_once "Auth/OpenID/Consumer.php"; function altModulus() { - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); static $num = null; if (!$num) { @@ -520,7 +520,7 @@ class Tests_Auth_OpenID_Test_Decode extends PHPUnit_Framework_TestCase { // test dh with non-default but valid values for dh_modulus // and dh_gen - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $args = array( 'openid.mode' => 'associate', @@ -1661,7 +1661,7 @@ class Tests_Auth_OpenID_Associate extends PHPUnit_Framework_TestCase { 'HMAC-SHA1'); $dh = new Auth_OpenID_DiffieHellman(); - $ml =& Auth_OpenID_getMathLib(); + $ml = Auth_OpenID_getMathLib(); $cpub = $dh->public; $session = new Auth_OpenID_DiffieHellmanSHA1ServerSession( @@ -1743,7 +1743,7 @@ class Tests_Auth_OpenID_Associate extends PHPUnit_Framework_TestCase { $enc_key = base64_decode( $response->fields->getArg(Auth_OpenID_OPENID_NS, "enc_mac_key")); - $lib =& Auth_OpenID_getMathLib(); + $lib = Auth_OpenID_getMathLib(); $spub = $lib->base64ToLong($response->fields->getArg(Auth_OpenID_OPENID_NS, "dh_server_public")); $secret = $consumer_dh->xorSecret($spub, $enc_key, 'Auth_OpenID_SHA256'); @@ -2148,8 +2148,8 @@ class Tests_Auth_OpenID_ServerTest extends PHPUnit_Framework_TestCase { class Tests_Auth_OpenID_Signatory extends PHPUnit_Framework_TestCase { function setUp() { - $this->store =& new Tests_Auth_OpenID_MemStore(); - $this->signatory =& new Auth_OpenID_Signatory($this->store); + $this->store = new Tests_Auth_OpenID_MemStore(); + $this->signatory = new Auth_OpenID_Signatory($this->store); $this->dumb_key = $this->signatory->dumb_key; $this->normal_key = $this->signatory->normal_key; } diff --git a/Tests/Auth/OpenID/StoreTest.php b/Tests/Auth/OpenID/StoreTest.php index 5e8c8d4..7c50e2f 100644 --- a/Tests/Auth/OpenID/StoreTest.php +++ b/Tests/Auth/OpenID/StoreTest.php @@ -438,9 +438,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { { // If the postgres extension isn't loaded or loadable, succeed // because we can't run the test. - if (!(extension_loaded('pgsql') || - @dl('pgsql.so') || - @dl('php_pgsql.dll')) || + if (!(extension_loaded('pgsql')) || !(@include_once 'DB.php')) { print "(not testing PostGreSQL store)"; $this->pass(); @@ -512,7 +510,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { return; } - $store =& new Auth_OpenID_PostgreSQLStore($db); + $store = new Auth_OpenID_PostgreSQLStore($db); $this->assertFalse($store->tableExists($store->nonces_table_name)); $this->assertFalse($store->tableExists($store->associations_table_name)); @@ -558,9 +556,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { { // If the sqlite extension isn't loaded or loadable, succeed // because we can't run the test. - if (!(extension_loaded('sqlite') || - @dl('sqlite.so') || - @dl('php_sqlite.dll')) || + if (!(extension_loaded('sqlite')) || !(@include_once 'DB.php')) { print "(not testing SQLite store)"; $this->pass(); @@ -585,7 +581,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { $this->pass("SQLite database connection failed: " . $db->getMessage()); } else { - $store =& new Auth_OpenID_SQLiteStore($db); + $store = new Auth_OpenID_SQLiteStore($db); $this->assertTrue($store->createTables(), "Table creation failed"); $this->_testStore($store); $this->_testNonce($store); @@ -603,8 +599,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { { // If the mysql extension isn't loaded or loadable, succeed // because we can't run the test. - if (!(extension_loaded('mysql') || - @dl('mysql.' . PHP_SHLIB_SUFFIX)) || + if (!(extension_loaded('mysql')) || !(@include_once 'DB.php')) { print "(not testing MySQL store)"; $this->pass(); @@ -643,7 +638,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store { $db->query("USE $temp_db_name"); - $store =& new Auth_OpenID_MySQLStore($db); + $store = new Auth_OpenID_MySQLStore($db); $store->createTables(); $this->_testStore($store); $this->_testNonce($store); @@ -720,9 +715,7 @@ class Tests_Auth_OpenID_MemcachedStore_Test extends Tests_Auth_OpenID_Store { { // If the memcache extension isn't loaded or loadable, succeed // because we can't run the test. - if (!(extension_loaded('memcache') || - @dl('memcache.so') || - @dl('php_memcache.dll'))) { + if (!extension_loaded('memcache')) { print "(skipping memcache store tests)"; $this->pass(); return; diff --git a/Tests/Auth/OpenID/VerifyDisco.php b/Tests/Auth/OpenID/VerifyDisco.php index f18d3aa..ea2566d 100644 --- a/Tests/Auth/OpenID/VerifyDisco.php +++ b/Tests/Auth/OpenID/VerifyDisco.php @@ -171,7 +171,7 @@ class Tests_Auth_OpenID_VerifyDisco extends _DiscoverAndVerify { function test_openid2UsePreDiscoveredWrongType() { - $this->consumer =& new Tests_Auth_OpenID_VerifyDisco_1($this->store); + $this->consumer = new Tests_Auth_OpenID_VerifyDisco_1($this->store); $this->consumer->test_case =& $this; $this->consumer->text = "verify failed"; diff --git a/Tests/Auth/Yadis/XRI.php b/Tests/Auth/Yadis/XRI.php index 220c196..403b1e3 100644 --- a/Tests/Auth/Yadis/XRI.php +++ b/Tests/Auth/Yadis/XRI.php @@ -64,7 +64,7 @@ class Tests_Auth_Yadis_ProxyQueryTestCase extends PHPUnit_Framework_TestCase { { $this->proxy_url = 'http://xri.example.com/'; $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); - $this->proxy = new Auth_Yadis_ProxyResolver($fetcher, + $this->proxy = new Auth_Yadis_ProxyResolver($this->fetcher, $this->proxy_url); $this->servicetype = 'xri://+i-service*(+forwarding)*($v*1.0)'; $this->servicetype_enc = 'xri%3A%2F%2F%2Bi-service%2A%28%2Bforwarding%29%2A%28%24v%2A1.0%29'; diff --git a/Tests/TestDriver.php b/Tests/TestDriver.php index 27312d2..1a1f5b1 100644 --- a/Tests/TestDriver.php +++ b/Tests/TestDriver.php @@ -16,7 +16,7 @@ require_once 'PHPUnit/Framework.php'; //require_once 'PHPUnit/GUI/HTML.php'; -error_reporting(E_ALL); +error_reporting(E_ALL | E_STRICT); global $__test_errors; $__test_errors = array(); |