diff --git a/src/Model.php b/src/Model.php index 083d7619..bbe31b88 100644 --- a/src/Model.php +++ b/src/Model.php @@ -452,7 +452,7 @@ protected function validateAndFilterData(bool $isUpdate): array } elseif ($isUpdate && !$this->isForce() && $this->isNotRequireUpdate($name, $val, $origin)) { unset($data[$name]); } else { - $val = $this->setWithAttr($name, $val); + $val = $this->setAttrOfWith($name, $val); } } @@ -788,7 +788,7 @@ public function __get(string $name) */ public function __set(string $name, $value): void { - if ($value instanceof Modelable && $bind = $this->getBindAttr($this->getOption('bindAttr'), $name)) { + if ($value instanceof Modelable && $bind = $this->getAttrOfBind($this->getOption('bindAttr'), $name)) { // 关联属性绑定 $this->bindRelationAttr($value, $bind); } else { diff --git a/src/model/View.php b/src/model/View.php index 2a48d4d2..08606810 100644 --- a/src/model/View.php +++ b/src/model/View.php @@ -62,7 +62,7 @@ protected function initData(bool $with = false) $this->$field = $this->fetchViewAttr($field, $data, $with); } elseif (strpos($field, '->')) { // 关联属性或JSON字段映射 - $this->$key = $this->getRelationMapAttr($field, $data); + $this->$key = $this->getAttrOfRelationMap($field, $data); } else { // 主模型属性映射 $this->$key = $this->fetchViewAttr($field, $data, $with); @@ -80,7 +80,7 @@ protected function initData(bool $with = false) * * @return mixed */ - private function getRelationMapAttr(string $field, array $data) + private function getAttrOfRelationMap(string $field, array $data) { $items = explode('->', $field); $relation = array_shift($items); diff --git a/src/model/concern/Attribute.php b/src/model/concern/Attribute.php index 5b6574d6..7edb2796 100644 --- a/src/model/concern/Attribute.php +++ b/src/model/concern/Attribute.php @@ -516,7 +516,7 @@ protected function hasGetAttr(string $name): bool * * @return mixed */ - private function setWithAttr(string $name, $value) + private function setAttrOfWith(string $name, $value) { $attr = Str::studly($name); $method = 'set' . $attr . 'Attr'; @@ -572,7 +572,7 @@ public function get(string $name, bool $attr = true) if ($attr) { // 通过获取器输出 - $value = $this->getWithAttr($name, $value, $this->getData()); + $value = $this->getAttrOfWith($name, $value, $this->getData()); $this->setWeakData('get', $name, $value); } @@ -601,7 +601,7 @@ protected function getMappingName(string $name): string * * @return mixed */ - private function getWithAttr(string $name, $value, array $data = []) + private function getAttrOfWith(string $name, $value, array $data = []) { $attr = Str::studly($name); $method = 'get' . $attr . 'Attr'; diff --git a/src/model/concern/AutoWriteData.php b/src/model/concern/AutoWriteData.php index c1d100de..bc2776d6 100644 --- a/src/model/concern/AutoWriteData.php +++ b/src/model/concern/AutoWriteData.php @@ -46,7 +46,7 @@ protected function autoWriteData(array &$data, bool $update, array $allow = []) if ($val instanceof Closure) { $value = $val($this); } else { - $value = is_string($name) ? $val : $this->setWithAttr($field, null, $data); + $value = is_string($name) ? $val : $this->setAttrOfWith($field, null); } $data[$field] = $value; $this->setData($field, $value); diff --git a/src/model/concern/Conversion.php b/src/model/concern/Conversion.php index aab48c97..05b40f0c 100644 --- a/src/model/concern/Conversion.php +++ b/src/model/concern/Conversion.php @@ -135,7 +135,7 @@ public function toArray(): array $item[$name] = $val->toArray(); } elseif (empty($allow) || in_array($name, $allow)) { // 通过获取器输出 - $item[$name] = $this->getWithAttr($name, $val, $data); + $item[$name] = $this->getAttrOfWith($name, $val, $data); } if (array_key_exists($name, $item) && isset($mapping[$name])) { diff --git a/src/model/concern/RelationShip.php b/src/model/concern/RelationShip.php index 7eb4a27c..8928dac6 100644 --- a/src/model/concern/RelationShip.php +++ b/src/model/concern/RelationShip.php @@ -63,7 +63,7 @@ private function parseRelationData(array $relations) foreach ($relations as $relation => $val) { $relation = $this->getRealFieldName($relation); $type = $this->getFields($relation); - $bind = $this->getBindAttr($this->getOption('bindAttr'), $relation); + $bind = $this->getAttrOfBind($this->getOption('bindAttr'), $relation); if (!empty($bind)) { // 绑定关联属性 $this->bindRelationAttr($val, $bind, $relation); @@ -216,7 +216,7 @@ public function hasRelation(string $name) return false; } - protected function getBindAttr($bind, $name) + protected function getAttrOfBind($bind, $name) { return $bind[$name] ?? []; }