1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 12:14:06 +02:00

[feature/request-class] Refactor request classes to use autoloading

All class names have been adjusted to use a phpbb_request prefix,
allowing them to be autoloaded.

Also introduces some improvements to autoloading in general.

PHPBB3-9716
This commit is contained in:
Igor Wiedler
2010-08-31 21:26:50 +02:00
committed by Nils Adermann
parent b3558b5078
commit 456de63912
14 changed files with 38 additions and 32 deletions

View File

@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
function set_var(&$result, $var, $type, $multibyte = false)
{
// no need for dependency injection here, if you have the object, call the method yourself!
$type_cast_helper = new phpbb_type_cast_helper();
$type_cast_helper = new phpbb_request_type_cast_helper();
$type_cast_helper->set_var($result, $var, $type, $multibyte);
}
@@ -70,7 +70,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, p
{
// false param: enable super globals, so the created request class does not
// make super globals inaccessible everywhere outside this function.
$tmp_request = new phpbb_request(new phpbb_type_cast_helper(), false);
$tmp_request = new phpbb_request(new phpbb_request_type_cast_helper(), false);
}
return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? phpbb_request_interface::COOKIE : phpbb_request_interface::REQUEST);

View File

@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpbb_request
*/
class phpbb_deactivated_super_global implements ArrayAccess, Countable, IteratorAggregate
class phpbb_request_deactivated_super_global implements ArrayAccess, Countable, IteratorAggregate
{
/**
* @var string Holds the name of the superglobal this is replacing.

View File

@@ -51,15 +51,15 @@ class phpbb_request implements phpbb_request_interface
protected $input;
/**
* @var phpbb_type_cast_helper_interface An instance of a type cast helper providing convenience methods for type conversions.
* @var phpbb_request_type_cast_helper_interface An instance of a type cast helper providing convenience methods for type conversions.
*/
protected $type_cast_helper;
/**
* Initialises the request class, that means it stores all input data in {@link $input input}
* and then calls {@link phpbb_deactivated_super_global phpbb_deactivated_super_global}
* and then calls {@link phpbb_request_deactivated_super_global phpbb_request_deactivated_super_global}
*/
public function __construct(phpbb_type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true)
public function __construct(phpbb_request_type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true)
{
if ($type_cast_helper)
{
@@ -67,7 +67,7 @@ class phpbb_request implements phpbb_request_interface
}
else
{
$this->type_cast_helper = new phpbb_type_cast_helper();
$this->type_cast_helper = new phpbb_request_type_cast_helper();
}
foreach ($this->super_globals as $const => $super_global)
@@ -97,7 +97,7 @@ class phpbb_request implements phpbb_request_interface
/**
* Disables access of super globals specified in $super_globals.
* This is achieved by overwriting the super globals with instances of {@link phpbb_deactivated_super_global phpbb_deactivated_super_global}
* This is achieved by overwriting the super globals with instances of {@link phpbb_request_deactivated_super_global phpbb_request_deactivated_super_global}
*/
public function disable_super_globals()
{
@@ -106,7 +106,7 @@ class phpbb_request implements phpbb_request_interface
foreach ($this->super_globals as $const => $super_global)
{
unset($GLOBALS[$super_global]);
$GLOBALS[$super_global] = new phpbb_deactivated_super_global($this, $super_global, $const);
$GLOBALS[$super_global] = new phpbb_request_deactivated_super_global($this, $super_global, $const);
}
$this->super_globals_disabled = true;

View File

@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpbb_request
*/
class phpbb_type_cast_helper implements phpbb_type_cast_helper_interface
class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_interface
{
/**

View File

@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*
* @package phpbb_request
*/
interface phpbb_type_cast_helper_interface
interface phpbb_request_type_cast_helper_interface
{
/**
* Recursively applies addslashes to a variable.