W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
屬性是元數(shù)據(jù)的任何一個(gè)保持器可反射一段代碼。這包括函數(shù),類(lèi),接口,特性等
除了一些特殊的屬性,屬性是一個(gè)純粹的句法實(shí)體。他們利用工具來(lái)完成任務(wù)。例如,您可以擁有基于文檔的屬性,其內(nèi)容通過(guò)反射提取。
<?hh
namespace Hack\UserDocumentation\Attributes\Intro\Examples\Simple;
<<ClassOwner("Joel Marcey"), Description("This class does nothing")>>
class Simple {}
function get_attributes(): void {
$rc = new \ReflectionClass(
"Hack\UserDocumentation\Attributes\Intro\Examples\Simple\Simple"
);
var_dump($rc->getAttributes()["Description"]);
}
get_attributes();
Output
array(1) {
[0]=>
string(23) "This class does nothing"
}
一些屬性對(duì)Hack類(lèi)型檢查器和HHVM都有特殊的含義。這里是最常見(jiàn)和有用的:
還有一些不太常見(jiàn)的特殊屬性。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: