MediaWiki master
|
Classes | |
class | DeprecatablePropertyArray |
ArrayAccess with support for deprecating access to certain offsets. More... | |
class | MWDebug |
Debug toolbar. More... | |
Functions | |
__get ( $name) | |
__isset ( $name) | |
__set ( $name, $value) | |
deprecateDynamicPropertiesAccess (string $version, ?string $class=null, ?string $component=null) | |
Emit deprecation warnings when dynamic and unknown properties are accessed. | |
deprecatePublicProperty ( $property, $version, $class=null, $component=null) | |
Mark a property as deprecated. | |
deprecatePublicPropertyFallback (string $property, string $version, $getter, $setter=null, $class=null, $component=null) | |
Mark a removed public property as deprecated and provide fallback getter and setter callables. | |
Variables | |
trait | DeprecationHelper |
Trait for issuing warnings on deprecated access. | |
MediaWiki\Debug\__get | ( | $name | ) |
Definition at line 198 of file DeprecationHelper.php.
References wfDeprecated().
MediaWiki\Debug\__isset | ( | $name | ) |
Definition at line 170 of file DeprecationHelper.php.
References wfDeprecated().
MediaWiki\Debug\__set | ( | $name, | |
$value ) |
Definition at line 234 of file DeprecationHelper.php.
References wfDeprecated().
|
protected |
Emit deprecation warnings when dynamic and unknown properties are accessed.
string | $version | MediaWiki version where the property became deprecated. |
string | null | $class | The class which has the deprecated property. |
string | null | $component |
Definition at line 162 of file DeprecationHelper.php.
|
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 99 of file DeprecationHelper.php.
|
protected |
Mark a removed public property as deprecated and provide fallback getter and setter callables.
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. |
callable | string | $getter | A user provided getter that implements a get logic for the property. If a string is given, it is called as a method on $this. |
callable | string | null | $setter | A user provided setter that implements a set logic for the property. If a string is given, it is called as a method on $this. |
string | null | $class | The class which has the deprecated property. |
string | null | $component |
Definition at line 133 of file DeprecationHelper.php.
trait MediaWiki::Debug\DeprecationHelper |
Trait for issuing warnings on deprecated access.
Use this trait in classes which have properties for which public access is deprecated or implementation has been moved to another class. 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 ); $this->deprecatePublicPropertyFallback( 'movedValue', '1.35', function () { return MediaWikiServices()::getInstance() ->getNewImplementationService()->getValue(); }, function ( $value ) { MediaWikiServices()::getInstance() ->getNewImplementationService()->setValue( $value ); } ); } }
$foo = new Foo; $foo->bar; // works but logs a warning $foo->movedValue = 10; // works but logs a warning $movedValue = $foo->movedValue; // also works
Cannot be used with classes that have their own __get/__set methods.
Definition at line 65 of file DeprecationHelper.php.