我正嘗試將我的網站移至Hack和XHP,當然。下面是什麼代碼結構的結構,我想實現:獲取XHPChild的子女
<ui:backstageHeader>
<ui:backstageHeader-navItem href="/">stories</ui:backstageHeader-navItem>
<ui:backstageHeader-navItem href="/story/send">send a story</ui:backstageHeader-navItem>
<ui:backstageHeader-navItem href="/aboutus">support</ui:backstageHeader-navItem>
</ui:backstageHeader>
(注::ui:backstageHeader-navItem
基本上呈現到<a href={$this->:href}>{$this->getCHildren}</a>
,所以沒有必要在這裏附上它的類。)
下面是代碼爲:ui:backstageHeader
:
final class :ui:backstageHeader extends :ui:base {
attribute :div;
children (:ui:backstageHeader-navItem)*;
protected function compose() {
$dom =
<section class="backstage-header">
<div class="container">
<div class="cell-logo">
<a href="/">
<span class="no23-logo-white"></span>
</a>
</div>
<div class="cell-navigation">
</div>
<div class="cell-account">
<div class="cell-login">
<div id="siteNav-login">Autentificare</div>
</div>
</div>
</div>
</section>;
$mainContainer = $dom->getChildren("div")[0];
$cellNavigation = $mainContainer->getChildren("div")[1];
$navItems = <ul class="main-navigation"></ul>;
foreach($this->getChildren() as $child) {
$navItems->appendChild(<li>{$child}</li>);
}
$dom->appendChild($navItems);
return $dom;
}
}
我使用的終端調試使用hhvm -m d <file.php>
我的代碼,一切都還好嗎那裏。但是,當我到達我的瀏覽器時,我得到了500
錯誤標題。這是日誌說什麼:
Catchable fatal error: Hack type error: Could not find method getChildren in an object of type XHPChild at /var/www/res/ui/backstage-header.php line 25
這個錯誤來自
$cellNavigation = $mainContainer->getChildren("div")[1];
但是,不知何故,我需要從我section.backstage-header
追加ul.main-navigation
到div.cell-navigation
。
我該怎麼辦?