P粉4474950692023-09-02 12:10:35
您需要创建一个名为Site的额外类,并返回一个对象数组。
class Site { private int $siteId; private string $name; private string $bone; /** * @param int $siteId * @param string $name * @param string $bone */ public function __construct(int $siteId, string $name, string $bone) { $this->siteId = $siteId; $this->name = $name; $this->bone = $bone; } /** * @return int */ public function getSiteId(): int { return $this->siteId; } /** * @param int $siteId */ public function setSiteId(int $siteId): void { $this->siteId = $siteId; } /** * @return string */ public function getName(): string { return $this->name; } /** * @param string $name */ public function setName(string $name): void { $this->name = $name; } /** * @return string */ public function getBone(): string { return $this->bone; } /** * @param string $bone */ public function setBone(string $bone): void { $this->bone = $bone; } }
然后返回站点数组:
return [ (new Site(1, '开罗', 'T-Rex骨骼')), (new Site(2, '吉萨', '迅猛龙骨骼')), (new Site(3, '亚历山大', '腕龙骨骼')) ];