/hphp/system/php/reflection/reflection.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
- <?php
- ///////////////////////////////////////////////////////////////////////////////
- // helpers
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/class.reflector.php )
- *
- * Reflector is an interface implemented by all exportable Reflection
- * classes.
- *
- */
- interface Reflector {
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflector.tostring.php )
- *
- * To string. Warning: This function is currently not documented; only its
- * argument list is available.
- *
- */
- public function __toString();
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/class.reflectionexception.php )
- *
- * The ReflectionException class.
- *
- */
- class ReflectionException extends Exception {
- }
- ///////////////////////////////////////////////////////////////////////////////
- // parameter
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/class.reflectionparameter.php )
- *
- * The ReflectionParameter class retrieves information about function's or
- * method's parameters.
- *
- * To introspect function parameters, first create an instance of the
- * ReflectionFunction or ReflectionMethod classes and then use their
- * ReflectionFunctionAbstract::getParameters() method to retrieve an array
- * of parameters.
- *
- */
- class ReflectionParameter implements Reflector {
- public $info;
- public $name;
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.construct.php )
- *
- * Constructs a ReflectionParameter class. Warning: This function is
- * currently not documented; only its argument list is available.
- *
- * @func mixed The function to reflect parameters from.
- * @param mixed The parameter.
- *
- * @return mixed No value is returned.
- */
- public function __construct($func, $param) {
- if ($func && $param) {
- $params = $func->getParameters();
- $this->info = $params[$param]->info;
- $this->name = $this->info['name'];
- }
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionparameter.tostring.php
- * )
- *
- * To string. Warning: This function is currently not documented; only its
- * argument list is available.
- *
- */
- public function __toString() {
- // TODO
- return "";
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionparameter.export.php )
- *
- * Exports. Warning: This function is currently not documented; only its
- * argument list is available.
- *
- * @func mixed The function name.
- * @param mixed The parameter name.
- * @ret mixed Setting to TRUE will return the export, as opposed
- * to emitting it. Setting to FALSE (the default) will
- * do the opposite.
- *
- * @return mixed The exported reflection.
- */
- public static function export($func, $param, $ret=false) {
- $obj = new ReflectionParameter($func, $param);
- $str = (string)$obj;
- if ($ret) {
- return $str;
- }
- print $str;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionparameter.getname.php
- * )
- *
- * Gets the name of the parameter.
- *
- * @return mixed The name of the reflected parameter.
- */
- public function getName() {
- return $this->info['name'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.ispassedbyreference.php )
- *
- * Checks if the parameter is passed in by reference. Warning: This
- * function is currently not documented; only its argument list is
- * available.
- *
- * @return mixed TRUE if the parameter is passed in by reference,
- * otherwise FALSE
- */
- public function isPassedByReference() {
- return isset($this->info['ref']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.getdeclaringclass.php )
- *
- * Gets the declaring class. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed A ReflectionClass object.
- */
- public function getDeclaringClass() {
- if (empty($this->info['class'])) {
- return null;
- }
- return new ReflectionClass($this->info['class']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.getdeclaringfunction.php )
- *
- * Gets the declaring function. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed A ReflectionFunction object.
- */
- public function getDeclaringFunction() {
- if (empty($this->info['class'])) {
- return new ReflectionFunction($this->info['function']);
- }
- return new ReflectionMethod($this->info['class'], $this->info['function']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionparameter.getclass.php
- * )
- *
- * Gets a class. Warning: This function is currently not documented; only
- * its argument list is available.
- *
- * @return mixed A ReflectionClass object.
- */
- public function getClass() {
- if (empty($this->info['type'])) {
- return null;
- }
- $ltype = strtolower($this->info['type']);
- if (hphp_scalar_typehints_enabled()) {
- $nonClassTypehints = array(
- 'bool' => 1,
- 'boolean' => 1,
- 'int' => 1,
- 'integer' => 1,
- 'real' => 1,
- 'double' => 1,
- 'float' => 1,
- 'string' => 1,
- 'array' => 1
- );
- if (isset($nonClassTypehints[$ltype])) {
- return null;
- }
- } else if ($ltype === 'array') {
- return null;
- }
- return new ReflectionClass($this->info['type']);
- }
- public function getTypehintText() {
- if (isset($this->info['type'])) {
- return $this->info['type'];
- }
- return '';
- }
- public function getTypeText() {
- if (isset($this->info['type_hint'])) {
- return $this->info['type_hint'];
- }
- return '';
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionparameter.isarray.php
- * )
- *
- * Checks if the parameter expects an array.
- *
- * @return mixed TRUE if an array is expected, FALSE otherwise.
- */
- public function isArray() {
- return $this->info['type'] == 'array';
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.allowsnull.php )
- *
- * Checks whether the parameter allows NULL. Warning: This function is
- * currently not documented; only its argument list is available.
- *
- * @return mixed TRUE if NULL is allowed, otherwise FALSE
- */
- public function allowsNull() {
- return isset($this->info['nullable']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.isoptional.php )
- *
- * Checks if the parameter is optional.
- *
- * @return mixed TRUE if the parameter is optional, otherwise FALSE
- */
- public function isOptional() {
- return array_key_exists('default', $this->info);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.isdefaultvalueavailable.php
- * )
- *
- * Checks if a default value for the parameter is available.
- *
- * @return mixed TRUE if a default value is available, otherwise
- * FALSE
- */
- public function isDefaultValueAvailable() {
- return array_key_exists('default', $this->info);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.getdefaultvalue.php )
- *
- * Gets the default value of the parameter for a user-defined function or
- * method. If the parameter is not optional a ReflectionException will be
- * thrown.
- *
- * @return mixed The parameters default value.
- */
- public function getDefaultValue() {
- if (!$this->isOptional()) {
- throw new ReflectionException('Parameter is not optional');
- }
- $defaultValue = $this->info['default'];
- if ($defaultValue instanceof stdclass) {
- if (isset($defaultValue->class)) {
- return hphp_get_class_constant($defaultValue->class,
- $defaultValue->name);
- }
- hphp_throw_fatal_error($defaultValue->msg);
- }
- return $defaultValue;
- }
- /**
- * @deprecated
- */
- public function getDefaultValueText() {
- return $this->getDefaultValueConstantName();
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.getdefaultvalueconstantname.php
- * )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns string on success or NULL on failure.
- */
- public function getDefaultValueConstantName() {
- if (isset($this->info['defaultText'])) {
- return $this->info['defaultText'];
- }
- return '';
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.getposition.php )
- *
- * Gets the position of the parameter.
- *
- * @return mixed The position of the parameter, left to right,
- * starting at position #0.
- */
- public function getPosition() {
- return $this->info['index'];
- }
- public function getAttribute($name) {
- $attrs = $this->info['attributes'];
- return isset($attrs[$name]) ? $attrs[$name] : null;
- }
- public function getAttributes() {
- return $this->info['attributes'];
- }
- public function getAttributeRecursive($name) {
- $attrs = $this->getAttributesRecursive();
- return isset($attrs[$name]) ? $attrs[$name] : null;
- }
- public function getAttributesRecursive() {
- if (!isset($this->info['class'])) {
- return $this->getAttributes();
- }
- $attrs = array();
- $class = $this->getDeclaringClass();
- $function_name = $this->info['function'];
- $index = $this->info['index'];
- self::collectAttributes(&$attrs, $class, $function_name, $index);
- return $attrs;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionparameter.iscallable.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns TRUE if the parameter is callable, FALSE if
- * it is not or NULL on failure.
- */
- public function isCallable() {
- return $this->info['type_hint'] === 'callable';
- }
- private static function collectAttributes(&$attrs, $class, $function_name,
- $index) {
- if ($class->hasMethod($function_name)) {
- $method = $class->getMethod($function_name);
- $params = $method->getParameters();
- if (count($params) >= $index) {
- $attrs += $params[$index]->getAttributes();
- }
- }
- $parent = $class->getParentClass();
- if ($parent) {
- self::collectAttributes(
- &$attrs,
- $parent,
- $function_name,
- $index);
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/class.reflectionfunctionabstract.php )
- *
- * A parent class to ReflectionFunction, read its description for details.
- *
- */
- class ReflectionFunctionAbstract {
- public $info;
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getname.php )
- *
- * Get the name of the function. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The name of the function.
- */
- public function getName() {
- return $this->info['name'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.isinternal.php )
- *
- * Checks whether the function is internal, as opposed to user-defined.
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed TRUE if it's internal, otherwise FALSE
- */
- public function isInternal() {
- return isset($this->info['internal']);
- }
- public function getClosure() {
- return $this->info['closure'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.isclosure.php )
- *
- * Checks whether it's a closure. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed TRUE if it's a closure, otherwise FALSE
- */
- public function isClosure() {
- return !empty($this->info['is_closure']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.isgenerator.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns TRUE if the function is generator, FALSE if
- * it is not or NULL on failure.
- */
- public function isGenerator() {
- return !empty($this->info['is_generator']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.isuserdefined.php )
- *
- * Checks whether the function is user-defined, as opposed to internal.
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed TRUE if it's user-defined, otherwise false;
- */
- public function isUserDefined() {
- return !isset($this->info['internal']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getfilename.php )
- *
- * Gets the file name from a user-defined function. Warning: This function
- * is currently not documented; only its argument list is available.
- *
- * @return mixed The file name.
- */
- public function getFileName() {
- return $this->info['file'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getstartline.php )
- *
- * Gets the starting line number of the function. Warning: This function
- * is currently not documented; only its argument list is available.
- *
- * @return mixed The starting line number.
- */
- public function getStartLine() {
- return $this->info['line1'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getendline.php )
- *
- * Get the ending line number. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The ending line number of the user defined function,
- * or FALSE if unknown.
- */
- public function getEndLine() {
- return $this->info['line2'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getdoccomment.php )
- *
- * Get a Doc comment from a function. Warning: This function is currently
- * not documented; only its argument list is available.
- *
- * @return mixed The doc comment if it exists, otherwise FALSE
- */
- public function getDocComment() {
- return $this->info['doc'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getstaticvariables.php
- * )
- *
- * Get the static variables. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed An array of static variables.
- */
- public function getStaticVariables() {
- return $this->info['static_variables'];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.returnsreference.php
- * )
- *
- * Checks whether the function returns a reference. Warning: This function
- * is currently not documented; only its argument list is available.
- *
- * @return mixed TRUE if it returns a reference, otherwise FALSE
- */
- public function returnsReference() {
- return isset($this->info['ref']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getparameters.php )
- *
- * Get the parameters as an array of ReflectionParameter. Warning: This
- * function is currently not documented; only its argument list is
- * available.
- *
- * @return mixed The parameters, as a ReflectionParameter object.
- */
- public function getParameters() {
- $ret = array();
- foreach ($this->info['params'] as $name => $info) {
- $param = new ReflectionParameter(null, null);
- $param->info = $info;
- $param->name = $info['name'];
- $ret[] = $param;
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getnumberofparameters.php
- * )
- *
- * Get the number of parameters that a function defines, both optional and
- * required. Warning: This function is currently not documented; only its
- * argument list is available.
- *
- * @return mixed The number of parameters.
- */
- public function getNumberOfParameters() {
- return count($this->info['params']);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunctionabstract.getnumberofrequiredparameters.php
- * )
- *
- * Get the number of required parameters that a function defines. Warning:
- * This function is currently not documented; only its argument list is
- * available.
- *
- * @return mixed The number of required parameters.
- */
- public function getNumberOfRequiredParameters() {
- $count = 0;
- $params = $this->getParameters();
- foreach ($params as $name => $param) {
- if ($param->isOptional()) {
- break;
- }
- $count++;
- }
- return $count;
- }
- public function getReturnTypeText() {
- if (isset($this->info['return_type'])) {
- return $this->info['return_type'];
- }
- return '';
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // function
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/class.reflectionfunction.php )
- *
- * The ReflectionFunction class reports information about a function.
- *
- */
- class ReflectionFunction extends ReflectionFunctionAbstract
- implements Reflector {
- const IS_DEPRECATED = 262144;
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionfunction.construct.php
- * )
- *
- * Constructs a ReflectionFunction object.
- *
- * @name mixed The name of the function to reflect or a closure.
- *
- * @return mixed No value is returned.
- */
- public function __construct($name) {
- if ($name instanceof Closure) {
- $this->info = hphp_get_closure_info($name);
- } else {
- $this->info = hphp_get_function_info($name);
- if (empty($this->info)) {
- throw new ReflectionException("Function $name does not exist");
- }
- }
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionfunction.tostring.php
- * )
- *
- * To string.
- *
- * @return mixed Returns ReflectionFunction::export()-like output for
- * the function.
- */
- public function __toString() {
- //TODO
- return "";
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionfunction.export.php )
- *
- * Exports a Reflected function.
- *
- * @name mixed The reflection to export.
- * @ret mixed Setting to TRUE will return the export, as opposed
- * to emitting it. Setting to FALSE (the default) will
- * do the opposite.
- *
- * @return mixed If the return parameter is set to TRUE, then the
- * export is returned as a string, otherwise NULL is
- * returned.
- */
- public static function export($name, $ret=false) {
- $obj = new ReflectionFunction($name);
- $str = (string)$obj;
- if ($ret) {
- return $str;
- }
- print $str;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionfunction.invoke.php )
- *
- * Invokes a reflected function.
- *
- * @return mixed Returns the result of the invoked function call.
- */
- public function invoke() {
- $args = func_get_args();
- if (isset($this->info['closureobj'])) {
- $closure = $this->info['closureobj'];
- return hphp_invoke_method($closure, get_class($closure),
- '__invoke', $args);
- }
- return hphp_invoke($this->info['name'], $args);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionfunction.invokeargs.php )
- *
- * Invokes the function and pass its arguments as array.
- *
- * @args mixed The passed arguments to the function as an array,
- * much like call_user_func_array() works.
- *
- * @return mixed Returns the result of the invoked function
- */
- public function invokeArgs($args) {
- if (isset($this->info['closureobj'])) {
- $closure = $this->info['closureobj'];
- return hphp_invoke_method($closure, get_class($closure),
- '__invoke', array_values($args));
- }
- return hphp_invoke($this->info['name'], array_values($args));
- }
- public function getAttribute($name) {
- $attrs = $this->info['attributes'];
- return isset($attrs[$name]) ? $attrs[$name] : null;
- }
- public function getAttributes() {
- return $this->info['attributes'];
- }
- public function getAttributeRecursive($name) {
- $attrs = $this->info['attributes'];
- return isset($attrs[$name]) ? $attrs[$name] : null;
- }
- public function getAttributesRecursive() {
- return $this->info['attributes'];
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // class
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/class.reflectionclass.php )
- *
- * The ReflectionClass class reports information about a class.
- *
- */
- class ReflectionClass implements Reflector {
- const IS_IMPLICIT_ABSTRACT = 16 ;
- const IS_EXPLICIT_ABSTRACT = 32 ;
- const IS_FINAL = 64 ;
- public $name;
- private $info = null;
- private static $fetched = array();
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.construct.php )
- *
- * Constructs a new ReflectionClass object. Warning: This function is
- * currently not documented; only its argument list is available.
- *
- * @name mixed Either a string containing the name of the class to
- * reflect, or an object.
- *
- * @return mixed No value is returned.
- */
- public function __construct($name) {
- if (is_object($name)) {
- $name = get_class($name);
- }
- $this->name = hphp_get_original_class_name($name);
- if (empty($this->name)) {
- throw new ReflectionException("Class $name does not exist");
- }
- }
- private function fetch($what) {
- if (!$this->info) {
- $this->info = self::fetch_recur($this->name);
- $this->info['properties'] += $this->info['private_properties'];
- }
- return $this->info[$what];
- }
- private static function fetch_recur($name) {
- if (isset(self::$fetched[$name])) return self::$fetched[$name];
- $info = hphp_get_class_info($name);
- if (empty($info)) {
- throw new ReflectionException("Class $name does not exist");
- }
- $info['attributes_rec'] = $info['attributes'];
- $abstract = isset($info['abstract']) || isset($info['interface']);
- // flattening the trees, so it's easier for lookups
- foreach ($info['interfaces'] as $interface => $_) {
- $p = self::fetch_recur($interface);
- if ($abstract) $info['methods'] += $p['methods'];
- $info['constants'] += $p['constants'];
- $info['interfaces'] += $p['interfaces'];
- }
- $parent = $info['parent'];
- if (!empty($parent)) {
- $p = self::fetch_recur($parent);
- if (isset($p['interface'])) {
- $info['interfaces'][$parent] = 1;
- } else {
- $info['properties'] += $p['properties'];
- }
- $info['methods'] += $p['methods'];
- $info['constants'] += $p['constants'];
- $info['interfaces'] += $p['interfaces'];
- $info['attributes_rec'] += $p['attributes_rec'];
- }
- self::$fetched[$name] = $info;
- return $info;
- }
- private function check($what) {
- if (!$this->info) {
- $this->info = self::fetch_recur($this->name);
- }
- return isset($this->info[$what]);
- }
- private function test($what, $name) {
- $v = $this->fetch($what);
- return $v && isset($v[$name]);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.tostring.php )
- *
- * Returns the string representation of the ReflectionClass object.
- *
- * @return mixed A string representation of this ReflectionClass
- * instance.
- */
- public function __toString() {
- return "";
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.export.php )
- *
- * Exports a reflected class.
- *
- * @name mixed The reflection to export.
- * @ret mixed Setting to TRUE will return the export, as opposed
- * to emitting it. Setting to FALSE (the default) will
- * do the opposite.
- *
- * @return mixed If the return parameter is set to TRUE, then the
- * export is returned as a string, otherwise NULL is
- * returned.
- */
- public static function export($name, $ret=false) {
- $obj = new ReflectionClass($name);
- $str = (string)$obj;
- if ($ret) {
- return $str;
- }
- print $str;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getname.php )
- *
- * Gets the class name. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The class name.
- */
- public function getName() {
- return $this->name;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.isinternal.php )
- *
- * Checks if the class is defined internally by an extension, or the core,
- * as opposed to user-defined.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isInternal() {
- return $this->check('internal');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.isuserdefined.php )
- *
- * Checks whether the class is user-defined, as opposed to internal.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isUserDefined() {
- return !$this->check('internal');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.isinstantiable.php )
- *
- * Checks if the class is instantiable.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isInstantiable() {
- return !$this->check('abstract');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.hasconstant.php
- * )
- *
- * Checks whether the class has a specific constant defined or not.
- *
- * @name mixed The name of the constant being checked for.
- *
- * @return mixed TRUE if the constant is defined, otherwise FALSE.
- */
- public function hasConstant($name) {
- return $this->test('constants', $name);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.hasmethod.php )
- *
- * Checks whether a specific method is defined in a class.
- *
- * @name mixed Name of the method being checked for.
- *
- * @return mixed TRUE if it has the method, otherwise FALSE
- */
- public function hasMethod($name) {
- return $this->test('methods', strtolower($name));
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.hasproperty.php
- * )
- *
- * Checks whether the specified property is defined.
- *
- * @name mixed Name of the property being checked for.
- *
- * @return mixed TRUE if it has the property, otherwise FALSE
- */
- public function hasProperty($name) {
- return $this->test('properties', $name);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getfilename.php
- * )
- *
- * Gets the filename of the file in which the class has been defined.
- *
- * @return mixed Returns the filename of the file in which the class
- * has been defined. If the class is defined in the PHP
- * core or in a PHP extension, FALSE is returned.
- */
- public function getFileName() {
- return $this->fetch('file');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getstartline.php
- * )
- *
- * Get the starting line number. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The starting line number, as an integer.
- */
- public function getStartLine() {
- return $this->fetch('line1');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getendline.php )
- *
- * Gets end line number from a user-defined class definition.
- *
- * @return mixed The ending line number of the user defined class, or
- * FALSE if unknown.
- */
- public function getEndLine() {
- return $this->fetch('line2');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getdoccomment.php )
- *
- * Gets doc comments from a class. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The doc comment if it exists, otherwise FALSE
- */
- public function getDocComment() {
- return $this->fetch('doc');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getconstructor.php )
- *
- * Gets the constructor of the reflected class.
- *
- * @return mixed A ReflectionMethod object reflecting the class'
- * constructor, or NULL if the class has no
- * constructor.
- */
- public function getConstructor() {
- if ($this->hasMethod('__construct')) {
- return $this->getMethod('__construct');
- }
- if (!$this->isTrait() && $this->hasMethod($name = $this->name)) {
- return $this->getMethod($name);
- }
- return null;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getmethod.php )
- *
- * Gets a ReflectionMethod for a class method.
- *
- * @name mixed The method name to reflect.
- *
- * @return mixed A ReflectionMethod.
- */
- public function getMethod($name) {
- if (!$this->info) {
- $method = hphp_get_method_info($this->name, $name);
- } else {
- $lname = strtolower($name);
- $methods = $this->info['methods'];
- if (isset($methods[$lname])) $method = $methods[$lname];
- }
- if (empty($method)) {
- $class = $this->name;
- throw new ReflectionException("Method $class::$name does not exist");
- }
- $ret = new ReflectionMethod(null, null);
- $ret->info = $method;
- $ret->name = $method['name'];
- $ret->class = $method['class'];
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getmethods.php )
- *
- * Gets an array of methods for the class.
- *
- * @filter mixed Filter the results to include only methods with
- * certain attributes. Defaults to no filtering.
- *
- * Any combination of ReflectionMethod::IS_STATIC,
- * ReflectionMethod::IS_PUBLIC,
- * ReflectionMethod::IS_PROTECTED,
- * ReflectionMethod::IS_PRIVATE,
- * ReflectionMethod::IS_ABSTRACT,
- * ReflectionMethod::IS_FINAL.
- *
- * @return mixed An array of ReflectionMethod objects reflecting each
- * method.
- */
- public function getMethods($filter = 0xFFFF) {
- $ret = array();
- $methods = $this->fetch('methods');
- foreach ($methods as $name => $_) {
- $m = $this->getMethod($name);
- if ((($filter & ReflectionMethod::IS_PUBLIC)) && $m->isPublic() ||
- (($filter & ReflectionMethod::IS_PROTECTED)) && $m->isProtected() ||
- (($filter & ReflectionMethod::IS_PRIVATE)) && $m->isPrivate() ||
- (($filter & ReflectionMethod::IS_STATIC)) && $m->isStatic() ||
- (($filter & ReflectionMethod::IS_FINAL)) && $m->isFinal() ||
- (($filter & ReflectionMethod::IS_ABSTRACT && $m->isAbstract()))) {
- $ret[] = $m;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getproperty.php
- * )
- *
- * Gets a ReflectionProperty for a class's property.
- *
- * @name mixed The property name.
- *
- * @return mixed A ReflectionProperty.
- */
- public function getProperty($name) {
- $properties = $this->fetch('properties');
- if (!isset($properties[$name])) {
- $class = $this->info['name'];
- throw new ReflectionException("Property $class::$name does not exist");
- }
- $cls = new ReflectionClass("ReflectionProperty");
- $ret = $cls->newInstanceWithoutConstructor();
- $ret->info = $properties[$name];
- $ret->name = $name;
- $ret->class = $this->info['name'];
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getproperties.php )
- *
- * Retrieves reflected properties.
- *
- * @filter mixed The optional filter, for filtering desired property
- * types. It's configured using the ReflectionProperty
- * constants, and defaults to all property types.
- *
- * @return mixed An array of ReflectionProperty objects.
- */
- public function getProperties($filter = 0xFFFF) {
- $ret = array();
- foreach ($this->fetch('properties') as $name => $_) {
- $p = $this->getProperty($name);
- if (($filter & ReflectionProperty::IS_PUBLIC) && $p->isPublic() ||
- ($filter & ReflectionProperty::IS_PROTECTED) && $p->isProtected() ||
- ($filter & ReflectionProperty::IS_PRIVATE) && $p->isPrivate() ||
- ($filter & ReflectionProperty::IS_STATIC) && $p->isStatic()) {
- $ret[] = $p;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getconstants.php
- * )
- *
- * Gets defined constants from a class. Warning: This function is
- * currently not documented; only its argument list is available.
- *
- * @return mixed An array of constants. Constant name in key,
- * constant value in value.
- */
- public function getConstants() {
- return $this->fetch('constants');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getconstant.php
- * )
- *
- * Gets the defined constant. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @name mixed Name of the constant.
- *
- * @return mixed Value of the constant.
- */
- public function getConstant($name) {
- $constants = $this->fetch('constants');
- if (!isset($constants[$name])) {
- $class = $this->info['name'];
- throw new ReflectionException("Class constant $class::$name does not exist");
- }
- return $constants[$name];
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getinterfaces.php )
- *
- * Gets the interfaces.
- *
- * @return mixed An associative array of interfaces, with keys as
- * interface names and the array values as
- * ReflectionClass objects.
- */
- public function getInterfaces() {
- $ret = array();
- foreach ($this->fetch('interfaces') as $name => $_) {
- $cls = new ReflectionClass($name);
- if ($cls->isInterface()) {
- $ret[$cls->getName()] = $cls;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.gettraits.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns an array with trait names in keys and
- * instances of trait's ReflectionClass in values.
- * Returns NULL in case of an error.
- */
- public function getTraits() {
- $ret = array();
- foreach ($this->fetch('traits') as $name => $_) {
- $cls = new ReflectionClass($name);
- if ($cls->isTrait()) {
- $ret[$cls->getName()] = $cls;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getinterfacenames.php )
- *
- * Get the interface names.
- *
- * @return mixed A numerical array with interface names as the
- * values.
- */
- public function getInterfaceNames() {
- $ret = array();
- foreach ($this->fetch('interfaces') as $name => $_) {
- $cls = new ReflectionClass($name);
- if ($cls->isInterface()) {
- $ret[] = $cls->getName();
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.gettraitnames.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns an array with trait names in values. Returns
- * NULL in case of an error.
- */
- public function getTraitNames() {
- $ret = array();
- foreach ($this->fetch('traits') as $name => $_) {
- $cls = new ReflectionClass($name);
- if ($cls->isTrait()) {
- $ret[] = $cls->getName();
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.gettraitaliases.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns an array with new method names in keys and
- * original names (in the format "TraitName::original")
- * in values. Returns NULL in case of an error.
- */
- public function getTraitAliases() {
- $ret = array();
- foreach ($this->fetch('trait_aliases') as $old_name => $new_name) {
- $ret[$old_name] = $new_name;
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.isinterface.php
- * )
- *
- * Checks whether the class is an interface.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isInterface() {
- return $this->check('interface');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.isabstract.php )
- *
- * Checks if the class is abstract.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isAbstract() {
- return $this->check('abstract');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.isfinal.php )
- *
- * Checks if a class is final.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isFinal() {
- return $this->check('final');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.istrait.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed Returns TRUE if this is a trait, FALSE otherwise.
- * Returns NULL in case of an error.
- */
- public function isTrait() {
- return $this->check('trait');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.getmodifiers.php
- * )
- *
- * Returns a bitfield of the access modifiers for this class.
- *
- * @return mixed Returns bitmask of modifier constants.
- */
- public function getModifiers() {
- return $this->fetch('modifiers');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.isinstance.php )
- *
- * Checks if an object is an instance of a class.
- *
- * @obj mixed The object being compared to.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isInstance($obj) {
- return hphp_instanceof($obj, $this->name);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.newinstance.php
- * )
- *
- * Creates a new instance of the class. The given arguments are passed to
- * the class constructor.
- *
- */
- public function newInstance() {
- $args = func_get_args();
- return hphp_create_object($this->name, $args);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.newinstanceargs.php )
- *
- * Creates a new instance of the class, the given arguments are passed to
- * the class constructor.
- *
- * @args mixed The parameters to be passed to the class constructor
- * as an array.
- *
- * @return mixed Returns a new instance of the class.
- */
- public function newInstanceArgs($args) {
- return hphp_create_object($this->name, array_values($args));
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php
- * )
- *
- * Creates a new instance of the class without invoking the constructor.
- *
- */
- public function newInstanceWithoutConstructor() {
- return hphp_create_object_without_constructor($this->name);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getparentclass.php )
- *
- * Warning: This function is currently not documented; only its argument
- * list is available.
- *
- * @return mixed A ReflectionClass.
- */
- public function getParentClass() {
- $parent = $this->fetch('parent');
- if (empty($parent)) {
- return false;
- }
- return new ReflectionClass($parent);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from http://php.net/manual/en/reflectionclass.issubclassof.php
- * )
- *
- * Checks if the class is a subclass of a specified class or implements a
- * specified interface.
- *
- * @cls mixed The class name being checked against.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isSubclassOf($cls) {
- if ($cls instanceof ReflectionClass) {
- $cls = $cls->name;
- }
- return is_subclass_of($this->name, $cls);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getstaticproperties.php )
- *
- * Get the static properties. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @return mixed The static properties, as an array.
- */
- public function getStaticProperties() {
- $ret = array();
- foreach ($this->getProperties() as $prop) {
- if ($prop->isStatic()) {
- $ret[$prop->name] = $prop;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getstaticpropertyvalue.php )
- *
- * Gets the value of a static property on this class.
- *
- * @name mixed The name of the static property for which to return
- * a value.
- * @default mixed
- *
- * @return mixed The value of the static property.
- */
- public function getStaticPropertyValue($name, $default = null) {
- if ($this->hasProperty($name) &&
- $this->getProperty($name)->isStatic()) {
- return hphp_get_static_property($this->name, $name, false);
- }
- return $default;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.setstaticpropertyvalue.php )
- *
- * Sets static property value. Warning: This function is currently not
- * documented; only its argument list is available.
- *
- * @name mixed Property name.
- * @value mixed New property value.
- *
- * @return mixed No value is returned.
- */
- public function setStaticPropertyValue($name, $value) {
- hphp_set_static_property($this->name, $name, $value, false);
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.getdefaultproperties.php )
- *
- * Gets default properties from a class (including inherited properties).
- *
- * This method only works for static properties when used on internal
- * classes. The default value of a static class property can not be tracked
- * when using this method on user defined classes.
- *
- * @return mixed An array of default properties, with the key being
- * the name of the property and the value being the
- * default value of the property or NULL if the
- * property doesn't have a default value. The function
- * does not distinguish between static and non static
- * properties and does not take visibility modifiers
- * into account.
- */
- public function getDefaultProperties() {
- $ret = array();
- foreach ($this->getProperties() as $prop) {
- if ($prop->isDefault()) {
- $ret[$prop->name] = $prop;
- }
- }
- return $ret;
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.isiterateable.php )
- *
- * Checks whether the class is iterateable.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function isIterateable() {
- return $this->isSubclassOf('ArrayAccess');
- }
- // This doc comment block generated by idl/sysdoc.php
- /**
- * ( excerpt from
- * http://php.net/manual/en/reflectionclass.implementsinterface.php )
- *
- * Checks whether it implements an interface.
- *
- * @cls mixed The interface name.
- *
- * @return mixed Returns TRUE on success or FALSE on failure.
- */
- public function implementsInterface($cls) {
- if ($cls instanceof ReflectionCla…
Large files files are truncated, but you can click here to view the full file