mirror of
https://github.com/dg/dibi.git
synced 2025-02-23 10:26:21 +01:00
DibiLazyStorage: allows empty string as property name for reading
This commit is contained in:
parent
325305326b
commit
79735e96d1
@ -544,7 +544,7 @@ class DibiColumnInfo extends DibiObject
|
||||
if (self::$types === NULL) {
|
||||
self::$types = new DibiLazyStorage(array(__CLASS__, 'detectType'));
|
||||
}
|
||||
return $this->info['nativetype'] ? self::$types->{$this->info['nativetype']} : dibi::TEXT;
|
||||
return self::$types->{$this->info['nativetype']};
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,15 +54,24 @@ abstract class DibiLazyStorageBase
|
||||
final class DibiLazyStorage extends DibiLazyStorageBase
|
||||
{
|
||||
|
||||
public function __set($nm, $val)
|
||||
{
|
||||
if ($nm == '') {
|
||||
$nm = "\xFF";
|
||||
}
|
||||
$this->$nm = $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __get($nm)
|
||||
{
|
||||
if (is_array($nm)) { // preg_replace_callback support
|
||||
$nm = $nm[1];
|
||||
}
|
||||
if ($nm == '') {
|
||||
throw new InvalidStateException('Missing identifier name.');
|
||||
$nm = "\xFF";
|
||||
return isset($this->$nm) ? $this->$nm : $this->$nm = call_user_func($this->getCallback(), '');
|
||||
} else {
|
||||
return $this->$nm = call_user_func($this->getCallback(), $nm);
|
||||
}
|
||||
return $this->$nm = call_user_func($this->getCallback(), $nm);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user