summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-04-04 22:55:40 +0000
committertailor <cygnus@janrain.com>2007-04-04 22:55:40 +0000
commit9bd1ca15e7f07e3c5ab28edddcf244555b2887ce (patch)
tree231d6b5a3041a5476033d2dd85eee852b3bc613c
parentf53a81c83f27a5d84e998b197b6569e35a12df8b (diff)
downloadphp-openid-9bd1ca15e7f07e3c5ab28edddcf244555b2887ce.zip
php-openid-9bd1ca15e7f07e3c5ab28edddcf244555b2887ce.tar.gz
php-openid-9bd1ca15e7f07e3c5ab28edddcf244555b2887ce.tar.bz2
[project @ Move math extension data into a function]
-rw-r--r--Auth/OpenID/BigMath.php39
-rw-r--r--admin/texttest.php12
-rw-r--r--examples/detect.php3
3 files changed, 28 insertions, 26 deletions
diff --git a/Auth/OpenID/BigMath.php b/Auth/OpenID/BigMath.php
index f8188a3..cfa0b35 100644
--- a/Auth/OpenID/BigMath.php
+++ b/Auth/OpenID/BigMath.php
@@ -340,20 +340,24 @@ class Auth_OpenID_GmpMathWrapper extends Auth_OpenID_MathLibrary{
* You can define new math library implementations and add them to
* this array.
*/
-global $_Auth_OpenID_math_extensions;
-$_Auth_OpenID_math_extensions = array();
-
-if (!defined('Auth_OpenID_BUGGY_GMP')) {
- $_Auth_OpenID_math_extensions[] =
- array('modules' => array('gmp', 'php_gmp'),
- 'extension' => 'gmp',
- 'class' => 'Auth_OpenID_GmpMathWrapper');
-}
+function Auth_OpenID_math_extensions()
+{
+ $result = array();
+
+ if (!defined('Auth_OpenID_BUGGY_GMP')) {
+ $result[] =
+ array('modules' => array('gmp', 'php_gmp'),
+ 'extension' => 'gmp',
+ 'class' => 'Auth_OpenID_GmpMathWrapper');
+ }
+
+ $result[] = array(
+ 'modules' => array('bcmath', 'php_bcmath'),
+ 'extension' => 'bcmath',
+ 'class' => 'Auth_OpenID_BcMathWrapper');
-$_Auth_OpenID_math_extensions[] = array(
- 'modules' => array('bcmath', 'php_bcmath'),
- 'extension' => 'bcmath',
- 'class' => 'Auth_OpenID_BcMathWrapper');
+ return $result;
+}
/**
* Detect which (if any) math library is available
@@ -397,7 +401,7 @@ function Auth_OpenID_detectMathLibrary($exts)
* functionality.
*
* Checks for the existence of an extension module described by the
- * local {@link Auth_OpenID_math_extensions} array and returns an
+ * result of {@link Auth_OpenID_math_extensions()} and returns an
* 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
@@ -429,13 +433,12 @@ function &Auth_OpenID_getMathLib()
}
// If this method has not been called before, look at
- // $Auth_OpenID_math_extensions and try to find an extension that
+ // Auth_OpenID_math_extensions and try to find an extension that
// works.
- global $_Auth_OpenID_math_extensions;
- $ext = Auth_OpenID_detectMathLibrary($_Auth_OpenID_math_extensions);
+ $ext = Auth_OpenID_detectMathLibrary(Auth_OpenID_math_extensions());
if ($ext === false) {
$tried = array();
- foreach ($_Auth_OpenID_math_extensions as $extinfo) {
+ foreach (Auth_OpenID_math_extensions() as $extinfo) {
$tried[] = $extinfo['extension'];
}
$triedstr = implode(", ", $tried);
diff --git a/admin/texttest.php b/admin/texttest.php
index c2945f7..c42e763 100644
--- a/admin/texttest.php
+++ b/admin/texttest.php
@@ -80,9 +80,6 @@ foreach ($flags as $flag) {
case '--no-curl':
define('Auth_Yadis_CURL_OVERRIDE', true);
break;
- case '--math-lib':
- $math_type[] = $value;
- break;
case '--thorough':
define('Tests_Auth_OpenID_thorough', true);
break;
@@ -93,8 +90,11 @@ foreach ($flags as $flag) {
}
// ******** Math library selection ***********
-
-if ($math_type) {
+// XXX FIXME
+// case '--math-lib':
+// $math_type[] = $value;
+// break;
+if ($math_type && false) {
if (defined('Auth_OpenID_NO_MATH_SUPPORT')) {
print "--no-math and --math-lib are mutually exclusive\n";
exit(1);
@@ -103,7 +103,7 @@ if ($math_type) {
$new_extensions = array();
foreach ($math_type as $lib) {
$found = false;
- foreach ($_Auth_OpenID_math_extensions as $ext) {
+ foreach (Auth_OpenID_math_extensions() as $ext) {
if ($ext['extension'] == $lib) {
$new_extensions[] = $ext;
$found = true;
diff --git a/examples/detect.php b/examples/detect.php
index 3d06cf6..e2d7c98 100644
--- a/examples/detect.php
+++ b/examples/detect.php
@@ -169,9 +169,8 @@ if (isset($_SERVER['REQUEST_METHOD'])) {
function detect_math($r, &$out)
{
- global $_Auth_OpenID_math_extensions;
$out .= $r->h2('Math support');
- $ext = Auth_OpenID_detectMathLibrary($_Auth_OpenID_math_extensions);
+ $ext = Auth_OpenID_detectMathLibrary(Auth_OpenID_math_extensions());
if (!isset($ext['extension']) || !isset($ext['class'])) {
$out .= $r->p(
'Your PHP installation does not include big integer math ' .