This commit is contained in:
2026-04-21 14:59:51 +08:00
parent 9c6340d0b3
commit 0abc7c32f7
+11 -6
View File
@@ -299,7 +299,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
protected static function instance(): static
{
return new static();
return new static;
}
@@ -590,7 +590,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
private function resolve(array $rule): Validator
{
$validate = new Validator();
$validate = new Validator;
foreach ($rule as $val) {
$field = array_shift($val);
if (is_string($field)) {
@@ -728,11 +728,16 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
public function __get(string $name): mixed
{
if (isset($this->_attributes[$name])) {
$value = $this->_attributes[$name] ?? NULL;
if (!method_exists($this, 'get' . ucfirst($name))) {
return $this->withPropertyOverride($name, $value);
} else if (isset($this->_oldAttributes[$name])) {
$value = $this->_oldAttributes[$name] ?? NULL;
return $this->withPropertyOverride($name, $value);
} else {
return $this->withRelate($name);
return parent::__get($name);
}
}
@@ -868,7 +873,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
public static function populate(array $data): static
{
$model = new static();
$model = new static;
$model->_attributes = $data;
$model->_oldAttributes = $data;
$model->setIsNowExample();
@@ -884,7 +889,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
*/
public static function __callStatic(string $name, array $arguments)
{
return (new static())->{$name}(...$arguments);
return (new static)->{$name}(...$arguments);
}