toArray中前面是哪两个foreach我们不需要管,基本上不会干扰到我们整个利用链,我们把注意力放到对$this->append的遍历上,结合poc我们知道this->append的值为["axin"=>["calc.exe","calc"]],所以$key为axin,$name为["calc.exe","calc"],那么就会进入第一个if分支,跟进getRelation
public function getRelation($name = null){ if (is_null($name)) { return $this->relation; } elseif (array_key_exists($name, $this->relation)) { return $this->relation[$name]; } return;}反正最后的结果就是返回null了,也就是$relation为null,接着$key进入了getAttr(),跟进:
public function getAttr($name, &$item = null) { try { $notFound = false; $value = $this->getData($name); } catch (InvalidArgumentException $e) { $notFound = true; $value = null; } // 检测属性获取器 $fieldName = Loader::parseName($name); $method = 'get' . Loader::parseName($name, 1) . 'Attr'; if (isset($this->withAttr[$fieldName])) { if ($notFound && $relation = $this->isRelationAttr($name)) { $modelRelation = $this->$relation(); $value = $this->getRelationData($modelRelation); } $closure = $this->withAttr[$fieldName]; $value = $closure($value, $this->data); } elseif (method_exists($this, $method)) { if ($notFound && $relation = $this->isRelationAttr($name)) { $modelRelation = $this->$relation(); $value = $this->getRelationData($modelRelation); } $value = $this->$method($value, $this->data); } elseif (isset($this->type[$name])) { // 类型转换 $value = $this->readTransform($value, $this->type[$name]); } elseif ($this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { if (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), [ 'datetime', 'date', 'timestamp', ])) { $value = $this->formatDateTime($this->dateFormat, $value); } else { $value = $this->formatDateTime($this->dateFormat, $value, true); } } elseif ($notFound) { $value = $this->getRelationAttribute($name, $item); } return $value; }
推荐阅读
- 《金铲铲之战》黎明最强阵容是什么?
- 古茶树不能承受之重,古曼撒之冷庙古树茶
- 工夫红茶是什么意思,功夫红茶与工夫红茶字之差
- 父亲节走心茶礼,厨心熟茶品质口碑和品牌之路
- 广州旅游攻略之必去景点
- 高桥银峰的作用有哪些,高桥银峰营养成分分析
- 十大名菜之首 抗癌防癌并有“富硒食品”之称
- 凤宁号茶叶加盟信息,佛山市南海区春之茗茶叶加盟八方茶园
- 贡眉是福鼎白茶之,福鼎大白与福鼎大毫的关系
- 各用沏茶用水知识解说,沏茶用水之软水
