]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/DeprecatedGlobal.php
MediaWiki 1.30.2-scripts2
[autoinstalls/mediawiki.git] / includes / DeprecatedGlobal.php
1 <?php
2 /**
3  * Delayed loading of deprecated global objects.
4  *
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.
9  *
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.
14  *
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
19  *
20  * @file
21  */
22
23 /**
24  * Class to allow throwing wfDeprecated warnings
25  * when people use globals that we do not want them to.
26  */
27 class DeprecatedGlobal extends StubObject {
28         protected $version;
29
30         /**
31          * @param string $name Global name
32          * @param callable|string $callback Factory function or class name to construct
33          * @param bool|string $version Version global was deprecated in
34          */
35         function __construct( $name, $callback, $version = false ) {
36                 parent::__construct( $name, $callback );
37                 $this->version = $version;
38         }
39
40         // @codingStandardsIgnoreStart
41         // PSR2.Methods.MethodDeclaration.Underscore
42         // PSR2.Classes.PropertyDeclaration.ScopeMissing
43         function _newObject() {
44                 /* Put the caller offset for wfDeprecated as 6, as
45                  * that gives the function that uses this object, since:
46                  * 1 = this function ( _newObject )
47                  * 2 = StubObject::_unstub
48                  * 3 = StubObject::_call
49                  * 4 = StubObject::__call
50                  * 5 = DeprecatedGlobal::<method of global called>
51                  * 6 = Actual function using the global.
52                  * Of course its theoretically possible to have other call
53                  * sequences for this method, but that seems to be
54                  * rather unlikely.
55                  */
56                 wfDeprecated( '$' . $this->global, $this->version, false, 6 );
57                 return parent::_newObject();
58         }
59         // @codingStandardsIgnoreEnd
60 }