改进Model类的readTransform和writeTransform方法

This commit is contained in:
thinkphp
2017-03-27 17:56:11 +08:00
parent f9cfb6ef3b
commit f0aaa7290c

View File

@@ -367,6 +367,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/
protected function writeTransform($value, $type)
{
if (is_null($value)) {
return null;
}
if (is_array($type)) {
list($type, $param) = $type;
} elseif (strpos($type, ':')) {
@@ -475,6 +479,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/
protected function readTransform($value, $type)
{
if (is_null($value)) {
return null;
}
if (is_array($type)) {
list($type, $param) = $type;
} elseif (strpos($type, ':')) {