MediaWiki master
DeprecatedGlobal.php
Go to the documentation of this file.
1<?php
24
31 protected $version;
32
38 public function __construct( $name, $callback, $version = false ) {
39 parent::__construct( $name, $callback );
40 $this->version = $version;
41 }
42
43 // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
44 public function _newObject() {
45 /*
46 * Put the caller offset for wfDeprecated as 6, as
47 * that gives the function that uses this object, since:
48 *
49 * 1 = this function ( _newObject )
50 * 2 = MediaWiki\StubObject\StubObject::_unstub
51 * 3 = MediaWiki\StubObject\StubObject::_call
52 * 4 = MediaWiki\StubObject\StubObject::__call
53 * 5 = MediaWiki\StubObject\DeprecatedGlobal::<method of global called>
54 * 6 = Actual function using the global.
55 * (the same applies to _get/__get or _set/__set instead of _call/__call)
56 *
57 * Of course its theoretically possible to have other call
58 * sequences for this method, but that seems to be
59 * rather unlikely.
60 */
61 wfDeprecated( '$' . $this->global, $this->version, false, 6 );
62 return parent::_newObject();
63 }
64}
65
67class_alias( DeprecatedGlobal::class, 'DeprecatedGlobal' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Class to allow throwing wfDeprecated warnings when people use globals that we do not want them to.
__construct( $name, $callback, $version=false)
_newObject()
Create a new object to replace this stub object.
Class to implement stub globals, which are globals that delay loading the their associated module cod...