Rename class Attribute to PLAAttribute.
As PHP 8 introduces a built-in Attribute class, a name clash occurs without this commit. Class names are used by the Visitor class to dynamically build method names. To avoid having to also rename the target methods, a class name mapping is introduced for this purpose. This map may be augmented whenever another similar case occurs.
This commit is contained in:
parent
3a75a32100
commit
c90dc06af2
@ -133,7 +133,7 @@ class AttributeFactory {
|
||||
return $this->newGidAttribute($name,$values,$server_id,$source);
|
||||
|
||||
} else {
|
||||
return new Attribute($name,$values,$server_id,$source);
|
||||
return new PLAAttribute($name,$values,$server_id,$source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class BinaryAttribute extends Attribute {
|
||||
class BinaryAttribute extends PLAAttribute {
|
||||
protected $filepaths;
|
||||
protected $filenames;
|
||||
|
||||
|
@ -12,6 +12,6 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class DateAttribute extends Attribute {
|
||||
class DateAttribute extends PLAAttribute {
|
||||
}
|
||||
?>
|
||||
|
@ -12,6 +12,6 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class DnAttribute extends Attribute {
|
||||
class DnAttribute extends PLAAttribute {
|
||||
}
|
||||
?>
|
||||
|
@ -12,6 +12,6 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class GidAttribute extends Attribute {
|
||||
class GidAttribute extends PLAAttribute {
|
||||
}
|
||||
?>
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class MultiLineAttribute extends Attribute {
|
||||
class MultiLineAttribute extends PLAAttribute {
|
||||
protected $rows = 0;
|
||||
protected $cols = 0;
|
||||
|
||||
|
@ -12,6 +12,6 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class ObjectClassAttribute extends Attribute {
|
||||
class ObjectClassAttribute extends PLAAttribute {
|
||||
}
|
||||
?>
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class Attribute {
|
||||
class PLAAttribute {
|
||||
# Attribute Name
|
||||
public $name;
|
||||
# Source of this attribute definition
|
@ -12,6 +12,6 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class PasswordAttribute extends Attribute {
|
||||
class PasswordAttribute extends PLAAttribute {
|
||||
}
|
||||
?>
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class SelectionAttribute extends Attribute {
|
||||
class SelectionAttribute extends PLAAttribute {
|
||||
protected $selection = array();
|
||||
protected $multiple;
|
||||
protected $default;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @package phpLDAPadmin
|
||||
* @subpackage Templates
|
||||
*/
|
||||
class ShadowAttribute extends Attribute {
|
||||
class ShadowAttribute extends PLAAttribute {
|
||||
public $shadow_before_today_attrs = array('shadowLastChange','shadowMin');
|
||||
public $shadow_after_today_attrs = array('shadowMax','shadowExpire','shadowWarning','shadowInactive');
|
||||
}
|
||||
|
@ -22,6 +22,15 @@ abstract class Visitor {
|
||||
protected $server_id;
|
||||
|
||||
public function __call($method,$args) {
|
||||
# This mapping array allows to map effective class names to
|
||||
# function name suffixes.
|
||||
# It has been introduced when class Attribute has been renamed
|
||||
# to PLAAttribute to avoid a name clash with the built-in
|
||||
# class of PHP 8.
|
||||
# Entering a class name mapping here allows to rename the
|
||||
# class without having to rename the methods too.
|
||||
static $classmap = array('PLAAttribute' => 'Attribute');
|
||||
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
@ -33,19 +42,14 @@ abstract class Visitor {
|
||||
$fnct = array_shift($args);
|
||||
|
||||
$object = $args[0];
|
||||
$class = get_class($object);
|
||||
|
||||
$call = "$method$fnct$class";
|
||||
|
||||
for ($class = get_class($object); $class; $class = get_parent_class($class)) {
|
||||
$call = isset($classmap[$class])? "$method$fnct$classmap[$class]": "$method$fnct$class";
|
||||
array_push($methods,$call);
|
||||
|
||||
while ($class && ! method_exists($this,$call)) {
|
||||
if (method_exists($this,$call))
|
||||
break;
|
||||
if (defined('DEBUGTMP') && DEBUGTMP)
|
||||
printf('<font size=-2><i>Class (%s): Method doesnt exist (%s,%s)</i></font><br />',$class,get_class($this),$call);
|
||||
|
||||
$class = get_parent_class($class);
|
||||
$call = "$method$fnct$class";
|
||||
array_push($methods,$call);
|
||||
}
|
||||
|
||||
if (defined('DEBUGTMP') && DEBUGTMP)
|
||||
|
Loading…
Reference in New Issue
Block a user