From 365aaf6132c0b0cf9b8cd8ca8a9ca6283d396347 Mon Sep 17 00:00:00 2001 From: Florin-Ciprian Bodin Date: Tue, 26 Mar 2024 16:48:25 +0200 Subject: [PATCH] Update and rename Deactivated_Super_Globals.php to deactivated_super_global.php and zpdate to PHP8 --- ...obals.php => deactivated_super_global.php} | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) rename classes/{Deactivated_Super_Globals.php => deactivated_super_global.php} (83%) diff --git a/classes/Deactivated_Super_Globals.php b/classes/deactivated_super_global.php similarity index 83% rename from classes/Deactivated_Super_Globals.php rename to classes/deactivated_super_global.php index 29c24a6..2ea1cac 100644 --- a/classes/Deactivated_Super_Globals.php +++ b/classes/deactivated_super_global.php @@ -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 - -?> \ No newline at end of file +?>