Update and rename Deactivated_Super_Globals.php to deactivated_super_global.php and zpdate to PHP8

This commit is contained in:
Florin-Ciprian Bodin
2024-03-26 16:48:25 +02:00
committed by GitHub
parent a515d1ba60
commit 365aaf6132

View File

@@ -61,11 +61,11 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
* @param string $name Name of the super global this is a replacement for - e.g. '_GET'.
* @param mx_request_vars::POST|GET|REQUEST|COOKIE $super_global The variable's super global constant.
*/
public function __construct(request $request, $name, $super_global)
public function __construct($request, string $name, int $super_global)
{
$this->request = $request;
$this->name = $name;
$this->super_global = $super_global;
$this->request = $request;
$this->name = $name;
$this->super_global = $super_global;
}
/**
@@ -75,15 +75,17 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
{
$file = '';
$line = 0;
$message = 'Illegal use of $' . $this->name . '. You must use the request class to access input data. Found in %s on line %d. This error message was generated by deactivated_super_global.';
$backtrace = debug_backtrace();
if (isset($backtrace[1]))
{
$file = $backtrace[1]['file'];
$line = $backtrace[1]['line'];
$file = isset($backtrace[1]['file']) ? $backtrace[1]['file'] : 'file? ';
$line = isset($backtrace[1]['line']) ? $backtrace[1]['line'] : 0;
}
trigger_error(sprintf($message, $file, $line), E_USER_ERROR);
}
@@ -94,7 +96,7 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
*
* @return bool Whether the key on the super global exists.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->request->is_set($offset, $this->super_global);
}
@@ -102,17 +104,17 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**#@+
* Part of the \ArrayAccess implementation, will always result in a FATAL error.
*/
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
$this->error();
}
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->error();
}
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->error();
}
@@ -121,7 +123,8 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**
* Part of the \Countable implementation, will always result in a FATAL error
*/
public function count()
#[\ReturnTypeWillChange]
public function count(): void
{
$this->error();
}
@@ -129,10 +132,10 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**
* Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error
*/
public function getIterator()
#[\ReturnTypeWillChange]
public function getIterator(): void
{
$this->error();
}
} // class deactivated_super_global
?>
?>