Merge "Typo fix"
[mediawiki.git] / includes / DeprecatedGlobal.php
blobd48bd0b0ca2502a4aa8d23d155da952047b513a8
1 <?php
2 /**
3 * Delayed loading of deprecated global objects.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
23 /**
24 * Class to allow throwing wfDeprecated warnings
25 * when people use globals that we do not want them to.
26 * (For example like $wgArticle)
29 class DeprecatedGlobal extends StubObject {
30 // The m's are to stay consistent with parent class.
31 protected $mRealValue, $mVersion;
33 function __construct( $name, $realValue, $version = false ) {
34 parent::__construct( $name );
35 $this->mRealValue = $realValue;
36 $this->mVersion = $version;
39 function _newObject() {
40 /* Put the caller offset for wfDeprecated as 6, as
41 * that gives the function that uses this object, since:
42 * 1 = this function ( _newObject )
43 * 2 = StubObject::_unstub
44 * 3 = StubObject::_call
45 * 4 = StubObject::__call
46 * 5 = DeprecatedGlobal::<method of global called>
47 * 6 = Actual function using the global.
48 * Of course its theoretically possible to have other call
49 * sequences for this method, but that seems to be
50 * rather unlikely.
52 wfDeprecated( '$' . $this->mGlobal, $this->mVersion, false, 6 );
53 return $this->mRealValue;