123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?php
- namespace Elgg;
- class DeprecationWrapper implements \ArrayAccess {
-
- protected $object;
-
- protected $string;
-
- protected $message;
-
- protected $version;
-
- protected $reporter;
-
- public function __construct($object, $message, $version, $reporter = 'elgg_deprecated_notice') {
- if (is_object($object)) {
- $this->object = $object;
- } else {
- $this->string = $object;
- }
- $this->message = $message;
- $this->version = $version;
- $this->reporter = $reporter;
- }
-
- public function __get($name) {
- $this->displayWarning();
- return $this->object->$name;
- }
-
- public function __set($name, $value) {
- $this->displayWarning();
- $this->object->$name = $value;
- }
-
- public function __call($name, $arguments) {
- $this->displayWarning();
- return call_user_func_array(array($this->object, $name), $arguments);
- }
-
- public function __toString() {
- $this->displayWarning();
- if (isset($this->string)) {
- return $this->string;
- } else {
- return (string) $this->object;
- }
- }
-
- protected function displayWarning() {
-
-
-
-
- call_user_func($this->reporter, $this->message, $this->version, 3);
- }
-
- public function offsetSet($key, $value) {
- $this->displayWarning();
- if (is_object($this->object) && !$this->object instanceof \ArrayAccess) {
- $this->object->$key = $value;
- } else {
- if ($key === null) {
-
- $this->object[] = $value;
- } else {
- $this->object[$key] = $value;
- }
- }
- }
-
- public function offsetGet($key) {
- $this->displayWarning();
- if (is_object($this->object) && !$this->object instanceof \ArrayAccess) {
- return $this->object->$key;
- } else {
- return $this->object[$key];
- }
- }
-
- public function offsetUnset($key) {
- $this->displayWarning();
- if (is_object($this->object) && !$this->object instanceof \ArrayAccess) {
- unset($this->object->$key);
- } else {
- unset($this->object[$key]);
- }
- }
-
- public function offsetExists($offset) {
- $this->displayWarning();
- if (is_object($this->object) && !$this->object instanceof \ArrayAccess) {
- return isset($this->object->$offset);
- } else {
- return array_key_exists($offset, $this->object);
- }
- }
- }
|