Skip to content

Commit 2fdccce

Browse files
committed
Add magic getter and magic setter for backward compatibility and to fit with WP_Object_Cache behavior.
1 parent b763a0d commit 2fdccce

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drop-in.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ public static function instance(): self {
116116
return self::$instance;
117117
}
118118

119+
/**
120+
* Makes private properties readable for backward compatibility.
121+
*
122+
* @see WP_Object_Cache::__get()
123+
*
124+
* @since 0.1.0
125+
*
126+
* @param string $name Property to get.
127+
* @return mixed Property.
128+
*/
129+
public function __get( $name ) { // phpcs:ignore NeutronStandard.MagicMethods.DisallowMagicGet.MagicGet
130+
return $this->$name;
131+
}
132+
133+
/**
134+
* Makes private properties settable for backward compatibility.
135+
*
136+
* @see WP_Object_Cache::__set()
137+
*
138+
* @since 0.1.0
139+
*
140+
* @param string $name Property to set.
141+
* @param mixed $value Property value.
142+
* @return mixed Newly-set property.
143+
*/
144+
public function __set( $name, $value ) { // phpcs:ignore NeutronStandard.MagicMethods.DisallowMagicSet.MagicSet
145+
$this->$name = $value;
146+
147+
return $this->$name;
148+
}
149+
119150
/**
120151
* Adds data to the cache if it doesn't already exist.
121152
*

0 commit comments

Comments
 (0)