PageRenderTime 57ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/system/php/reflection/reflection.php

http://github.com/facebook/hiphop-php
PHP | 2634 lines | 1173 code | 167 blank | 1294 comment | 106 complexity | 821287e02e02577cf90ac246dba6cdc3 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // helpers
  4. // This doc comment block generated by idl/sysdoc.php
  5. /**
  6. * ( excerpt from http://php.net/manual/en/class.reflector.php )
  7. *
  8. * Reflector is an interface implemented by all exportable Reflection
  9. * classes.
  10. *
  11. */
  12. interface Reflector {
  13. // This doc comment block generated by idl/sysdoc.php
  14. /**
  15. * ( excerpt from http://php.net/manual/en/reflector.tostring.php )
  16. *
  17. * To string. Warning: This function is currently not documented; only its
  18. * argument list is available.
  19. *
  20. */
  21. public function __toString();
  22. }
  23. // This doc comment block generated by idl/sysdoc.php
  24. /**
  25. * ( excerpt from http://php.net/manual/en/class.reflectionexception.php )
  26. *
  27. * The ReflectionException class.
  28. *
  29. */
  30. class ReflectionException extends Exception {
  31. }
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // parameter
  34. // This doc comment block generated by idl/sysdoc.php
  35. /**
  36. * ( excerpt from http://php.net/manual/en/class.reflectionparameter.php )
  37. *
  38. * The ReflectionParameter class retrieves information about function's or
  39. * method's parameters.
  40. *
  41. * To introspect function parameters, first create an instance of the
  42. * ReflectionFunction or ReflectionMethod classes and then use their
  43. * ReflectionFunctionAbstract::getParameters() method to retrieve an array
  44. * of parameters.
  45. *
  46. */
  47. class ReflectionParameter implements Reflector {
  48. public $info;
  49. public $name;
  50. // This doc comment block generated by idl/sysdoc.php
  51. /**
  52. * ( excerpt from
  53. * http://php.net/manual/en/reflectionparameter.construct.php )
  54. *
  55. * Constructs a ReflectionParameter class. Warning: This function is
  56. * currently not documented; only its argument list is available.
  57. *
  58. * @func mixed The function to reflect parameters from.
  59. * @param mixed The parameter.
  60. *
  61. * @return mixed No value is returned.
  62. */
  63. public function __construct($func, $param) {
  64. if ($func && $param) {
  65. $params = $func->getParameters();
  66. $this->info = $params[$param]->info;
  67. $this->name = $this->info['name'];
  68. }
  69. }
  70. // This doc comment block generated by idl/sysdoc.php
  71. /**
  72. * ( excerpt from http://php.net/manual/en/reflectionparameter.tostring.php
  73. * )
  74. *
  75. * To string. Warning: This function is currently not documented; only its
  76. * argument list is available.
  77. *
  78. */
  79. public function __toString() {
  80. // TODO
  81. return "";
  82. }
  83. // This doc comment block generated by idl/sysdoc.php
  84. /**
  85. * ( excerpt from http://php.net/manual/en/reflectionparameter.export.php )
  86. *
  87. * Exports. Warning: This function is currently not documented; only its
  88. * argument list is available.
  89. *
  90. * @func mixed The function name.
  91. * @param mixed The parameter name.
  92. * @ret mixed Setting to TRUE will return the export, as opposed
  93. * to emitting it. Setting to FALSE (the default) will
  94. * do the opposite.
  95. *
  96. * @return mixed The exported reflection.
  97. */
  98. public static function export($func, $param, $ret=false) {
  99. $obj = new ReflectionParameter($func, $param);
  100. $str = (string)$obj;
  101. if ($ret) {
  102. return $str;
  103. }
  104. print $str;
  105. }
  106. // This doc comment block generated by idl/sysdoc.php
  107. /**
  108. * ( excerpt from http://php.net/manual/en/reflectionparameter.getname.php
  109. * )
  110. *
  111. * Gets the name of the parameter.
  112. *
  113. * @return mixed The name of the reflected parameter.
  114. */
  115. public function getName() {
  116. return $this->info['name'];
  117. }
  118. // This doc comment block generated by idl/sysdoc.php
  119. /**
  120. * ( excerpt from
  121. * http://php.net/manual/en/reflectionparameter.ispassedbyreference.php )
  122. *
  123. * Checks if the parameter is passed in by reference. Warning: This
  124. * function is currently not documented; only its argument list is
  125. * available.
  126. *
  127. * @return mixed TRUE if the parameter is passed in by reference,
  128. * otherwise FALSE
  129. */
  130. public function isPassedByReference() {
  131. return isset($this->info['ref']);
  132. }
  133. // This doc comment block generated by idl/sysdoc.php
  134. /**
  135. * ( excerpt from
  136. * http://php.net/manual/en/reflectionparameter.getdeclaringclass.php )
  137. *
  138. * Gets the declaring class. Warning: This function is currently not
  139. * documented; only its argument list is available.
  140. *
  141. * @return mixed A ReflectionClass object.
  142. */
  143. public function getDeclaringClass() {
  144. if (empty($this->info['class'])) {
  145. return null;
  146. }
  147. return new ReflectionClass($this->info['class']);
  148. }
  149. // This doc comment block generated by idl/sysdoc.php
  150. /**
  151. * ( excerpt from
  152. * http://php.net/manual/en/reflectionparameter.getdeclaringfunction.php )
  153. *
  154. * Gets the declaring function. Warning: This function is currently not
  155. * documented; only its argument list is available.
  156. *
  157. * @return mixed A ReflectionFunction object.
  158. */
  159. public function getDeclaringFunction() {
  160. if (empty($this->info['class'])) {
  161. return new ReflectionFunction($this->info['function']);
  162. }
  163. return new ReflectionMethod($this->info['class'], $this->info['function']);
  164. }
  165. // This doc comment block generated by idl/sysdoc.php
  166. /**
  167. * ( excerpt from http://php.net/manual/en/reflectionparameter.getclass.php
  168. * )
  169. *
  170. * Gets a class. Warning: This function is currently not documented; only
  171. * its argument list is available.
  172. *
  173. * @return mixed A ReflectionClass object.
  174. */
  175. public function getClass() {
  176. if (empty($this->info['type'])) {
  177. return null;
  178. }
  179. $ltype = strtolower($this->info['type']);
  180. if (hphp_scalar_typehints_enabled()) {
  181. $nonClassTypehints = array(
  182. 'bool' => 1,
  183. 'boolean' => 1,
  184. 'int' => 1,
  185. 'integer' => 1,
  186. 'real' => 1,
  187. 'double' => 1,
  188. 'float' => 1,
  189. 'string' => 1,
  190. 'array' => 1
  191. );
  192. if (isset($nonClassTypehints[$ltype])) {
  193. return null;
  194. }
  195. } else if ($ltype === 'array') {
  196. return null;
  197. }
  198. return new ReflectionClass($this->info['type']);
  199. }
  200. public function getTypehintText() {
  201. if (isset($this->info['type'])) {
  202. return $this->info['type'];
  203. }
  204. return '';
  205. }
  206. public function getTypeText() {
  207. if (isset($this->info['type_hint'])) {
  208. return $this->info['type_hint'];
  209. }
  210. return '';
  211. }
  212. // This doc comment block generated by idl/sysdoc.php
  213. /**
  214. * ( excerpt from http://php.net/manual/en/reflectionparameter.isarray.php
  215. * )
  216. *
  217. * Checks if the parameter expects an array.
  218. *
  219. * @return mixed TRUE if an array is expected, FALSE otherwise.
  220. */
  221. public function isArray() {
  222. return $this->info['type'] == 'array';
  223. }
  224. // This doc comment block generated by idl/sysdoc.php
  225. /**
  226. * ( excerpt from
  227. * http://php.net/manual/en/reflectionparameter.allowsnull.php )
  228. *
  229. * Checks whether the parameter allows NULL. Warning: This function is
  230. * currently not documented; only its argument list is available.
  231. *
  232. * @return mixed TRUE if NULL is allowed, otherwise FALSE
  233. */
  234. public function allowsNull() {
  235. return isset($this->info['nullable']);
  236. }
  237. // This doc comment block generated by idl/sysdoc.php
  238. /**
  239. * ( excerpt from
  240. * http://php.net/manual/en/reflectionparameter.isoptional.php )
  241. *
  242. * Checks if the parameter is optional.
  243. *
  244. * @return mixed TRUE if the parameter is optional, otherwise FALSE
  245. */
  246. public function isOptional() {
  247. return array_key_exists('default', $this->info);
  248. }
  249. // This doc comment block generated by idl/sysdoc.php
  250. /**
  251. * ( excerpt from
  252. * http://php.net/manual/en/reflectionparameter.isdefaultvalueavailable.php
  253. * )
  254. *
  255. * Checks if a default value for the parameter is available.
  256. *
  257. * @return mixed TRUE if a default value is available, otherwise
  258. * FALSE
  259. */
  260. public function isDefaultValueAvailable() {
  261. return array_key_exists('default', $this->info);
  262. }
  263. // This doc comment block generated by idl/sysdoc.php
  264. /**
  265. * ( excerpt from
  266. * http://php.net/manual/en/reflectionparameter.getdefaultvalue.php )
  267. *
  268. * Gets the default value of the parameter for a user-defined function or
  269. * method. If the parameter is not optional a ReflectionException will be
  270. * thrown.
  271. *
  272. * @return mixed The parameters default value.
  273. */
  274. public function getDefaultValue() {
  275. if (!$this->isOptional()) {
  276. throw new ReflectionException('Parameter is not optional');
  277. }
  278. $defaultValue = $this->info['default'];
  279. if ($defaultValue instanceof stdclass) {
  280. if (isset($defaultValue->class)) {
  281. return hphp_get_class_constant($defaultValue->class,
  282. $defaultValue->name);
  283. }
  284. hphp_throw_fatal_error($defaultValue->msg);
  285. }
  286. return $defaultValue;
  287. }
  288. /**
  289. * @deprecated
  290. */
  291. public function getDefaultValueText() {
  292. return $this->getDefaultValueConstantName();
  293. }
  294. // This doc comment block generated by idl/sysdoc.php
  295. /**
  296. * ( excerpt from
  297. * http://php.net/manual/en/reflectionparameter.getdefaultvalueconstantname.php
  298. * )
  299. *
  300. * Warning: This function is currently not documented; only its argument
  301. * list is available.
  302. *
  303. * @return mixed Returns string on success or NULL on failure.
  304. */
  305. public function getDefaultValueConstantName() {
  306. if (isset($this->info['defaultText'])) {
  307. return $this->info['defaultText'];
  308. }
  309. return '';
  310. }
  311. // This doc comment block generated by idl/sysdoc.php
  312. /**
  313. * ( excerpt from
  314. * http://php.net/manual/en/reflectionparameter.getposition.php )
  315. *
  316. * Gets the position of the parameter.
  317. *
  318. * @return mixed The position of the parameter, left to right,
  319. * starting at position #0.
  320. */
  321. public function getPosition() {
  322. return $this->info['index'];
  323. }
  324. public function getAttribute($name) {
  325. $attrs = $this->info['attributes'];
  326. return isset($attrs[$name]) ? $attrs[$name] : null;
  327. }
  328. public function getAttributes() {
  329. return $this->info['attributes'];
  330. }
  331. public function getAttributeRecursive($name) {
  332. $attrs = $this->getAttributesRecursive();
  333. return isset($attrs[$name]) ? $attrs[$name] : null;
  334. }
  335. public function getAttributesRecursive() {
  336. if (!isset($this->info['class'])) {
  337. return $this->getAttributes();
  338. }
  339. $attrs = array();
  340. $class = $this->getDeclaringClass();
  341. $function_name = $this->info['function'];
  342. $index = $this->info['index'];
  343. self::collectAttributes(&$attrs, $class, $function_name, $index);
  344. return $attrs;
  345. }
  346. // This doc comment block generated by idl/sysdoc.php
  347. /**
  348. * ( excerpt from
  349. * http://php.net/manual/en/reflectionparameter.iscallable.php )
  350. *
  351. * Warning: This function is currently not documented; only its argument
  352. * list is available.
  353. *
  354. * @return mixed Returns TRUE if the parameter is callable, FALSE if
  355. * it is not or NULL on failure.
  356. */
  357. public function isCallable() {
  358. return $this->info['type_hint'] === 'callable';
  359. }
  360. private static function collectAttributes(&$attrs, $class, $function_name,
  361. $index) {
  362. if ($class->hasMethod($function_name)) {
  363. $method = $class->getMethod($function_name);
  364. $params = $method->getParameters();
  365. if (count($params) >= $index) {
  366. $attrs += $params[$index]->getAttributes();
  367. }
  368. }
  369. $parent = $class->getParentClass();
  370. if ($parent) {
  371. self::collectAttributes(
  372. &$attrs,
  373. $parent,
  374. $function_name,
  375. $index);
  376. }
  377. }
  378. }
  379. ///////////////////////////////////////////////////////////////////////////////
  380. // This doc comment block generated by idl/sysdoc.php
  381. /**
  382. * ( excerpt from
  383. * http://php.net/manual/en/class.reflectionfunctionabstract.php )
  384. *
  385. * A parent class to ReflectionFunction, read its description for details.
  386. *
  387. */
  388. class ReflectionFunctionAbstract {
  389. public $info;
  390. // This doc comment block generated by idl/sysdoc.php
  391. /**
  392. * ( excerpt from
  393. * http://php.net/manual/en/reflectionfunctionabstract.getname.php )
  394. *
  395. * Get the name of the function. Warning: This function is currently not
  396. * documented; only its argument list is available.
  397. *
  398. * @return mixed The name of the function.
  399. */
  400. public function getName() {
  401. return $this->info['name'];
  402. }
  403. // This doc comment block generated by idl/sysdoc.php
  404. /**
  405. * ( excerpt from
  406. * http://php.net/manual/en/reflectionfunctionabstract.isinternal.php )
  407. *
  408. * Checks whether the function is internal, as opposed to user-defined.
  409. * Warning: This function is currently not documented; only its argument
  410. * list is available.
  411. *
  412. * @return mixed TRUE if it's internal, otherwise FALSE
  413. */
  414. public function isInternal() {
  415. return isset($this->info['internal']);
  416. }
  417. public function getClosure() {
  418. return $this->info['closure'];
  419. }
  420. // This doc comment block generated by idl/sysdoc.php
  421. /**
  422. * ( excerpt from
  423. * http://php.net/manual/en/reflectionfunctionabstract.isclosure.php )
  424. *
  425. * Checks whether it's a closure. Warning: This function is currently not
  426. * documented; only its argument list is available.
  427. *
  428. * @return mixed TRUE if it's a closure, otherwise FALSE
  429. */
  430. public function isClosure() {
  431. return !empty($this->info['is_closure']);
  432. }
  433. // This doc comment block generated by idl/sysdoc.php
  434. /**
  435. * ( excerpt from
  436. * http://php.net/manual/en/reflectionfunctionabstract.isgenerator.php )
  437. *
  438. * Warning: This function is currently not documented; only its argument
  439. * list is available.
  440. *
  441. * @return mixed Returns TRUE if the function is generator, FALSE if
  442. * it is not or NULL on failure.
  443. */
  444. public function isGenerator() {
  445. return !empty($this->info['is_generator']);
  446. }
  447. // This doc comment block generated by idl/sysdoc.php
  448. /**
  449. * ( excerpt from
  450. * http://php.net/manual/en/reflectionfunctionabstract.isuserdefined.php )
  451. *
  452. * Checks whether the function is user-defined, as opposed to internal.
  453. * Warning: This function is currently not documented; only its argument
  454. * list is available.
  455. *
  456. * @return mixed TRUE if it's user-defined, otherwise false;
  457. */
  458. public function isUserDefined() {
  459. return !isset($this->info['internal']);
  460. }
  461. // This doc comment block generated by idl/sysdoc.php
  462. /**
  463. * ( excerpt from
  464. * http://php.net/manual/en/reflectionfunctionabstract.getfilename.php )
  465. *
  466. * Gets the file name from a user-defined function. Warning: This function
  467. * is currently not documented; only its argument list is available.
  468. *
  469. * @return mixed The file name.
  470. */
  471. public function getFileName() {
  472. return $this->info['file'];
  473. }
  474. // This doc comment block generated by idl/sysdoc.php
  475. /**
  476. * ( excerpt from
  477. * http://php.net/manual/en/reflectionfunctionabstract.getstartline.php )
  478. *
  479. * Gets the starting line number of the function. Warning: This function
  480. * is currently not documented; only its argument list is available.
  481. *
  482. * @return mixed The starting line number.
  483. */
  484. public function getStartLine() {
  485. return $this->info['line1'];
  486. }
  487. // This doc comment block generated by idl/sysdoc.php
  488. /**
  489. * ( excerpt from
  490. * http://php.net/manual/en/reflectionfunctionabstract.getendline.php )
  491. *
  492. * Get the ending line number. Warning: This function is currently not
  493. * documented; only its argument list is available.
  494. *
  495. * @return mixed The ending line number of the user defined function,
  496. * or FALSE if unknown.
  497. */
  498. public function getEndLine() {
  499. return $this->info['line2'];
  500. }
  501. // This doc comment block generated by idl/sysdoc.php
  502. /**
  503. * ( excerpt from
  504. * http://php.net/manual/en/reflectionfunctionabstract.getdoccomment.php )
  505. *
  506. * Get a Doc comment from a function. Warning: This function is currently
  507. * not documented; only its argument list is available.
  508. *
  509. * @return mixed The doc comment if it exists, otherwise FALSE
  510. */
  511. public function getDocComment() {
  512. return $this->info['doc'];
  513. }
  514. // This doc comment block generated by idl/sysdoc.php
  515. /**
  516. * ( excerpt from
  517. * http://php.net/manual/en/reflectionfunctionabstract.getstaticvariables.php
  518. * )
  519. *
  520. * Get the static variables. Warning: This function is currently not
  521. * documented; only its argument list is available.
  522. *
  523. * @return mixed An array of static variables.
  524. */
  525. public function getStaticVariables() {
  526. return $this->info['static_variables'];
  527. }
  528. // This doc comment block generated by idl/sysdoc.php
  529. /**
  530. * ( excerpt from
  531. * http://php.net/manual/en/reflectionfunctionabstract.returnsreference.php
  532. * )
  533. *
  534. * Checks whether the function returns a reference. Warning: This function
  535. * is currently not documented; only its argument list is available.
  536. *
  537. * @return mixed TRUE if it returns a reference, otherwise FALSE
  538. */
  539. public function returnsReference() {
  540. return isset($this->info['ref']);
  541. }
  542. // This doc comment block generated by idl/sysdoc.php
  543. /**
  544. * ( excerpt from
  545. * http://php.net/manual/en/reflectionfunctionabstract.getparameters.php )
  546. *
  547. * Get the parameters as an array of ReflectionParameter. Warning: This
  548. * function is currently not documented; only its argument list is
  549. * available.
  550. *
  551. * @return mixed The parameters, as a ReflectionParameter object.
  552. */
  553. public function getParameters() {
  554. $ret = array();
  555. foreach ($this->info['params'] as $name => $info) {
  556. $param = new ReflectionParameter(null, null);
  557. $param->info = $info;
  558. $param->name = $info['name'];
  559. $ret[] = $param;
  560. }
  561. return $ret;
  562. }
  563. // This doc comment block generated by idl/sysdoc.php
  564. /**
  565. * ( excerpt from
  566. * http://php.net/manual/en/reflectionfunctionabstract.getnumberofparameters.php
  567. * )
  568. *
  569. * Get the number of parameters that a function defines, both optional and
  570. * required. Warning: This function is currently not documented; only its
  571. * argument list is available.
  572. *
  573. * @return mixed The number of parameters.
  574. */
  575. public function getNumberOfParameters() {
  576. return count($this->info['params']);
  577. }
  578. // This doc comment block generated by idl/sysdoc.php
  579. /**
  580. * ( excerpt from
  581. * http://php.net/manual/en/reflectionfunctionabstract.getnumberofrequiredparameters.php
  582. * )
  583. *
  584. * Get the number of required parameters that a function defines. Warning:
  585. * This function is currently not documented; only its argument list is
  586. * available.
  587. *
  588. * @return mixed The number of required parameters.
  589. */
  590. public function getNumberOfRequiredParameters() {
  591. $count = 0;
  592. $params = $this->getParameters();
  593. foreach ($params as $name => $param) {
  594. if ($param->isOptional()) {
  595. break;
  596. }
  597. $count++;
  598. }
  599. return $count;
  600. }
  601. public function getReturnTypeText() {
  602. if (isset($this->info['return_type'])) {
  603. return $this->info['return_type'];
  604. }
  605. return '';
  606. }
  607. }
  608. ///////////////////////////////////////////////////////////////////////////////
  609. // function
  610. // This doc comment block generated by idl/sysdoc.php
  611. /**
  612. * ( excerpt from http://php.net/manual/en/class.reflectionfunction.php )
  613. *
  614. * The ReflectionFunction class reports information about a function.
  615. *
  616. */
  617. class ReflectionFunction extends ReflectionFunctionAbstract
  618. implements Reflector {
  619. const IS_DEPRECATED = 262144;
  620. // This doc comment block generated by idl/sysdoc.php
  621. /**
  622. * ( excerpt from http://php.net/manual/en/reflectionfunction.construct.php
  623. * )
  624. *
  625. * Constructs a ReflectionFunction object.
  626. *
  627. * @name mixed The name of the function to reflect or a closure.
  628. *
  629. * @return mixed No value is returned.
  630. */
  631. public function __construct($name) {
  632. if ($name instanceof Closure) {
  633. $this->info = hphp_get_closure_info($name);
  634. } else {
  635. $this->info = hphp_get_function_info($name);
  636. if (empty($this->info)) {
  637. throw new ReflectionException("Function $name does not exist");
  638. }
  639. }
  640. }
  641. // This doc comment block generated by idl/sysdoc.php
  642. /**
  643. * ( excerpt from http://php.net/manual/en/reflectionfunction.tostring.php
  644. * )
  645. *
  646. * To string.
  647. *
  648. * @return mixed Returns ReflectionFunction::export()-like output for
  649. * the function.
  650. */
  651. public function __toString() {
  652. //TODO
  653. return "";
  654. }
  655. // This doc comment block generated by idl/sysdoc.php
  656. /**
  657. * ( excerpt from http://php.net/manual/en/reflectionfunction.export.php )
  658. *
  659. * Exports a Reflected function.
  660. *
  661. * @name mixed The reflection to export.
  662. * @ret mixed Setting to TRUE will return the export, as opposed
  663. * to emitting it. Setting to FALSE (the default) will
  664. * do the opposite.
  665. *
  666. * @return mixed If the return parameter is set to TRUE, then the
  667. * export is returned as a string, otherwise NULL is
  668. * returned.
  669. */
  670. public static function export($name, $ret=false) {
  671. $obj = new ReflectionFunction($name);
  672. $str = (string)$obj;
  673. if ($ret) {
  674. return $str;
  675. }
  676. print $str;
  677. }
  678. // This doc comment block generated by idl/sysdoc.php
  679. /**
  680. * ( excerpt from http://php.net/manual/en/reflectionfunction.invoke.php )
  681. *
  682. * Invokes a reflected function.
  683. *
  684. * @return mixed Returns the result of the invoked function call.
  685. */
  686. public function invoke() {
  687. $args = func_get_args();
  688. if (isset($this->info['closureobj'])) {
  689. $closure = $this->info['closureobj'];
  690. return hphp_invoke_method($closure, get_class($closure),
  691. '__invoke', $args);
  692. }
  693. return hphp_invoke($this->info['name'], $args);
  694. }
  695. // This doc comment block generated by idl/sysdoc.php
  696. /**
  697. * ( excerpt from
  698. * http://php.net/manual/en/reflectionfunction.invokeargs.php )
  699. *
  700. * Invokes the function and pass its arguments as array.
  701. *
  702. * @args mixed The passed arguments to the function as an array,
  703. * much like call_user_func_array() works.
  704. *
  705. * @return mixed Returns the result of the invoked function
  706. */
  707. public function invokeArgs($args) {
  708. if (isset($this->info['closureobj'])) {
  709. $closure = $this->info['closureobj'];
  710. return hphp_invoke_method($closure, get_class($closure),
  711. '__invoke', array_values($args));
  712. }
  713. return hphp_invoke($this->info['name'], array_values($args));
  714. }
  715. public function getAttribute($name) {
  716. $attrs = $this->info['attributes'];
  717. return isset($attrs[$name]) ? $attrs[$name] : null;
  718. }
  719. public function getAttributes() {
  720. return $this->info['attributes'];
  721. }
  722. public function getAttributeRecursive($name) {
  723. $attrs = $this->info['attributes'];
  724. return isset($attrs[$name]) ? $attrs[$name] : null;
  725. }
  726. public function getAttributesRecursive() {
  727. return $this->info['attributes'];
  728. }
  729. }
  730. ///////////////////////////////////////////////////////////////////////////////
  731. // class
  732. // This doc comment block generated by idl/sysdoc.php
  733. /**
  734. * ( excerpt from http://php.net/manual/en/class.reflectionclass.php )
  735. *
  736. * The ReflectionClass class reports information about a class.
  737. *
  738. */
  739. class ReflectionClass implements Reflector {
  740. const IS_IMPLICIT_ABSTRACT = 16 ;
  741. const IS_EXPLICIT_ABSTRACT = 32 ;
  742. const IS_FINAL = 64 ;
  743. public $name;
  744. private $info = null;
  745. private static $fetched = array();
  746. // This doc comment block generated by idl/sysdoc.php
  747. /**
  748. * ( excerpt from http://php.net/manual/en/reflectionclass.construct.php )
  749. *
  750. * Constructs a new ReflectionClass object. Warning: This function is
  751. * currently not documented; only its argument list is available.
  752. *
  753. * @name mixed Either a string containing the name of the class to
  754. * reflect, or an object.
  755. *
  756. * @return mixed No value is returned.
  757. */
  758. public function __construct($name) {
  759. if (is_object($name)) {
  760. $name = get_class($name);
  761. }
  762. $this->name = hphp_get_original_class_name($name);
  763. if (empty($this->name)) {
  764. throw new ReflectionException("Class $name does not exist");
  765. }
  766. }
  767. private function fetch($what) {
  768. if (!$this->info) {
  769. $this->info = self::fetch_recur($this->name);
  770. $this->info['properties'] += $this->info['private_properties'];
  771. }
  772. return $this->info[$what];
  773. }
  774. private static function fetch_recur($name) {
  775. if (isset(self::$fetched[$name])) return self::$fetched[$name];
  776. $info = hphp_get_class_info($name);
  777. if (empty($info)) {
  778. throw new ReflectionException("Class $name does not exist");
  779. }
  780. $info['attributes_rec'] = $info['attributes'];
  781. $abstract = isset($info['abstract']) || isset($info['interface']);
  782. // flattening the trees, so it's easier for lookups
  783. foreach ($info['interfaces'] as $interface => $_) {
  784. $p = self::fetch_recur($interface);
  785. if ($abstract) $info['methods'] += $p['methods'];
  786. $info['constants'] += $p['constants'];
  787. $info['interfaces'] += $p['interfaces'];
  788. }
  789. $parent = $info['parent'];
  790. if (!empty($parent)) {
  791. $p = self::fetch_recur($parent);
  792. if (isset($p['interface'])) {
  793. $info['interfaces'][$parent] = 1;
  794. } else {
  795. $info['properties'] += $p['properties'];
  796. }
  797. $info['methods'] += $p['methods'];
  798. $info['constants'] += $p['constants'];
  799. $info['interfaces'] += $p['interfaces'];
  800. $info['attributes_rec'] += $p['attributes_rec'];
  801. }
  802. self::$fetched[$name] = $info;
  803. return $info;
  804. }
  805. private function check($what) {
  806. if (!$this->info) {
  807. $this->info = self::fetch_recur($this->name);
  808. }
  809. return isset($this->info[$what]);
  810. }
  811. private function test($what, $name) {
  812. $v = $this->fetch($what);
  813. return $v && isset($v[$name]);
  814. }
  815. // This doc comment block generated by idl/sysdoc.php
  816. /**
  817. * ( excerpt from http://php.net/manual/en/reflectionclass.tostring.php )
  818. *
  819. * Returns the string representation of the ReflectionClass object.
  820. *
  821. * @return mixed A string representation of this ReflectionClass
  822. * instance.
  823. */
  824. public function __toString() {
  825. return "";
  826. }
  827. // This doc comment block generated by idl/sysdoc.php
  828. /**
  829. * ( excerpt from http://php.net/manual/en/reflectionclass.export.php )
  830. *
  831. * Exports a reflected class.
  832. *
  833. * @name mixed The reflection to export.
  834. * @ret mixed Setting to TRUE will return the export, as opposed
  835. * to emitting it. Setting to FALSE (the default) will
  836. * do the opposite.
  837. *
  838. * @return mixed If the return parameter is set to TRUE, then the
  839. * export is returned as a string, otherwise NULL is
  840. * returned.
  841. */
  842. public static function export($name, $ret=false) {
  843. $obj = new ReflectionClass($name);
  844. $str = (string)$obj;
  845. if ($ret) {
  846. return $str;
  847. }
  848. print $str;
  849. }
  850. // This doc comment block generated by idl/sysdoc.php
  851. /**
  852. * ( excerpt from http://php.net/manual/en/reflectionclass.getname.php )
  853. *
  854. * Gets the class name. Warning: This function is currently not
  855. * documented; only its argument list is available.
  856. *
  857. * @return mixed The class name.
  858. */
  859. public function getName() {
  860. return $this->name;
  861. }
  862. // This doc comment block generated by idl/sysdoc.php
  863. /**
  864. * ( excerpt from http://php.net/manual/en/reflectionclass.isinternal.php )
  865. *
  866. * Checks if the class is defined internally by an extension, or the core,
  867. * as opposed to user-defined.
  868. *
  869. * @return mixed Returns TRUE on success or FALSE on failure.
  870. */
  871. public function isInternal() {
  872. return $this->check('internal');
  873. }
  874. // This doc comment block generated by idl/sysdoc.php
  875. /**
  876. * ( excerpt from
  877. * http://php.net/manual/en/reflectionclass.isuserdefined.php )
  878. *
  879. * Checks whether the class is user-defined, as opposed to internal.
  880. *
  881. * @return mixed Returns TRUE on success or FALSE on failure.
  882. */
  883. public function isUserDefined() {
  884. return !$this->check('internal');
  885. }
  886. // This doc comment block generated by idl/sysdoc.php
  887. /**
  888. * ( excerpt from
  889. * http://php.net/manual/en/reflectionclass.isinstantiable.php )
  890. *
  891. * Checks if the class is instantiable.
  892. *
  893. * @return mixed Returns TRUE on success or FALSE on failure.
  894. */
  895. public function isInstantiable() {
  896. return !$this->check('abstract');
  897. }
  898. // This doc comment block generated by idl/sysdoc.php
  899. /**
  900. * ( excerpt from http://php.net/manual/en/reflectionclass.hasconstant.php
  901. * )
  902. *
  903. * Checks whether the class has a specific constant defined or not.
  904. *
  905. * @name mixed The name of the constant being checked for.
  906. *
  907. * @return mixed TRUE if the constant is defined, otherwise FALSE.
  908. */
  909. public function hasConstant($name) {
  910. return $this->test('constants', $name);
  911. }
  912. // This doc comment block generated by idl/sysdoc.php
  913. /**
  914. * ( excerpt from http://php.net/manual/en/reflectionclass.hasmethod.php )
  915. *
  916. * Checks whether a specific method is defined in a class.
  917. *
  918. * @name mixed Name of the method being checked for.
  919. *
  920. * @return mixed TRUE if it has the method, otherwise FALSE
  921. */
  922. public function hasMethod($name) {
  923. return $this->test('methods', strtolower($name));
  924. }
  925. // This doc comment block generated by idl/sysdoc.php
  926. /**
  927. * ( excerpt from http://php.net/manual/en/reflectionclass.hasproperty.php
  928. * )
  929. *
  930. * Checks whether the specified property is defined.
  931. *
  932. * @name mixed Name of the property being checked for.
  933. *
  934. * @return mixed TRUE if it has the property, otherwise FALSE
  935. */
  936. public function hasProperty($name) {
  937. return $this->test('properties', $name);
  938. }
  939. // This doc comment block generated by idl/sysdoc.php
  940. /**
  941. * ( excerpt from http://php.net/manual/en/reflectionclass.getfilename.php
  942. * )
  943. *
  944. * Gets the filename of the file in which the class has been defined.
  945. *
  946. * @return mixed Returns the filename of the file in which the class
  947. * has been defined. If the class is defined in the PHP
  948. * core or in a PHP extension, FALSE is returned.
  949. */
  950. public function getFileName() {
  951. return $this->fetch('file');
  952. }
  953. // This doc comment block generated by idl/sysdoc.php
  954. /**
  955. * ( excerpt from http://php.net/manual/en/reflectionclass.getstartline.php
  956. * )
  957. *
  958. * Get the starting line number. Warning: This function is currently not
  959. * documented; only its argument list is available.
  960. *
  961. * @return mixed The starting line number, as an integer.
  962. */
  963. public function getStartLine() {
  964. return $this->fetch('line1');
  965. }
  966. // This doc comment block generated by idl/sysdoc.php
  967. /**
  968. * ( excerpt from http://php.net/manual/en/reflectionclass.getendline.php )
  969. *
  970. * Gets end line number from a user-defined class definition.
  971. *
  972. * @return mixed The ending line number of the user defined class, or
  973. * FALSE if unknown.
  974. */
  975. public function getEndLine() {
  976. return $this->fetch('line2');
  977. }
  978. // This doc comment block generated by idl/sysdoc.php
  979. /**
  980. * ( excerpt from
  981. * http://php.net/manual/en/reflectionclass.getdoccomment.php )
  982. *
  983. * Gets doc comments from a class. Warning: This function is currently not
  984. * documented; only its argument list is available.
  985. *
  986. * @return mixed The doc comment if it exists, otherwise FALSE
  987. */
  988. public function getDocComment() {
  989. return $this->fetch('doc');
  990. }
  991. // This doc comment block generated by idl/sysdoc.php
  992. /**
  993. * ( excerpt from
  994. * http://php.net/manual/en/reflectionclass.getconstructor.php )
  995. *
  996. * Gets the constructor of the reflected class.
  997. *
  998. * @return mixed A ReflectionMethod object reflecting the class'
  999. * constructor, or NULL if the class has no
  1000. * constructor.
  1001. */
  1002. public function getConstructor() {
  1003. if ($this->hasMethod('__construct')) {
  1004. return $this->getMethod('__construct');
  1005. }
  1006. if (!$this->isTrait() && $this->hasMethod($name = $this->name)) {
  1007. return $this->getMethod($name);
  1008. }
  1009. return null;
  1010. }
  1011. // This doc comment block generated by idl/sysdoc.php
  1012. /**
  1013. * ( excerpt from http://php.net/manual/en/reflectionclass.getmethod.php )
  1014. *
  1015. * Gets a ReflectionMethod for a class method.
  1016. *
  1017. * @name mixed The method name to reflect.
  1018. *
  1019. * @return mixed A ReflectionMethod.
  1020. */
  1021. public function getMethod($name) {
  1022. if (!$this->info) {
  1023. $method = hphp_get_method_info($this->name, $name);
  1024. } else {
  1025. $lname = strtolower($name);
  1026. $methods = $this->info['methods'];
  1027. if (isset($methods[$lname])) $method = $methods[$lname];
  1028. }
  1029. if (empty($method)) {
  1030. $class = $this->name;
  1031. throw new ReflectionException("Method $class::$name does not exist");
  1032. }
  1033. $ret = new ReflectionMethod(null, null);
  1034. $ret->info = $method;
  1035. $ret->name = $method['name'];
  1036. $ret->class = $method['class'];
  1037. return $ret;
  1038. }
  1039. // This doc comment block generated by idl/sysdoc.php
  1040. /**
  1041. * ( excerpt from http://php.net/manual/en/reflectionclass.getmethods.php )
  1042. *
  1043. * Gets an array of methods for the class.
  1044. *
  1045. * @filter mixed Filter the results to include only methods with
  1046. * certain attributes. Defaults to no filtering.
  1047. *
  1048. * Any combination of ReflectionMethod::IS_STATIC,
  1049. * ReflectionMethod::IS_PUBLIC,
  1050. * ReflectionMethod::IS_PROTECTED,
  1051. * ReflectionMethod::IS_PRIVATE,
  1052. * ReflectionMethod::IS_ABSTRACT,
  1053. * ReflectionMethod::IS_FINAL.
  1054. *
  1055. * @return mixed An array of ReflectionMethod objects reflecting each
  1056. * method.
  1057. */
  1058. public function getMethods($filter = 0xFFFF) {
  1059. $ret = array();
  1060. $methods = $this->fetch('methods');
  1061. foreach ($methods as $name => $_) {
  1062. $m = $this->getMethod($name);
  1063. if ((($filter & ReflectionMethod::IS_PUBLIC)) && $m->isPublic() ||
  1064. (($filter & ReflectionMethod::IS_PROTECTED)) && $m->isProtected() ||
  1065. (($filter & ReflectionMethod::IS_PRIVATE)) && $m->isPrivate() ||
  1066. (($filter & ReflectionMethod::IS_STATIC)) && $m->isStatic() ||
  1067. (($filter & ReflectionMethod::IS_FINAL)) && $m->isFinal() ||
  1068. (($filter & ReflectionMethod::IS_ABSTRACT && $m->isAbstract()))) {
  1069. $ret[] = $m;
  1070. }
  1071. }
  1072. return $ret;
  1073. }
  1074. // This doc comment block generated by idl/sysdoc.php
  1075. /**
  1076. * ( excerpt from http://php.net/manual/en/reflectionclass.getproperty.php
  1077. * )
  1078. *
  1079. * Gets a ReflectionProperty for a class's property.
  1080. *
  1081. * @name mixed The property name.
  1082. *
  1083. * @return mixed A ReflectionProperty.
  1084. */
  1085. public function getProperty($name) {
  1086. $properties = $this->fetch('properties');
  1087. if (!isset($properties[$name])) {
  1088. $class = $this->info['name'];
  1089. throw new ReflectionException("Property $class::$name does not exist");
  1090. }
  1091. $cls = new ReflectionClass("ReflectionProperty");
  1092. $ret = $cls->newInstanceWithoutConstructor();
  1093. $ret->info = $properties[$name];
  1094. $ret->name = $name;
  1095. $ret->class = $this->info['name'];
  1096. return $ret;
  1097. }
  1098. // This doc comment block generated by idl/sysdoc.php
  1099. /**
  1100. * ( excerpt from
  1101. * http://php.net/manual/en/reflectionclass.getproperties.php )
  1102. *
  1103. * Retrieves reflected properties.
  1104. *
  1105. * @filter mixed The optional filter, for filtering desired property
  1106. * types. It's configured using the ReflectionProperty
  1107. * constants, and defaults to all property types.
  1108. *
  1109. * @return mixed An array of ReflectionProperty objects.
  1110. */
  1111. public function getProperties($filter = 0xFFFF) {
  1112. $ret = array();
  1113. foreach ($this->fetch('properties') as $name => $_) {
  1114. $p = $this->getProperty($name);
  1115. if (($filter & ReflectionProperty::IS_PUBLIC) && $p->isPublic() ||
  1116. ($filter & ReflectionProperty::IS_PROTECTED) && $p->isProtected() ||
  1117. ($filter & ReflectionProperty::IS_PRIVATE) && $p->isPrivate() ||
  1118. ($filter & ReflectionProperty::IS_STATIC) && $p->isStatic()) {
  1119. $ret[] = $p;
  1120. }
  1121. }
  1122. return $ret;
  1123. }
  1124. // This doc comment block generated by idl/sysdoc.php
  1125. /**
  1126. * ( excerpt from http://php.net/manual/en/reflectionclass.getconstants.php
  1127. * )
  1128. *
  1129. * Gets defined constants from a class. Warning: This function is
  1130. * currently not documented; only its argument list is available.
  1131. *
  1132. * @return mixed An array of constants. Constant name in key,
  1133. * constant value in value.
  1134. */
  1135. public function getConstants() {
  1136. return $this->fetch('constants');
  1137. }
  1138. // This doc comment block generated by idl/sysdoc.php
  1139. /**
  1140. * ( excerpt from http://php.net/manual/en/reflectionclass.getconstant.php
  1141. * )
  1142. *
  1143. * Gets the defined constant. Warning: This function is currently not
  1144. * documented; only its argument list is available.
  1145. *
  1146. * @name mixed Name of the constant.
  1147. *
  1148. * @return mixed Value of the constant.
  1149. */
  1150. public function getConstant($name) {
  1151. $constants = $this->fetch('constants');
  1152. if (!isset($constants[$name])) {
  1153. $class = $this->info['name'];
  1154. throw new ReflectionException("Class constant $class::$name does not exist");
  1155. }
  1156. return $constants[$name];
  1157. }
  1158. // This doc comment block generated by idl/sysdoc.php
  1159. /**
  1160. * ( excerpt from
  1161. * http://php.net/manual/en/reflectionclass.getinterfaces.php )
  1162. *
  1163. * Gets the interfaces.
  1164. *
  1165. * @return mixed An associative array of interfaces, with keys as
  1166. * interface names and the array values as
  1167. * ReflectionClass objects.
  1168. */
  1169. public function getInterfaces() {
  1170. $ret = array();
  1171. foreach ($this->fetch('interfaces') as $name => $_) {
  1172. $cls = new ReflectionClass($name);
  1173. if ($cls->isInterface()) {
  1174. $ret[$cls->getName()] = $cls;
  1175. }
  1176. }
  1177. return $ret;
  1178. }
  1179. // This doc comment block generated by idl/sysdoc.php
  1180. /**
  1181. * ( excerpt from http://php.net/manual/en/reflectionclass.gettraits.php )
  1182. *
  1183. * Warning: This function is currently not documented; only its argument
  1184. * list is available.
  1185. *
  1186. * @return mixed Returns an array with trait names in keys and
  1187. * instances of trait's ReflectionClass in values.
  1188. * Returns NULL in case of an error.
  1189. */
  1190. public function getTraits() {
  1191. $ret = array();
  1192. foreach ($this->fetch('traits') as $name => $_) {
  1193. $cls = new ReflectionClass($name);
  1194. if ($cls->isTrait()) {
  1195. $ret[$cls->getName()] = $cls;
  1196. }
  1197. }
  1198. return $ret;
  1199. }
  1200. // This doc comment block generated by idl/sysdoc.php
  1201. /**
  1202. * ( excerpt from
  1203. * http://php.net/manual/en/reflectionclass.getinterfacenames.php )
  1204. *
  1205. * Get the interface names.
  1206. *
  1207. * @return mixed A numerical array with interface names as the
  1208. * values.
  1209. */
  1210. public function getInterfaceNames() {
  1211. $ret = array();
  1212. foreach ($this->fetch('interfaces') as $name => $_) {
  1213. $cls = new ReflectionClass($name);
  1214. if ($cls->isInterface()) {
  1215. $ret[] = $cls->getName();
  1216. }
  1217. }
  1218. return $ret;
  1219. }
  1220. // This doc comment block generated by idl/sysdoc.php
  1221. /**
  1222. * ( excerpt from
  1223. * http://php.net/manual/en/reflectionclass.gettraitnames.php )
  1224. *
  1225. * Warning: This function is currently not documented; only its argument
  1226. * list is available.
  1227. *
  1228. * @return mixed Returns an array with trait names in values. Returns
  1229. * NULL in case of an error.
  1230. */
  1231. public function getTraitNames() {
  1232. $ret = array();
  1233. foreach ($this->fetch('traits') as $name => $_) {
  1234. $cls = new ReflectionClass($name);
  1235. if ($cls->isTrait()) {
  1236. $ret[] = $cls->getName();
  1237. }
  1238. }
  1239. return $ret;
  1240. }
  1241. // This doc comment block generated by idl/sysdoc.php
  1242. /**
  1243. * ( excerpt from
  1244. * http://php.net/manual/en/reflectionclass.gettraitaliases.php )
  1245. *
  1246. * Warning: This function is currently not documented; only its argument
  1247. * list is available.
  1248. *
  1249. * @return mixed Returns an array with new method names in keys and
  1250. * original names (in the format "TraitName::original")
  1251. * in values. Returns NULL in case of an error.
  1252. */
  1253. public function getTraitAliases() {
  1254. $ret = array();
  1255. foreach ($this->fetch('trait_aliases') as $old_name => $new_name) {
  1256. $ret[$old_name] = $new_name;
  1257. }
  1258. return $ret;
  1259. }
  1260. // This doc comment block generated by idl/sysdoc.php
  1261. /**
  1262. * ( excerpt from http://php.net/manual/en/reflectionclass.isinterface.php
  1263. * )
  1264. *
  1265. * Checks whether the class is an interface.
  1266. *
  1267. * @return mixed Returns TRUE on success or FALSE on failure.
  1268. */
  1269. public function isInterface() {
  1270. return $this->check('interface');
  1271. }
  1272. // This doc comment block generated by idl/sysdoc.php
  1273. /**
  1274. * ( excerpt from http://php.net/manual/en/reflectionclass.isabstract.php )
  1275. *
  1276. * Checks if the class is abstract.
  1277. *
  1278. * @return mixed Returns TRUE on success or FALSE on failure.
  1279. */
  1280. public function isAbstract() {
  1281. return $this->check('abstract');
  1282. }
  1283. // This doc comment block generated by idl/sysdoc.php
  1284. /**
  1285. * ( excerpt from http://php.net/manual/en/reflectionclass.isfinal.php )
  1286. *
  1287. * Checks if a class is final.
  1288. *
  1289. * @return mixed Returns TRUE on success or FALSE on failure.
  1290. */
  1291. public function isFinal() {
  1292. return $this->check('final');
  1293. }
  1294. // This doc comment block generated by idl/sysdoc.php
  1295. /**
  1296. * ( excerpt from http://php.net/manual/en/reflectionclass.istrait.php )
  1297. *
  1298. * Warning: This function is currently not documented; only its argument
  1299. * list is available.
  1300. *
  1301. * @return mixed Returns TRUE if this is a trait, FALSE otherwise.
  1302. * Returns NULL in case of an error.
  1303. */
  1304. public function isTrait() {
  1305. return $this->check('trait');
  1306. }
  1307. // This doc comment block generated by idl/sysdoc.php
  1308. /**
  1309. * ( excerpt from http://php.net/manual/en/reflectionclass.getmodifiers.php
  1310. * )
  1311. *
  1312. * Returns a bitfield of the access modifiers for this class.
  1313. *
  1314. * @return mixed Returns bitmask of modifier constants.
  1315. */
  1316. public function getModifiers() {
  1317. return $this->fetch('modifiers');
  1318. }
  1319. // This doc comment block generated by idl/sysdoc.php
  1320. /**
  1321. * ( excerpt from http://php.net/manual/en/reflectionclass.isinstance.php )
  1322. *
  1323. * Checks if an object is an instance of a class.
  1324. *
  1325. * @obj mixed The object being compared to.
  1326. *
  1327. * @return mixed Returns TRUE on success or FALSE on failure.
  1328. */
  1329. public function isInstance($obj) {
  1330. return hphp_instanceof($obj, $this->name);
  1331. }
  1332. // This doc comment block generated by idl/sysdoc.php
  1333. /**
  1334. * ( excerpt from http://php.net/manual/en/reflectionclass.newinstance.php
  1335. * )
  1336. *
  1337. * Creates a new instance of the class. The given arguments are passed to
  1338. * the class constructor.
  1339. *
  1340. */
  1341. public function newInstance() {
  1342. $args = func_get_args();
  1343. return hphp_create_object($this->name, $args);
  1344. }
  1345. // This doc comment block generated by idl/sysdoc.php
  1346. /**
  1347. * ( excerpt from
  1348. * http://php.net/manual/en/reflectionclass.newinstanceargs.php )
  1349. *
  1350. * Creates a new instance of the class, the given arguments are passed to
  1351. * the class constructor.
  1352. *
  1353. * @args mixed The parameters to be passed to the class constructor
  1354. * as an array.
  1355. *
  1356. * @return mixed Returns a new instance of the class.
  1357. */
  1358. public function newInstanceArgs($args) {
  1359. return hphp_create_object($this->name, array_values($args));
  1360. }
  1361. // This doc comment block generated by idl/sysdoc.php
  1362. /**
  1363. * ( excerpt from
  1364. * http://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php
  1365. * )
  1366. *
  1367. * Creates a new instance of the class without invoking the constructor.
  1368. *
  1369. */
  1370. public function newInstanceWithoutConstructor() {
  1371. return hphp_create_object_without_constructor($this->name);
  1372. }
  1373. // This doc comment block generated by idl/sysdoc.php
  1374. /**
  1375. * ( excerpt from
  1376. * http://php.net/manual/en/reflectionclass.getparentclass.php )
  1377. *
  1378. * Warning: This function is currently not documented; only its argument
  1379. * list is available.
  1380. *
  1381. * @return mixed A ReflectionClass.
  1382. */
  1383. public function getParentClass() {
  1384. $parent = $this->fetch('parent');
  1385. if (empty($parent)) {
  1386. return false;
  1387. }
  1388. return new ReflectionClass($parent);
  1389. }
  1390. // This doc comment block generated by idl/sysdoc.php
  1391. /**
  1392. * ( excerpt from http://php.net/manual/en/reflectionclass.issubclassof.php
  1393. * )
  1394. *
  1395. * Checks if the class is a subclass of a specified class or implements a
  1396. * specified interface.
  1397. *
  1398. * @cls mixed The class name being checked against.
  1399. *
  1400. * @return mixed Returns TRUE on success or FALSE on failure.
  1401. */
  1402. public function isSubclassOf($cls) {
  1403. if ($cls instanceof ReflectionClass) {
  1404. $cls = $cls->name;
  1405. }
  1406. return is_subclass_of($this->name, $cls);
  1407. }
  1408. // This doc comment block generated by idl/sysdoc.php
  1409. /**
  1410. * ( excerpt from
  1411. * http://php.net/manual/en/reflectionclass.getstaticproperties.php )
  1412. *
  1413. * Get the static properties. Warning: This function is currently not
  1414. * documented; only its argument list is available.
  1415. *
  1416. * @return mixed The static properties, as an array.
  1417. */
  1418. public function getStaticProperties() {
  1419. $ret = array();
  1420. foreach ($this->getProperties() as $prop) {
  1421. if ($prop->isStatic()) {
  1422. $ret[$prop->name] = $prop;
  1423. }
  1424. }
  1425. return $ret;
  1426. }
  1427. // This doc comment block generated by idl/sysdoc.php
  1428. /**
  1429. * ( excerpt from
  1430. * http://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php )
  1431. *
  1432. * Gets the value of a static property on this class.
  1433. *
  1434. * @name mixed The name of the static property for which to return
  1435. * a value.
  1436. * @default mixed
  1437. *
  1438. * @return mixed The value of the static property.
  1439. */
  1440. public function getStaticPropertyValue($name, $default = null) {
  1441. if ($this->hasProperty($name) &&
  1442. $this->getProperty($name)->isStatic()) {
  1443. return hphp_get_static_property($this->name, $name, false);
  1444. }
  1445. return $default;
  1446. }
  1447. // This doc comment block generated by idl/sysdoc.php
  1448. /**
  1449. * ( excerpt from
  1450. * http://php.net/manual/en/reflectionclass.setstaticpropertyvalue.php )
  1451. *
  1452. * Sets static property value. Warning: This function is currently not
  1453. * documented; only its argument list is available.
  1454. *
  1455. * @name mixed Property name.
  1456. * @value mixed New property value.
  1457. *
  1458. * @return mixed No value is returned.
  1459. */
  1460. public function setStaticPropertyValue($name, $value) {
  1461. hphp_set_static_property($this->name, $name, $value, false);
  1462. }
  1463. // This doc comment block generated by idl/sysdoc.php
  1464. /**
  1465. * ( excerpt from
  1466. * http://php.net/manual/en/reflectionclass.getdefaultproperties.php )
  1467. *
  1468. * Gets default properties from a class (including inherited properties).
  1469. *
  1470. * This method only works for static properties when used on internal
  1471. * classes. The default value of a static class property can not be tracked
  1472. * when using this method on user defined classes.
  1473. *
  1474. * @return mixed An array of default properties, with the key being
  1475. * the name of the property and the value being the
  1476. * default value of the property or NULL if the
  1477. * property doesn't have a default value. The function
  1478. * does not distinguish between static and non static
  1479. * properties and does not take visibility modifiers
  1480. * into account.
  1481. */
  1482. public function getDefaultProperties() {
  1483. $ret = array();
  1484. foreach ($this->getProperties() as $prop) {
  1485. if ($prop->isDefault()) {
  1486. $ret[$prop->name] = $prop;
  1487. }
  1488. }
  1489. return $ret;
  1490. }
  1491. // This doc comment block generated by idl/sysdoc.php
  1492. /**
  1493. * ( excerpt from
  1494. * http://php.net/manual/en/reflectionclass.isiterateable.php )
  1495. *
  1496. * Checks whether the class is iterateable.
  1497. *
  1498. * @return mixed Returns TRUE on success or FALSE on failure.
  1499. */
  1500. public function isIterateable() {
  1501. return $this->isSubclassOf('ArrayAccess');
  1502. }
  1503. // This doc comment block generated by idl/sysdoc.php
  1504. /**
  1505. * ( excerpt from
  1506. * http://php.net/manual/en/reflectionclass.implementsinterface.php )
  1507. *
  1508. * Checks whether it implements an interface.
  1509. *
  1510. * @cls mixed The interface name.
  1511. *
  1512. * @return mixed Returns TRUE on success or FALSE on failure.
  1513. */
  1514. public function implementsInterface($cls) {
  1515. if ($cls instanceof ReflectionCla

Large files files are truncated, but you can click here to view the full file