[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> StubObject.php (summary)

Delayed loading of global objects. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 187 lines (6 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

StubObject:: (7 methods):
  __construct()
  isRealObject()
  unstub()
  _call()
  _newObject()
  __call()
  _unstub()

StubUserLang:: (3 methods):
  __construct()
  __call()
  _newObject()


Class: StubObject  - X-Ref

Class to implement stub globals, which are globals that delay loading the
their associated module code by deferring initialisation until the first
method call.

Note on reference parameters:

If the called method takes any parameters by reference, the __call magic
here won't work correctly. The solution is to unstub the object before
calling the method.

Note on unstub loops:

Unstub loops (infinite recursion) sometimes occur when a constructor calls
another function, and the other function calls some method of the stub. The
best way to avoid this is to make constructors as lightweight as possible,
deferring any initialisation which depends on other modules. As a last
resort, you can use StubObject::isRealObject() to break the loop, but as a
general rule, the stub object mechanism should be transparent, and code
which refers to it should be kept to a minimum.
__construct( $global = null, $class = null, $params = array()   X-Ref
Constructor.

param: string $global Name of the global variable.
param: string $class Name of the class of the real object.
param: array $params Parameters to pass to constructor of the real object.

isRealObject( $obj )   X-Ref
Returns a bool value whenever $obj is a stub object. Can be used to break
a infinite loop when unstubbing an object.

param: object $obj Object to check.
return: bool True if $obj is not an instance of StubObject class.

unstub( &$obj )   X-Ref
Unstubs an object, if it is a stub object. Can be used to break a
infinite loop when unstubbing an object or to avoid reference parameter
breakage.

param: object $obj Object to check.
return: void

_call( $name, $args )   X-Ref
Function called if any function exists with that name in this object.
It is used to unstub the object. Only used internally, PHP will call
self::__call() function and that function will call this function.
This function will also call the function with the same name in the real
object.

param: string $name Name of the function called
param: array $args Arguments
return: mixed

_newObject()   X-Ref
Create a new object to replace this stub object.

return: object

__call( $name, $args )   X-Ref
Function called by PHP if no function with that name exists in this
object.

param: string $name Name of the function called
param: array $args Arguments
return: mixed

_unstub( $name = '_unstub', $level = 2 )   X-Ref
This function creates a new object of the real class and replace it in
the global variable.
This is public, for the convenience of external callers wishing to access
properties, e.g. eval.php

param: string $name Name of the method called in this object.
param: int $level Level to go in the stack trace to get the function
return: object The unstubbed version of itself

Class: StubUserLang  - X-Ref

Stub object for the user language. It depends of the user preferences and
"uselang" parameter that can be passed to index.php. This object have to be
in $wgLang global.

__construct()   X-Ref
No description

__call( $name, $args )   X-Ref
No description

_newObject()   X-Ref

return: Language



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1