Completed
Branch master (4b8315)
by
unknown
17:52
created

includes/DeprecatedGlobal.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
28
class DeprecatedGlobal extends StubObject {
29
	protected $realValue, $version;
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
30
31
	function __construct( $name, $realValue, $version = false ) {
32
		parent::__construct( $name );
33
		$this->realValue = $realValue;
34
		$this->version = $version;
35
	}
36
37
	// @codingStandardsIgnoreStart
38
	// PSR2.Methods.MethodDeclaration.Underscore
39
	// PSR2.Classes.PropertyDeclaration.ScopeMissing
40
	function _newObject() {
41
42
		/* Put the caller offset for wfDeprecated as 6, as
43
		 * that gives the function that uses this object, since:
44
		 * 1 = this function ( _newObject )
45
		 * 2 = StubObject::_unstub
46
		 * 3 = StubObject::_call
47
		 * 4 = StubObject::__call
48
		 * 5 = DeprecatedGlobal::<method of global called>
49
		 * 6 = Actual function using the global.
50
		 * Of course its theoretically possible to have other call
51
		 * sequences for this method, but that seems to be
52
		 * rather unlikely.
53
		 */
54
		wfDeprecated( '$' . $this->global, $this->version, false, 6 );
55
		return $this->realValue;
56
	}
57
	// @codingStandardsIgnoreEnd
58
}
59