mirror of
https://github.com/dg/dibi.git
synced 2025-07-08 00:04:32 +02:00
DibiLazyStorage: allows empty string as property name for reading
This commit is contained in:
@ -544,7 +544,7 @@ class DibiColumnInfo extends DibiObject
|
|||||||
if (self::$types === NULL) {
|
if (self::$types === NULL) {
|
||||||
self::$types = new DibiLazyStorage(array(__CLASS__, 'detectType'));
|
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
|
final class DibiLazyStorage extends DibiLazyStorageBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __set($nm, $val)
|
||||||
|
{
|
||||||
|
if ($nm == '') {
|
||||||
|
$nm = "\xFF";
|
||||||
|
}
|
||||||
|
$this->$nm = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __get($nm)
|
public function __get($nm)
|
||||||
{
|
{
|
||||||
if (is_array($nm)) { // preg_replace_callback support
|
|
||||||
$nm = $nm[1];
|
|
||||||
}
|
|
||||||
if ($nm == '') {
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user