MediaWiki REL1_32
|
Trait for issuing warnings on deprecated access. More...
Go to the source code of this file.
Functions | |
__get ( $name) | |
__set ( $name, $value) | |
deprecatePublicProperty ( $property, $version, $class=null, $component=null) | |
Mark a property as deprecated. | |
deprecationHelperGetPropertyOwner ( $property) | |
Like property_exists but also check for non-visible private properties and returns which class in the inheritance chain declared the property. | |
Variables | |
trait | DeprecationHelper |
Use this trait in classes which have properties for which public access is deprecated. | |
Trait for issuing warnings on deprecated access.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html
Definition in file DeprecationHelper.php.
__get | ( | $name | ) |
Definition at line 74 of file DeprecationHelper.php.
References $name, deprecationHelperGetPropertyOwner(), list, and wfDeprecated().
__set | ( | $name, | |
$value | |||
) |
Definition at line 93 of file DeprecationHelper.php.
References $name, $value, deprecationHelperGetPropertyOwner(), list, and wfDeprecated().
|
protected |
Mark a property as deprecated.
Only use this for properties that used to be public and only call it in the constructor.
string | $property | The name of the property. |
string | $version | MediaWiki version where the property became deprecated. |
string | null | $class | The class which has the deprecated property. This can usually be guessed, but PHP can get confused when both the parent class and the subclass use the trait, so it should be specified in classes meant for subclassing. |
string | null | $component |
Definition at line 68 of file DeprecationHelper.php.
References $property.
Referenced by DifferenceEngine\__construct().
|
private |
Like property_exists but also check for non-visible private properties and returns which class in the inheritance chain declared the property.
string | $property |
Definition at line 118 of file DeprecationHelper.php.
trait DeprecationHelper |
Use this trait in classes which have properties for which public access is deprecated.
Set the list of properties in $deprecatedPublicProperties and make the properties non-public. The trait will preserve public access but issue deprecation warnings when it is needed.
Example usage: class Foo { use DeprecationHelper; protected $bar; public function construct() { $this->deprecatePublicProperty( 'bar', '1.21', __CLASS ); } }
$foo = new Foo; $foo->bar; // works but logs a warning
Cannot be used with classes that have their own __get/__set methods.
Definition at line 45 of file DeprecationHelper.php.