request = $request; $this->name = $name; $this->super_global = $super_global; } /** * Calls trigger_error with the file and line number the super global was used in. */ private function error() { $file = ''; $line = 0; $message = 'Illegal use of $' . $this->name . '. You must use the request class or request_var() 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']; } trigger_error(sprintf($message, $file, $line), E_USER_ERROR); } /** * Redirects isset to the correct request class call. * * @param string $offset The key of the super global being accessed. * * @return bool Whether the key on the super global exists. */ public function offsetExists($offset) { return $this->request->is_set($offset, $this->super_global); } /**#@+ * Part of the \ArrayAccess implementation, will always result in a FATAL error. */ public function offsetGet($offset) { $this->error(); } public function offsetSet($offset, $value) { $this->error(); } public function offsetUnset($offset) { $this->error(); } /**#@-*/ /** * Part of the \Countable implementation, will always result in a FATAL error */ public function count() { $this->error(); } /** * Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error */ public function getIterator() { $this->error(); } }