26use Wikimedia\ObjectFactory\ObjectFactory;
74 if ( is_callable(
$class ) ) {
90 return is_object( $obj ) && !$obj instanceof
self;
102 if ( $obj instanceof
self ) {
103 $obj = $obj->_unstub(
'unstub', 3 );
120 return call_user_func_array( [ $GLOBALS[$this->global], $name ],
$args );
134 return ObjectFactory::getObjectFromSpec(
$params + [
135 'args' => $this->params,
136 'closure_expansion' =>
false,
158 public function _get( $name ) {
159 $this->
_unstub(
"__get($name)", 5 );
171 return $this->
_get( $name );
180 public function _set( $name, $value ) {
181 $this->
_unstub(
"__set($name)", 5 );
192 public function __set( $name, $value ) {
193 $this->
_set( $name, $value );
208 public function _unstub( $name =
'_unstub', $level = 2 ) {
209 static $recursionLevel = 0;
211 if ( !$GLOBALS[$this->global] instanceof
self ) {
215 if ( get_class( $GLOBALS[$this->global] ) != $this->
class ) {
217 if ( ++$recursionLevel > 2 ) {
218 throw new MWException(
"Unstub loop detected on call of "
219 .
"\${$this->global}->$name from $caller\n" );
221 wfDebug(
"Unstubbing \${$this->global} on call of "
222 .
"\${$this->global}::$name from $caller" );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Class to implement stub globals, which are globals that delay loading the their associated module cod...
_unstub( $name='_unstub', $level=2)
This function creates a new object of the real class and replace it in the global variable.
_set( $name, $value)
Wrapper for __set(), similar to _call() above.
_call( $name, $args)
Function called if any function exists with that name in this object.
_get( $name)
Wrapper for __get(), similar to _call() above.
static unstub(&$obj)
Unstubs an object, if it is a stub object.
_newObject()
Create a new object to replace this stub object.
__construct( $global=null, $class=null, $params=[])
__call( $name, $args)
Function called by PHP if no function with that name exists in this object.
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
__set( $name, $value)
Function called by PHP if no property with that name exists in this object.
__get( $name)
Function called by PHP if no property with that name exists in this object.