MediaWiki master
MediaWiki\Debug Namespace Reference

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.
 

Function Documentation

◆ __get()

MediaWiki\Debug\__get ( $name)

Definition at line 198 of file DeprecationHelper.php.

References wfDeprecated().

◆ __isset()

MediaWiki\Debug\__isset ( $name)

Definition at line 170 of file DeprecationHelper.php.

References wfDeprecated().

◆ __set()

MediaWiki\Debug\__set ( $name,
$value )

Definition at line 234 of file DeprecationHelper.php.

References wfDeprecated().

◆ deprecateDynamicPropertiesAccess()

MediaWiki\Debug\deprecateDynamicPropertiesAccess ( string $version,
string $class = null,
string $component = null )
protected

Emit deprecation warnings when dynamic and unknown properties are accessed.

Parameters
string$versionMediaWiki version where the property became deprecated.
string | null$classThe class which has the deprecated property.
string | null$component

Definition at line 162 of file DeprecationHelper.php.

◆ deprecatePublicProperty()

MediaWiki\Debug\deprecatePublicProperty ( $property,
$version,
$class = null,
$component = null )
protected

Mark a property as deprecated.

Only use this for properties that used to be public and only call it in the constructor.

Note
Providing callbacks makes it not serializable
Parameters
string$propertyThe name of the property.
string$versionMediaWiki version where the property became deprecated.
string | null$classThe 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
See also
wfDeprecated()

Definition at line 99 of file DeprecationHelper.php.

◆ deprecatePublicPropertyFallback()

MediaWiki\Debug\deprecatePublicPropertyFallback ( string $property,
string $version,
$getter,
$setter = null,
$class = null,
$component = null )
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.

Parameters
string$propertyThe name of the property.
string$versionMediaWiki version where the property became deprecated.
callable | string$getterA 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$setterA 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$classThe class which has the deprecated property.
string | null$component
Since
1.36
See also
wfDeprecated()

Definition at line 133 of file DeprecationHelper.php.

Variable Documentation

◆ DeprecationHelper

trait MediaWiki::Debug\DeprecationHelper
Initial value:
{
protected static string[][] $deprecatedPublicProperties = []

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.

Since
1.32

Definition at line 65 of file DeprecationHelper.php.