public function setForm(Form &$form, array $request) { $errors = array(); $form->befor_set(); $reflex = new ReflectionObject($form); $propts = $reflex->getParentClass()->getProperties(); foreach ($propts as $propt) { $name = $propt->getName(); $exis = method_exists($form, self::VALIDATE . $name); $value = isset($request[$name]) ? $request[$name] : null; $valid = self::VALIDATE . $name; $setvl = self::SET_METHOD . ucfirst($name); $respn = $exis ? $form->{$valid}($value) : true; if ($respn === true) { if (method_exists($form, $setvl)) { if ($value != null) { $form->{$setvl}($value); } } else { if ($value != null) { $propt->setAccessible(true); $propt->setValue($form, $value); $propt->setAccessible(false); } } } else { $errors[$name] = $respn; } } $form->after_set(); return count($errors) > 0 ? $errors : true; }
/** * @return string */ public function getViewTemplate() { // set default view name if (is_null($this->viewTemplate)) { $reflected = new \ReflectionObject($this); $viewTemplate = substr($reflected->getFileName(), 0, -4); $templateFound = false; foreach (self::$viewExtensions as $extension) { if (file_exists($viewTemplate . '.' . ltrim($extension, '.'))) { $templateFound = true; break; } } if (!$templateFound) { // try to get parent template if any $parentReflectedClass = $reflected->getParentClass(); if ($parentReflectedClass->isInstantiable() && $parentReflectedClass->implementsInterface(RenderableActionInterface::class)) { $parentViewTemplate = $parentReflectedClass->newInstance()->getViewTemplate(); $viewTemplate = $parentViewTemplate; } } $this->viewTemplate = $viewTemplate; } return $this->viewTemplate; }
/** * Executes the application. * * Available options: * * * interactive: Sets the input interactive flag * * decorated: Sets the output decorated flag * * verbosity: Sets the output verbosity flag * * capture_stderr_separately: Make output of stdOut and stdErr separately available * * @param array $input An array of arguments and options * @param array $options An array of options * * @return int The command exit code */ public function run(array $input, $options = array()) { $this->input = new ArrayInput($input); if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); } $this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately']; if (!$this->captureStreamsIndependently) { $this->output = new StreamOutput(fopen('php://memory', 'w', false)); if (isset($options['decorated'])) { $this->output->setDecorated($options['decorated']); } if (isset($options['verbosity'])) { $this->output->setVerbosity($options['verbosity']); } } else { $this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null); $errorOutput = new StreamOutput(fopen('php://memory', 'w', false)); $errorOutput->setFormatter($this->output->getFormatter()); $errorOutput->setVerbosity($this->output->getVerbosity()); $errorOutput->setDecorated($this->output->isDecorated()); $reflectedOutput = new \ReflectionObject($this->output); $strErrProperty = $reflectedOutput->getProperty('stderr'); $strErrProperty->setAccessible(true); $strErrProperty->setValue($this->output, $errorOutput); $reflectedParent = $reflectedOutput->getParentClass(); $streamProperty = $reflectedParent->getProperty('stream'); $streamProperty->setAccessible(true); $streamProperty->setValue($this->output, fopen('php://memory', 'w', false)); } return $this->statusCode = $this->application->run($this->input, $this->output); }
/** * Get a list of classes and traits to analyze. * * @param \ReflectionObject $reflectionObject The object to get the parents from. * * @return array The list of classes to read. */ public static function getClassesToRead(\ReflectionObject $reflectionObject) { $cacheId = md5("classesToRead:" . $reflectionObject->getName()); $objectClasses = self::getFromCache($cacheId); if ($objectClasses !== null) { return $objectClasses; } $objectClasses = array($reflectionObject); $objectTraits = $reflectionObject->getTraits(); if (!empty($objectTraits)) { foreach ($objectTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $reflectionObject->getParentClass(); while ($parentClass) { $objectClasses[] = $parentClass; $parentTraits = $parentClass->getTraits(); if (!empty($parentTraits)) { foreach ($parentTraits as $trait) { $objectClasses[] = $trait; } } $parentClass = $parentClass->getParentClass(); } self::saveToCache($cacheId, $objectClasses); return $objectClasses; }
public function getParentClass() { $parent = parent::getParentClass(); if ($parent) { $parent = new self($parent->getName()); } return $parent; }
/** * Return class declaration * * @param unknown_type $class */ public function getClassDeclaration($class) { //instantiate class $obj = new $class(); $ref = new ReflectionObject($obj); $parentClass = $ref->getParentClass()->getname(); $declaration = 'class ' . $class . ' extends ' . $parentClass; return $declaration; }
protected function set_document_owner_type($type = null) { if (is_null($type)) { $class = get_class($this); $r = new ReflectionObject($this); while (__CLASS__ != ($current_class = $r->getParentClass()->getName())) { $class = $current_class; $r = $r->getParentClass(); } $type = substr($class, 19); } $this->documentOwnerType = $type; }
/** * @param ReferenceRepository $referenceRepository * * @throws \RuntimeException * * @return string */ public function serialize(ReferenceRepository $referenceRepository) { $references = array(); $isORM = $referenceRepository->getManager() instanceof EntityManager; foreach ($referenceRepository->getReferences() as $name => $reference) { $reference = $referenceRepository->getReference($name); $references[$name]['identifier'] = $referenceRepository->getManager()->getUnitOfWork()->getEntityIdentifier($reference); if ($reference instanceof Proxy) { $ro = new \ReflectionObject($reference); $references[$name]['class'] = $ro->getParentClass()->getName(); } else { $references[$name]['class'] = get_class($reference); } } return serialize($references); }
public function props($originalObject) { $convertedObject = new \stdClass(); $reflectionObject = new \ReflectionObject($originalObject); $properties = $reflectionObject->getProperties(); // Если у класса есть родитльский класс // получаем свойства родительского класса $parentObject = $reflectionObject->getParentClass(); if ($parentObject instanceof \ReflectionClass) { $properties = array_merge($parentObject->getProperties(), $properties); } foreach ($properties as $item) { $annotation = $this->reader->getPropertyAnnotation($item, $this->annotationClass); if (null !== $annotation) { $propertyName = $annotation->getPropertyName(); $convertedObject->{$propertyName} = $annotation; } } return $convertedObject; }
/** * @return \FOS\HttpCacheBundle\HttpCache|\PHPUnit_Framework_MockObject_MockObject */ protected function getHttpCachePartialMock(array $mockedMethods = null) { $mock = $this->getMockBuilder('\FOS\HttpCacheBundle\HttpCache') ->setMethods( $mockedMethods ) ->disableOriginalConstructor() ->getMock(); // Force setting options property since we can't use original constructor. $options = array( 'debug' => false, 'default_ttl' => 0, 'private_headers' => array( 'Authorization', 'Cookie' ), 'allow_reload' => false, 'allow_revalidate' => false, 'stale_while_revalidate' => 2, 'stale_if_error' => 60, ); $refMock = new \ReflectionObject($mock); $refHttpCache = $refMock // \FOS\HttpCacheBundle\HttpCache ->getParentClass() // \Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache ->getParentClass() // \Symfony\Component\HttpKernel\HttpCache\HttpCache ->getParentClass(); // Workaround for Symfony 2.3 where $options property is not defined. if (!$refHttpCache->hasProperty('options')) { $mock->options = $options; } else { $refOptions = $refHttpCache ->getProperty('options'); $refOptions->setAccessible(true); $refOptions->setValue($mock, $options ); } return $mock; }
/** * cfdump-style debugging output * @param $var The variable to output. * @param $limit Maximum recursion depth for arrays (default 0 = all) * @param $label text to display in complex data type header * @param $depth Current depth (default 0) */ public function dump(&$var, $limit = 0, $label = '', $depth = 0) { if ($limit > 0 && $depth >= $limit) { return; } static $seen = array(); $he = function ($s) { return htmlentities($s); }; $self = $this; $echoFunction = function ($var, $tabs, $label = '') use($self) { if (!is_subclass_of($var, 'ReflectionFunctionAbstract')) { $var = new \ReflectionFunction($var); } echo "{$tabs}<table class=\"dump function\">{$tabs}<thead><tr><th>" . ($label != '' ? $label . ' - ' : '') . (is_callable(array($var, 'getModifiers')) ? htmlentities(implode(' ', \Reflection::getModifierNames($var->getModifiers()))) : '') . " function " . htmlentities($var->getName()) . "</th></tr></thead>{$tabs}<tbody>"; echo "{$tabs}<tr><td class=\"value\">{$tabs}<table class=\"dump layout\">{$tabs}<tr><th>Parameters:</th><td>"; $params = $var->getParameters(); if (count($params) > 0) { echo "</td></tr>{$tabs}<tr><td colspan=\"2\">{$tabs}<table class=\"dump param\">{$tabs}<thead><tr><th>Name</th><th>Array/Ref</th><th>Required</th><th>Default</th></tr></thead>{$tabs}<tbody>"; foreach ($params as $param) { echo "{$tabs}<tr><td>" . htmlentities($param->getName()) . "</td><td>" . ($param->isArray() ? "Array " : "") . ($param->isPassedByReference() ? "Reference" : "") . "</td><td>" . ($param->isOptional() ? "Optional" : "Required") . "</td><td>"; if ($param->isOptional()) { $self->dump($param->getDefaultValue()); } echo "</td></tr>"; } echo "{$tabs}</tbody>{$tabs}</table>"; } else { echo "none</td></tr>"; } $comment = trim($var->getDocComment()); if ($comment !== NULL && $comment !== '') { echo "{$tabs}<tr><th>Doc Comment:</th><td><kbd>" . str_replace("\n", "<br/>", htmlentities($comment)) . "</kbd></td></tr>"; } echo "</table>{$tabs}</td></tr>"; echo "{$tabs}</tbody>{$tabs}</table>"; }; $tabs = "\n" . str_repeat("\t", $depth); $depth++; $printCount = 0; if (!array_key_exists('fw1dumpstarted', $_REQUEST)) { $_REQUEST['fw1dumpstarted'] = TRUE; echo <<<DUMPCSS <style type="text/css">/* fw/1 dump */ table.dump { color: black; background-color: white; font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; border-spacing: 0; border-collapse: collapse; } table.dump th { text-indent: -2em; padding: 0.25em 0.25em 0.25em 2.25em; color: #fff; } table.dump td { padding: 0.25em; } table.dump th, table.dump td { border-width: 2px; border-style: solid; border-spacing: 0; vertical-align: top; text-align: left; } table.dump.object, table.dump.object td, table.dump.object th { border-color: #f00; } table.dump.object th { background-color: #f44; } table.dump.object .key { background-color: #fcc; } table.dump.array, table.dump.array td, table.dump.array th { border-color: #060; } table.dump.array th { background-color: #090; } table.dump.array .key { background-color: #cfc; } table.dump.struct, table.dump.struct td, table.dump.struct th { border-color: #00c; } table.dump.struct th { background-color: #44c; } table.dump.struct .key { background-color: #cdf; } table.dump.function, table.dump.function td, table.dump.function th { border-color: #a40; } table.dump.function th { background-color: #c60; } table.dump.layout, table.dump.layout td, table.dump.layout th { border-color: #fff; } table.dump.layout th { font-style: italic; background-color: #fff; color: #000; font-weight: normal; } table.dump.param, table.dump.param td, table.dump.param th { border-color: #ddd; } table.dump.param th { background-color: #eee; color: black; font-weight: bold; } </style> DUMPCSS; } if (is_array($var)) { $label = $label === '' ? $var === $_POST ? '$_POST' : ($var === $_GET ? '$_GET' : ($var === $_COOKIE ? '$_COOKIE' : ($var === $_ENV ? '$_ENV' : ($var === $_FILES ? '$_FILES' : ($var === $_REQUEST ? '$_REQUEST' : ($var === $_SERVER ? '$_SERVER' : ($var === $_SESSION ? '$_SESSION' : ''))))))) : $label; $c = count($var); if (isset($var['fw1recursionsentinel'])) { echo "(Recursion)"; } $aclass = $c > 0 && array_key_exists(0, $var) && array_key_exists($c - 1, $var) ? 'array' : 'struct'; $var['fw1recursionsentinel'] = true; echo "{$tabs}<table class=\"dump {$aclass}\">{$tabs}<thead><tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "array" . ($c > 0 ? "" : " [empty]") . "</th></tr></thead>{$tabs}<tbody>"; foreach ($var as $index => $aval) { if ($index === 'fw1recursionsentinel') { continue; } echo "{$tabs}<tr><td class=\"key\">" . $he($index) . "</td><td class=\"value\">"; $this->dump($aval, $limit, '', $depth); echo "</td></tr>"; $printCount++; if ($limit > 0 && $printCount >= $limit && $aclass === 'array') { break; } } echo "{$tabs}</tbody>{$tabs}</table>"; // unset($var['fw1recursionsentinel']); } elseif (is_string($var)) { echo $var === '' ? '[EMPTY STRING]' : htmlentities($var); } elseif (is_bool($var)) { echo $var ? "TRUE" : "FALSE"; } elseif (is_callable($var) || is_object($var) && is_subclass_of($var, 'ReflectionFunctionAbstract')) { $echoFunction($var, $tabs, $label); } elseif (is_float($var)) { echo "(float) " . htmlentities($var); } elseif (is_int($var)) { echo "(int) " . htmlentities($var); } elseif (is_null($var)) { echo "NULL"; } elseif (is_object($var)) { $ref = new \ReflectionObject($var); $parent = $ref->getParentClass(); $interfaces = implode("<br/>implements ", $ref->getInterfaceNames()); try { $serial = serialize($var); } catch (\Exception $e) { $serial = 'hasclosure' . $ref->getName(); } $objHash = 'o' . md5($serial); $refHash = 'r' . md5($ref); echo "{$tabs}<table class=\"dump object\"" . (isset($seen[$refHash]) ? "" : "id=\"{$refHash}\"") . ">{$tabs}<thead>{$tabs}<tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "object " . htmlentities($ref->getName()) . ($parent ? "<br/>extends " . $parent->getName() : "") . ($interfaces !== '' ? "<br/>implements " . $interfaces : "") . "</th></tr>{$tabs}<tbody>"; if (isset($seen[$objHash])) { echo "{$tabs}<tr><td colspan=\"2\"><a href=\"#{$refHash}\">[see above for details]</a></td></tr>"; } else { $seen[$objHash] = TRUE; $constants = $ref->getConstants(); if (count($constants) > 0) { echo "{$tabs}<tr><td class=\"key\">CONSTANTS</td><td class=\"values\">{$tabs}<table class=\"dump object\">"; foreach ($constants as $constant => $cval) { echo "{$tabs}<tr><td class=\"key\">" . htmlentities($constant) . "</td><td class=\"value constant\">"; $this->dump($cval, $limit, '', $depth); echo "</td></tr>"; } echo "{$tabs}</table>{$tabs}</td></tr>"; } $properties = $ref->getProperties(); if (count($properties) > 0) { echo "{$tabs}<tr><td class=\"key\">PROPERTIES</td><td class=\"values\">{$tabs}<table class=\"dump object\">"; foreach ($properties as $property) { echo "{$tabs}<tr><td class=\"key\">" . htmlentities(implode(' ', \Reflection::getModifierNames($property->getModifiers()))) . " " . $he($property->getName()) . "</td><td class=\"value property\">"; $wasHidden = $property->isPrivate() || $property->isProtected(); $property->setAccessible(TRUE); $this->dump($property->getValue($var), $limit, '', $depth); if ($wasHidden) { $property->setAccessible(FALSE); } echo "</td></tr>"; } echo "{$tabs}</table>{$tabs}</td></tr>"; } $methods = $ref->getMethods(); if (count($methods) > 0) { echo "{$tabs}<tr><td class=\"key\">METHODS</td><td class=\"values\">"; if (isset($seen[$refHash])) { echo "<a href=\"#{$refHash}\">[see above for details]</a>"; } else { $seen[$refHash] = TRUE; echo "{$tabs}<table class=\"dump object\">"; foreach ($methods as $method) { echo "{$tabs}<tr><td class=\"key\">" . htmlentities($method->getName()) . "</td><td class=\"value function\">"; $echoFunction($method, $tabs, ''); echo "</td></tr>"; } echo "{$tabs}</table>"; } echo "{$tabs}</td></tr>"; } } echo "{$tabs}</tbody>{$tabs}</table>"; } elseif (is_resource($var)) { echo "(Resource)"; } elseif (is_numeric($var)) { echo htmlentities($var); } elseif (is_scalar($var)) { echo htmlentities($var); } else { echo gettype($var); } }
/** * This test tests if the clientConfiguration from the Configuration object * is actually passed to the client if the constructor creates it's own client. * * @dataProvider booleanValues * @test */ public function clientConfigurationIsPassedToHttpClient($verify) { $configurationArray = $this->mergeConfigurationWithMinimalConfiguration(); $clientConfiguration = ['verify' => $verify]; $configurationArray['clientConfiguration'] = $clientConfiguration; $configuration = new Configuration($configurationArray); $client = $this->createClient($configuration); $reflectionObject = new \ReflectionObject($client); $clientProperty = $reflectionObject->getParentClass()->getProperty('client'); $clientProperty->setAccessible(true); $httpClient = $clientProperty->getValue($client); $this->assertEquals($clientConfiguration['verify'], $httpClient->getConfig()['verify']); }
/** * prints out information about the $this arg * * @since 9-23-09 * * object info uses the reflection class http://nz.php.net/manual-lookup.php?pattern=oop5.reflection&lang=en * * @todo * - get the parent classes methods and values and stuff, then organize the methods by visible and invisible (private, protected) * - this might be a good way for aIter to display classes also, but just get the properties of the object * * @param string $calling_class the class name of the class that made the call * @return string information about the arg */ function outInfo($calling_class = '') { $this->useName(false); $config = $this->config(); $config->outEnquote(false); $config->outObject(false); $type = $this->type(); $format_handler = new out_format($config); $name = $this->name(); $val = $this->value(); $info_list = array(); $info_type = 'undefined'; switch ($type) { case self::TYPE_NULL: $info_type = 'NULL'; break; case self::TYPE_STRING_VAL: case self::TYPE_STRING_LITERAL: case self::TYPE_STRING_GENERATED: $info_type = 'string'; $info_list[] = sprintf('value: %s', $format_handler->enquote($val)); $info_list[] = sprintf('%d characters', mb_strlen($val)); break; ///case self::TYPE_STRING_EMPTY: break; ///case self::TYPE_STRING_EMPTY: break; case self::TYPE_NUMERIC: if (is_int($val)) { $info_type = 'integer'; } else { if (is_float($val)) { $info_type = 'float'; } } //if/else if $info_list[] = sprintf('value: %s', $val); break; case self::TYPE_ARRAY: $info_type = 'array'; // find out if it is an indexed array... $info_list = array(); $info_list[] = 'length: ' . count($val); if (!empty($val)) { $info_list[] = ctype_digit(join('', array_keys($val))) ? 'keys are numeric' : 'keys are associative'; } //if break; case self::TYPE_OBJECT: $rclass = new ReflectionObject($val); $info_type = $rclass->getName() . ' instance'; $indent = $this->indent; if ($path = $rclass->getFileName()) { $file_map = new out_file($path); $file_map->config($config); $info_list[] = sprintf('%s %s %s', $format_handler->wrap('b', 'Defined:'), $rclass->getName(), $file_map->out(true, false)); } //if $class_name_list = array($rclass->getName()); // get all the classes this object extends... if ($parent_class = $rclass->getParentClass()) { $info_list[] = $format_handler->wrap('b', 'Extends:'); while (!empty($parent_class)) { $class_name_list[] = $parent_class->getName(); $file_map = new out_file($parent_class->getFileName()); $file_map->config($config); $info_list[] = sprintf('%s%s %s', $indent, $parent_class->getName(), $file_map->out(true, false)); $parent_class = $parent_class->getParentClass(); } //while } //if // handle properties... $properties = $rclass->getProperties(); $info_list[] = $format_handler->wrap('b', sprintf('%s (%d):', 'Properties', count($properties))); $prop_val = null; $prop_check = true; foreach ($properties as $property) { // setAccessible only around >5.3... if (method_exists($property, 'setAccessible')) { $property->setAccessible(true); $prop_val = $property->getValue($val); } else { if ($property->isPublic()) { $prop_val = $property->getValue($val); } else { $prop_val = $format_handler->wrap('i', 'Not Accessible'); $prop_check = false; } //if/else } //if/else if (is_array($prop_val)) { $prop_val = $format_handler->escapeArray(trim($this->aIter($prop_val, 2, false))); } else { if ($prop_check) { $arg_map = new out_arg('', $prop_val); $prop_val = $arg_map->defaultValue(); } //if } //if/else $info_list[] = sprintf('%s%s %s = %s', $indent, $format_handler->wrap('span', join(' ', Reflection::getModifierNames($property->getModifiers())), out_config::COLOR_MODIFIER), $format_handler->wrap('span', $property->getName(), out_config::COLOR_PARAM), $prop_val); } //foreach // handle methods... $methods = $rclass->getMethods(); $info_list[] = $format_handler->wrap('b', sprintf('%s (%d):', 'Methods', count($methods))); $method_list = array(); $only_public_methods = empty($calling_class) ? true : !in_array($calling_class, $class_name_list); foreach ($methods as $method) { // we only want to show methods the person can use... if ($only_public_methods && !$method->isPublic()) { continue; } //if $method_comment = $method->getDocComment(); $params = $method->getParameters(); $param_list = array(); foreach ($params as $param) { $param_type = ''; if (!empty($method_comment)) { $match = array(); if (preg_match(sprintf('#\\*\\s*@param\\s+(\\S+)\\s+\\$%s#iu', preg_quote($param->getName())), $method_comment, $match)) { $param_type = $format_handler->wrap('span', $match[1], out_config::COLOR_TYPE) . ' '; } //if } //if $param_str = $format_handler->wrap('span', sprintf('%s$%s', $param_type, $param->getName()), out_config::COLOR_PARAM); if ($param->isDefaultValueAvailable()) { $arg_map = new out_arg('', $param->getDefaultValue()); $param_str .= ' = ' . $arg_map->defaultValue(); } //if $param_list[] = $param_str; } //foreach // see if we can get a return type for the method... $method_return_type = ''; if (!empty($method_comment)) { $match = array(); if (preg_match('#\\*\\s*@return\\s+(\\S+)#iu', $method_comment, $match)) { $method_return_type = ' ' . $format_handler->wrap('span', $match[1], out_config::COLOR_TYPE); } //if } //if $method_list[$method->getName()] = sprintf('%s%s%s %s(%s)', $indent, $format_handler->wrap('span', join(' ', Reflection::getModifierNames($method->getModifiers())), out_config::COLOR_MODIFIER), $method_return_type, $method->getName(), join(', ', $param_list)); } //foreach ksort($method_list); $info_list = array_merge($info_list, array_values($method_list)); // handle constants... $constants = $rclass->getConstants(); $info_list[] = $format_handler->wrap('b', sprintf('%s (%d):', 'Constants', count($constants))); foreach ($constants as $const_name => $const_val) { $info_list[] = sprintf('%s%s = %s', $indent, $format_handler->wrap('span', $const_name, out_config::COLOR_PARAM), $const_val); } //foreach break; case self::TYPE_BOOLEAN: $info_type = 'boolean'; $info_list[] = sprintf('value: %s', $this->defaultValue()); break; case self::TYPE_BREAK: $info_type = 'break'; $info_list[] = sprintf('lines: %d', $this->name()); break; case self::TYPE_UNDEFINED: default: $type = 'undefined'; break; } //switch $this->printValue(sprintf("%s (%s)\r\n%s", $format_handler->wrap('b', $name), $info_type, empty($info_list) ? '' : join("\r\n", $info_list) . "\r\n")); return $this->outAll(); }
private function _reflectionParent(\ReflectionObject $reflection) { if ($pc = $reflection->getParentClass()) { $name = '<span class="d-information" title="Class this object extends"></span> '; $name .= '<span class="d-obj-info">Extends</span>'; // $inst = $pc->newInstanceWithoutConstructor(); $this->render($pc->name, $name); } }
function fetch() { $this->setup(); $this->_slots = $this->_event->filter('template.slots', $this, $this->_slots); ob_start(); $this->content(); $this->assign('_content', trim(ob_get_clean())); $extends = $this->_extends; if (null === $extends) { $r = new \ReflectionObject($this); $p = $r->getParentClass(); if ($p && $p->name != 'greebo\\conveniences\\Template') { $extends = $p->name; } } return $extends ? $this->render($extends, $this->_raw) : $this->_content; }
/** * Prepend some data * * @param VisitorInterface $visitor * @param array $prependData */ protected function prependData(VisitorInterface $visitor, array $prependData) { $refl = new \ReflectionObject($visitor); $property = $refl->getParentClass()->getParentClass()->getProperty('data'); $property->setAccessible(true); $data = $property->getValue($visitor); $data = $prependData + $data; $property->setValue($visitor, $data); }
/** * Returns all the parents for this object static with the youngest to the oldest * The resolution order to follow when going up a inheritance hierarchy. * * @return array this an array of ReflectionClass * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public function getParents($stopAt = []) { $reflectionClass = new \ReflectionObject($this); $parents = []; while ($reflectionClass->getParentClass()) { $reflectionClass = $reflectionClass->getParentClass(); if (in_array($reflectionClass->getName(), $stopAt)) { break; } $parents[$reflectionClass->getName()] = $reflectionClass; } return $parents; }
static function drawObject(&$source, &$parents) { $className = get_class($source); $object_index = self::getObjectId($source); $object_id = 'dhph_' . $className . '_' . self::$calls . '_' . $object_index; if (self::isRecursiveObject($source, $parents)) { self::drawValue('<a href="#' . $object_id . '" onclick="dumphper_show(this);">' . $className . ' #' . $object_index . '</a>', 'recursion'); } else { $sClass = new ReflectionObject($source); $statics = null; $class = $sClass->getParentClass(); $classArray = ''; while (is_object($class)) { $classArray = ' > ' . $class->getName() . $classArray; $class = $class->getParentClass(); } echo '<div class="dumphper-container' . (self::$depth <= self::$max_showw_depth ? '' : ' dumphper-closed') . '">'; self::drawHeader('<a id="' . $object_id . '" name="' . $object_id . '" class="dumphper-toggler" href="javascript:;" onclick="dumphper_toggle(this);">' . $className . ' #' . $object_index . (count($classArray) ? ' <span class="dumphper-class-def"> ' . $classArray . '</span>' : '') . '</a>', 'object'); echo '<table class="dumphper-table" cellspacing="0" cellpadding="0">'; if (!DPHP_USE_ACCESSIBLE) { $temp = (array) $source; } $class = $sClass; while (is_object($class)) { if (!property_exists($source, '*_methods') && !$source instanceof Closure) { $reflectionClass = new ReflectionClass($source); $methods = $reflectionClass->getMethods(); $methodsList = array(); foreach ($methods as $reflectionMethod) { if ($reflectionMethod->isPublic()) { $methodString = $reflectionMethod->name; $Parameters = $reflectionMethod->getParameters(); if (count($Parameters) > 0) { $argList = array(); foreach ($Parameters as $p) { $argList[] = '$' . $p; } $argList = implode(', ', $argList); $methodString .= "({$argList})"; } $methodsList[] = $methodString; } } //var_dump($methodsList);die; $source->{"*_methods"} = $methodsList; } $properties = $class->getProperties(); if ($class->name != $className && count($properties)) { echo '<tr><td colspan = "2">'; self::drawValue('<code>inherited from </code>' . $class->name . ':', 'inherited'); echo '</td></tr>'; } foreach ($properties as &$value) { $declaredClass = $value->getDeclaringClass()->name; if ($class->name == $declaredClass) { echo '<tr><td class="dumphper-key-object">'; self::drawValue($value->name, join('-', Reflection::getModifierNames($value->getModifiers()))); echo '</td><td>'; if ($value->isPublic()) { $tmp = $value->getValue($source); self::_dump($tmp, $parents); } elseif (DPHP_USE_ACCESSIBLE) { $value->setAccessible(true); $tmp = $value->getValue($source); self::_dump($tmp, $parents); } elseif ($value->isStatic()) { if (!$statics) { $statics = $class->getStaticProperties(); } self::_dump($statics[$value->name], $parents); } else { $scope = $value->isPrivate() ? $value->class : '*'; self::_dump($temp["{$scope}{$value->name}"], $parents); } echo '</td></tr>'; } } $class = $class->getParentClass(); } echo '</table>'; echo '</div>'; } }
/** * Get the HTML part from the email. * * This is a current restriction since the BaseMessage class doesn't provide * method to get the rendered HTML. * * This only works in \yii\swiftmailer\Message. * * @param \yii\mail\BaseMessage $message * @return string|null the HTML string or null if not found. */ private static function getHtmlBody($message) { if ($message instanceof \yii\swiftmailer\Message) { $swiftMessage = $message->getSwiftMessage(); $r = new \ReflectionObject($swiftMessage); $parentClassThatHasBody = $r->getParentClass()->getParentClass()->getParentClass(); //\Swift_Mime_SimpleMimeEntity $body = $parentClassThatHasBody->getProperty('_immediateChildren'); $body->setAccessible(true); $children = $body->getValue($swiftMessage); foreach ($children as $child) { if ($child instanceof \Swift_MimePart && $child->getContentType() == 'text/html') { return $child->getBody(); } } } return null; }
/** * Get a modified ErrorException object that is mocked with the required properties. * * @param string $message * @param string $file * @param integer $line * @param array $trace * * @return \ErrorException */ private function getErrorExceptionMock($message, $file, $line, array $trace = array()) { $exception = new \ErrorException($message); $reflection = new \ReflectionObject($exception); $fileProperty = $reflection->getProperty('file'); $fileProperty->setAccessible(true); $fileProperty->setValue($exception, $file); $lineProperty = $reflection->getProperty('line'); $lineProperty->setAccessible(true); $lineProperty->setValue($exception, $line); $traceProperty = $reflection->getParentClass()->getProperty('trace'); $traceProperty->setAccessible(true); $traceProperty->setValue($exception, $trace); return $exception; }
/** * cfdump-style debugging output * @param $var The variable to output. * @param $limit Maximum recursion depth for arrays (default 0 = all) * @param $label text to display in complex data type header * @param $depth Current depth (default 0) */ public static function dump(&$var, $limit = 0, $label = '', $depth = 0) { if (!is_int($depth)) $depth = 0; if (!is_int($limit)) $limit = 0; if (($limit > 0) && ($depth >= $limit)) return; static $seen = array(); $he = function ($s) { return htmlentities($s); }; $tabs = "\n" . str_repeat("\t", $depth); $depth++; $printCount = 0; self::dumpCssJs(); if (is_array($var)) { // It turns out that identity (===) in PHP isn't actually identity. It's more like "do you look similar enough to fool an untrained observer?". Lame! // $label = $label === '' ? (($var === $_POST) ? '$_POST' : (($var === $_GET) ? '$_GET' : (($var === $_COOKIE) ? '$_COOKIE' : (($var === $_ENV) ? '$_ENV' : (($var === $_FILES) ? '$_FILES' : (($var === $_REQUEST) ? '$_REQUEST' : (($var === $_SERVER) ? '$_SERVER' : (isset($_SESSION) && ($var === $_SESSION) ? '$_SESSION' : '')))))))) : $label; $c = count($var); if(isset($var['fw1recursionsentinel'])) { echo "(Recursion)"; } $aclass = (($c > 0) && array_key_exists(0, $var) && array_key_exists($c - 1, $var)) ? 'array' : 'struct'; $var['fw1recursionsentinel'] = true; echo "$tabs<table class=\"dump ${aclass} depth${depth}\">$tabs<thead><tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "array" . ($c > 0 ? "" : " [empty]") . "</th></tr></thead>$tabs<tbody>"; foreach ($var as $index => $aval) { if ($index === 'fw1recursionsentinel') continue; echo "$tabs<tr><td class=\"key\">" . $he($index) . "</td><td class=\"value\"><div>"; self::dump($aval, $limit, '', $depth); echo "</div></td></tr>"; $printCount++; if (($limit > 0) && ($printCount >= $limit) && ($aclass === 'array')) break; } echo "$tabs</tbody>$tabs</table>"; // unset($var['fw1recursionsentinel']); } elseif (is_string($var)) { echo $var === '' ? '[EMPTY STRING]' : htmlentities($var); } elseif (is_bool($var)) { echo $var ? "TRUE" : "FALSE"; } elseif (is_callable($var) || (is_object($var) && is_subclass_of($var, 'ReflectionFunctionAbstract'))) { self::dumpFunction($var, $tabs, $limit, $label, $depth); } elseif (is_resource($var)) { echo "(Resource)"; } elseif (is_float($var)) { echo "(float) " . htmlentities($var); } elseif (is_int($var)) { echo "(int) " . htmlentities($var); } elseif (is_null($var)) { echo "NULL"; } elseif (is_object($var)) { $ref = new \ReflectionObject($var); $parent = $ref->getParentClass(); $interfaces = implode("<br/>implements ", $ref->getInterfaceNames()); $objHash = spl_object_hash($var); $refHash = 'r' . md5($ref); $objClassName = $ref->getName(); if ($objClassName === 'SimpleXMLElement') { echo "$tabs<table class=\"dump xml depth${depth}\">$tabs<thead>$tabs<tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "xml element</th></tr>$tabs<tbody>"; self::trKeyValue('Name', $var->getName()); // echo "<tr><td class=\"key\">Name</td><td class=\"value\">" . htmlentities($var->getName()) . "</td></tr>\n"; $attribs = array(); foreach ($var->attributes() as $attribName => $attribValue) { $attribs[$attribName] = $attribValue; } if (count($attribs) > 0) { echo "$tabs<tr><td class=\"key\">Attributes</td><td class=\"values\"><div>$tabs<table class=\"dump xml attributes\"><tbody>"; foreach ($attribs as $attribName => $attribValue) { self::trKeyValue($attribName, $attribValue); } echo "$tabs</tbody></table>$tabs</div></td></tr>"; } $xmlText = trim((string) $var); if ($xmlText !== '') { self::trKeyValue('Text', $xmlText); } if ($var->count() > 0) { echo "$tabs<tr><td class=\"key\">Children</td><td class=\"values\"><div>$tabs<table class=\"dump xml children\"><tbody>"; $childNum = 0; foreach ($var->children() as $child) { echo "$tabs<tr><td class=\"key\">" . $childNum . "</td><td class=\"value child\"><div>"; self::dump($child, $limit, '', $depth + 1); echo "</div></td></tr>"; $childNum++; } echo "$tabs</tbody></table>$tabs</div></td></tr>"; } } else { echo "$tabs<table class=\"dump object depth${depth}\"" . (isset($seen[$refHash]) ? "" : "id=\"$refHash\"") . ">$tabs<thead>$tabs<tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "object " . htmlentities($objClassName) . ($parent ? "<br/>extends " .$parent->getName() : "") . ($interfaces !== '' ? "<br/>implements " . $interfaces : "") . "</th></tr>$tabs<tbody>"; if (isset($seen[$objHash])) { echo "$tabs<tr><td colspan=\"2\"><a href=\"#$refHash\">[see above for details]</a></td></tr>"; } else { $seen[$objHash] = TRUE; $constants = $ref->getConstants(); if (count($constants) > 0) { echo "$tabs<tr><td class=\"key\">CONSTANTS</td><td class=\"values\"><div>$tabs<table class=\"dump object\">"; foreach ($constants as $constant => $cval) { echo "$tabs<tr><td class=\"key\">" . htmlentities($constant) . "</td><td class=\"value constant\"><div>"; self::dump($cval, $limit, '', $depth + 1); echo "</div></td></tr>"; } echo "$tabs</table>$tabs</div></td></tr>"; } $properties = $ref->getProperties(); if (count($properties) > 0) { echo "$tabs<tr><td class=\"key\">PROPERTIES</td><td class=\"values\"><div>$tabs<table class=\"dump object\">"; foreach ($properties as $property) { echo "$tabs<tr><td class=\"key\">" . htmlentities(implode(' ', \Reflection::getModifierNames($property->getModifiers()))) . " " . $he($property->getName()) . "</td><td class=\"value property\"><div>"; $wasHidden = $property->isPrivate() || $property->isProtected(); $property->setAccessible(TRUE); $propVal = $property->getValue($var); self::dump($propVal, $limit, '', $depth + 1); if ($wasHidden) { $property->setAccessible(FALSE); } echo "</div></td></tr>"; } echo "$tabs</table>$tabs</div></td></tr>"; } $methods = $ref->getMethods(); if (count($methods) > 0) { echo "$tabs<tr><td class=\"key\">METHODS</td><td class=\"values shh\"><div>"; if (isset($seen[$refHash])) { echo "<a href=\"#$refHash\">[see above for details]</a>"; } else { $seen[$refHash] = TRUE; echo "$tabs<table class=\"dump object\">"; foreach ($methods as $method) { echo "$tabs<tr><td class=\"key\">" . htmlentities($method->getName()) . "</td><td class=\"value function\"><div>"; self::dumpFunction($method, $tabs, $limit, '', $depth + 1); echo "</div></td></tr>"; } echo "$tabs</table>"; } echo "$tabs</div></td></tr>"; } } } echo "$tabs</tbody>$tabs</table>"; } elseif (is_numeric($var)) { echo htmlentities($var); } elseif (is_scalar($var)) { echo htmlentities($var); } else { echo gettype($var); } } // dump
/** * Helper method that gets all the properties from a reflection obj * * @param $object * * @return \ReflectionProperty[] */ protected function getAllClassProperties($object) { $reflectionObj = new \ReflectionObject($object); $properties = $reflectionObj->getProperties(); while ($parent = $reflectionObj->getParentClass()) { $properties = array_merge($parent->getProperties(), $properties); $reflectionObj = $parent; } return $properties; }
/** * cfdump-style debugging output * @param $var The variable to output. * @param $limit Maximum recursion depth for arrays (default 0 = all) * @param $label text to display in complex data type header * @param $depth Current depth (default 0) */ public function dump(&$var, $limit = 0, $label = '', $depth = 0) { if (!is_int($depth)) $depth = 0; if (!is_int($limit)) $limit = 0; if (($limit > 0) && ($depth >= $limit)) return; static $seen = array(); $he = function ($s) { return htmlentities($s); }; $tabs = "\n" . str_repeat("\t", $depth); $depth++; $printCount = 0; $self = $this; $echoFunction = function($var, $tabs, $limit = 0, $label = '', $depth = 0) use ($self) { if (!is_subclass_of($var, 'ReflectionFunctionAbstract')) { $var = new \ReflectionFunction($var); } echo "$tabs<table class=\"dump function depth${depth}\">$tabs<thead><tr><th>" . ($label != '' ? $label . ' - ' : '') . (is_callable(array($var, 'getModifiers')) ? htmlentities(implode(' ', \Reflection::getModifierNames($var->getModifiers()))) : '') . " function " . htmlentities($var->getName()) . "</th></tr></thead>$tabs<tbody>"; echo "$tabs<tr><td class=\"value\">$tabs<table class=\"dump layout\">$tabs<tr><th>Parameters:</th><td>"; $params = $var->getParameters(); if (count($params) > 0) { echo "</td></tr>$tabs<tr><td colspan=\"2\">$tabs<table class=\"dump param\">$tabs<thead><tr><th>Name</th><th>Array/Ref</th><th>Required</th><th>Default</th></tr></thead>$tabs<tbody>"; foreach ($params as $param) { echo "$tabs<tr><td>" . htmlentities($param->getName()) . "</td><td>" . ($param->isArray() ? "Array " : "") . ($param->isPassedByReference() ? "Reference" : "") . "</td><td>" . ($param->isOptional() ? "Optional" : "Required") . "</td><td>"; if ($param->isOptional() && $param->isDefaultValueAvailable()) { $self->dump($param->getDefaultValue(), $limit, $label, $depth); } echo "</td></tr>"; } echo "$tabs</tbody>$tabs</table>"; } else { echo "none</td></tr>"; } $comment = trim($var->getDocComment()); if (($comment !== NULL) && ($comment !== '')) { echo "$tabs<tr><th>Doc Comment:</th><td><kbd>" . str_replace("\n", "<br/>", htmlentities($comment)) . "</kbd></td></tr>"; } echo "</table>$tabs</td></tr>"; echo "$tabs</tbody>$tabs</table>"; }; if (!array_key_exists('fw1dumpstarted', $_REQUEST)) { $_REQUEST['fw1dumpstarted'] = TRUE; echo<<<DUMPCSSJS <style type="text/css">/* fw/1 dump */ table.dump { color: black; background-color: white; font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; border-spacing: 0; border-collapse: collapse; } table.dump th { text-indent: -2em; padding: 0.25em 0.25em 0.25em 2.25em; color: #fff; } table.dump td { padding: 0.25em; } table.dump .key { cursor: pointer; } table.dump td.shh { background-color: #ddd; } table.dump td.shh div { display: none; } table.dump td.shh:before { content: "..."; } table.dump th, table.dump td { border-width: 2px; border-style: solid; border-spacing: 0; vertical-align: top; text-align: left; } table.dump.object, table.dump.object > * > tr > td, table.dump.object > thead > tr > th { border-color: #f00; } table.dump.object > thead > tr > th { background-color: #f44; } table.dump.object > tbody > tr > .key { background-color: #fcc; } table.dump.array, table.dump.array > * > tr > td, table.dump.array > thead > tr > th { border-color: #060; } table.dump.array > thead > tr > th { background-color: #090; } table.dump.array > tbody > tr > .key { background-color: #cfc; } table.dump.struct, table.dump.struct > * > tr > td, table.dump.struct > thead > tr > th { border-color: #00c; } table.dump.struct > thead > tr > th { background-color: #44c; } table.dump.struct > tbody > tr > .key { background-color: #cdf; } table.dump.function, table.dump.function > * > tr > td, table.dump.function > thead > tr > th { border-color: #a40; } table.dump.function > thead > tr > th { background-color: #c60; } table.dump.layout, table.dump.layout > * > tr > td, table.dump.layout > thead > tr > th { border-color: #fff; } table.dump.layout > * > tr > th { font-style: italic; background-color: #fff; color: #000; font-weight: normal; border: none; } table.dump.param, table.dump.param > * > tr > td, table.dump.param > thead > tr > th { border-color: #ddd; } table.dump.param > thead > tr > th { background-color: #eee; color: black; font-weight: bold; } </style> <script type="text/javascript" language="JavaScript"> (function(w,d){ var addEvent = function(o,t,f) { if (o.addEventListener) o.addEventListener(t,f,false); else if (o.attachEvent) { o['e' + t + f] = f; o[t + f] = function() { o['e' + t + f](w.event); } o.attachEvent('on' + t, o[t + f]); } }; // addEvent var clickCell = function(e) { var target = e.target || this; var sib = target.nextSibling; if (sib && sib.tagName && (sib.tagName.toLowerCase() === 'td')) { if (/(^|\s)shh(\s|$)/.test(sib.className)) sib.className = sib.className.replace(/(^|\s)shh(\s|$)/, ' '); else sib.className += ' shh'; } if (e && e.stopPropagation) e.stopPropagation(); else w.event.cancelBubble = true; return false; }; // clickCell var collapsifyDumps = function() { setTimeout(function() { var tables = document.getElementsByTagName('table'); for(var t = 0; t < tables.length; t++) { var table = tables[t]; var dumpPattern = /(^|\s)dump(\s|$)/; var depthPattern = /(^|\s)depth1(\s|$)/; if (! (dumpPattern.test(table.className) && depthPattern.test(table.className) )) continue; var cells = table.getElementsByTagName('td'); var keyPattern = /(^|\s)key(\s|$)/; var keyCount = 0; for (var c = 0; c < cells.length; c++) { var cell = cells[c]; if (! (keyPattern.test(cell.className))) continue; addEvent(cell, 'click', clickCell); } // for k } // for t }, 250); }; // collapsify dumps if (d.addEventListener) d.addEventListener("DOMContentLoaded", collapsifyDumps, false); else d.onreadystatechange = function() { if (d.readyState === 'interactive') collapsifyDumps(this); }; })(window,document); </script> DUMPCSSJS; } if (is_array($var)) { // It turns out that identity (===) in PHP isn't actually identity. It's more like "do you look similar enough to fool an untrained observer?". Lame! // $label = $label === '' ? (($var === $_POST) ? '$_POST' : (($var === $_GET) ? '$_GET' : (($var === $_COOKIE) ? '$_COOKIE' : (($var === $_ENV) ? '$_ENV' : (($var === $_FILES) ? '$_FILES' : (($var === $_REQUEST) ? '$_REQUEST' : (($var === $_SERVER) ? '$_SERVER' : (isset($_SESSION) && ($var === $_SESSION) ? '$_SESSION' : '')))))))) : $label; $c = count($var); if(isset($var['fw1recursionsentinel'])) { echo "(Recursion)"; } $aclass = (($c > 0) && array_key_exists(0, $var) && array_key_exists($c - 1, $var)) ? 'array' : 'struct'; $var['fw1recursionsentinel'] = TRUE; echo "$tabs<table class=\"dump ${aclass} depth${depth}\">$tabs<thead><tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "array" . ($c > 0 ? "" : " [empty]") . "</th></tr></thead>$tabs<tbody>"; foreach ($var as $index => $aval) { if ($index === 'fw1recursionsentinel') continue; echo "$tabs<tr><td class=\"key\">" . $he($index) . "</td><td class=\"value\"><div>"; $this->dump($aval, $limit, '', $depth); echo "</div></td></tr>"; $printCount++; if (($limit > 0) && ($printCount >= $limit) && ($aclass === 'array')) break; } echo "$tabs</tbody>$tabs</table>"; // unset($var['fw1recursionsentinel']); } elseif (is_string($var)) { echo $var === '' ? '[EMPTY STRING]' : htmlentities($var); } elseif (is_bool($var)) { echo $var ? "TRUE" : "FALSE"; } elseif (is_callable($var) || (is_object($var) && is_subclass_of($var, 'ReflectionFunctionAbstract'))) { $echoFunction($var, $tabs, $limit, $label, $depth); } elseif (is_float($var)) { echo "(float) " . htmlentities($var); } elseif (is_int($var)) { echo "(int) " . htmlentities($var); } elseif (is_null($var)) { echo "NULL"; } elseif (is_object($var)) { $ref = new \ReflectionObject($var); $parent = $ref->getParentClass(); $interfaces = implode("<br/>implements ", $ref->getInterfaceNames()); /* try { $serial = serialize($var); } catch (\Exception $e) { $serial = 'hasclosure' . $ref->getName(); } $objHash = 'o' . md5($serial); */ $objHash = spl_object_hash($var); $refHash = 'r' . md5($ref); echo "$tabs<table class=\"dump object depth${depth}\"" . (isset($seen[$refHash]) ? "" : "id=\"$refHash\"") . ">$tabs<thead>$tabs<tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "object " . htmlentities($ref->getName()) . ($parent ? "<br/>extends " .$parent->getName() : "") . ($interfaces !== '' ? "<br/>implements " . $interfaces : "") . "</th></tr>$tabs<tbody>"; if (isset($seen[$objHash])) { echo "$tabs<tr><td colspan=\"2\"><a href=\"#$refHash\">[see above for details]</a></td></tr>"; } else { $seen[$objHash] = TRUE; $constants = $ref->getConstants(); if (count($constants) > 0) { echo "$tabs<tr><td class=\"key\">CONSTANTS</td><td class=\"values\"><div>$tabs<table class=\"dump object\">"; foreach ($constants as $constant => $cval) { echo "$tabs<tr><td class=\"key\">" . htmlentities($constant) . "</td><td class=\"value constant\"><div>"; $this->dump($cval, $limit, '', $depth + 1); echo "</div></td></tr>"; } echo "$tabs</table>$tabs</div></td></tr>"; } $properties = $ref->getProperties(); if (count($properties) > 0) { echo "$tabs<tr><td class=\"key\">PROPERTIES</td><td class=\"values\"><div>$tabs<table class=\"dump object\">"; foreach ($properties as $property) { echo "$tabs<tr><td class=\"key\">" . htmlentities(implode(' ', \Reflection::getModifierNames($property->getModifiers()))) . " " . $he($property->getName()) . "</td><td class=\"value property\"><div>"; $wasHidden = $property->isPrivate() || $property->isProtected(); $property->setAccessible(TRUE); $propertyValue = $property->getValue($var); $this->dump($propertyValue, $limit, '', $depth + 1); if ($wasHidden) { $property->setAccessible(FALSE); } echo "</div></td></tr>"; } echo "$tabs</table>$tabs</div></td></tr>"; } $methods = $ref->getMethods(); if (count($methods) > 0) { echo "$tabs<tr><td class=\"key\">METHODS</td><td class=\"values shh\"><div>"; if (isset($seen[$refHash])) { echo "<a href=\"#$refHash\">[see above for details]</a>"; } else { $seen[$refHash] = TRUE; echo "$tabs<table class=\"dump object\">"; foreach ($methods as $method) { echo "$tabs<tr><td class=\"key\">" . htmlentities($method->getName()) . "</td><td class=\"value function\"><div>"; $echoFunction($method, $tabs, $limit, '', $depth + 1); echo "</div></td></tr>"; } echo "$tabs</table>"; } echo "$tabs</div></td></tr>"; } } echo "$tabs</tbody>$tabs</table>"; } elseif (is_resource($var)) { echo "(Resource)"; } elseif (is_numeric($var)) { echo htmlentities($var); } elseif (is_scalar($var)) { echo htmlentities($var); } else { echo gettype($var); } } // dump
public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize) { gc_disable(); if (!file_exists($outputFolder)) { mkdir($outputFolder, 0777, true); } $this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash"); $obData = fopen($outputFolder . "/objects.js", "wb+"); $staticProperties = []; $data = []; $objects = []; $refCounts = []; $this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize); do { $continue = false; foreach ($objects as $hash => $object) { if (!is_object($object)) { continue; } $continue = true; $className = get_class($object); $objects[$hash] = true; $reflection = new \ReflectionObject($object); $info = ["information" => "{$hash}@{$className}", "properties" => []]; if ($reflection->getParentClass()) { $info["parent"] = $reflection->getParentClass()->getName(); } if (count($reflection->getInterfaceNames()) > 0) { $info["implements"] = implode(", ", $reflection->getInterfaceNames()); } foreach ($reflection->getProperties() as $property) { if ($property->isStatic()) { continue; } if (!$property->isPublic()) { $property->setAccessible(true); } $this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize); } fwrite($obData, "{$hash}@{$className}: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n"); if (!isset($objects["staticProperties"][$className])) { $staticProperties[$className] = []; foreach ($reflection->getProperties() as $property) { if (!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className) { continue; } if (!$property->isPublic()) { $property->setAccessible(true); } $this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize); } } } echo "[Dump] Wrote " . count($objects) . " objects\n"; } while ($continue); file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); echo "[Dump] Finished!\n"; gc_enable(); $this->server->forceShutdown(); }
/** * Dumps a varialble from the global scope. * * @param mixed $var The variable to dump. * @param bool $return Return output? (Default: false) * @param mixed $title string|bool|array Alternate title for the dump, or to backtrace. * @param mixed $background Override the default background. * @param string $mode Default "auto", can be: "cli" or "web". * @return mixed void|string */ function var_dump($var, $return = false, $title = false, $background = false, $mode = 'auto') { if ($background === false) { $background = 'white'; } if ($mode === 'auto') { $webmode = ENV_MODE & ENV_WEB ? true : false; } elseif ($mode === 'web') { $webmode = true; } elseif ($mode === 'cli') { $webmode = false; } elseif ($mode === 'terminal') { $webmode = false; } else { trigger_error('Invalid mode.', E_USER_WARNING); } $fixDumpString = function ($name, $value, $htmlspecial = true) use(&$background, &$mode) { if (in_array($name, array('[\'pass\']', '[\'password\']', '[\'PHP_AUTH_PW\']'))) { $value = '********'; } else { $fix = array("\r\n" => colorize('¤¶', 'gray', $background, $mode) . "\n", "\n\r" => colorize('¶¤', 'gray', $background, $mode) . "\n\n", "\n" => colorize('¶', 'gray', $background, $mode) . "\n", "\r" => colorize('¤', 'gray', $background, $mode) . "\n"); $value = strtr($htmlspecial ? htmlspecialchars($value) : $value, $fix); } return $value; }; $recursionClasses = array(); $dodump = function ($var, $var_name = null, $indent = 0, $params = array()) use(&$dodump, &$fixDumpString, &$background, &$webmode, &$mode, &$recursionClasses) { if (is_object($var)) { if (!empty($recursionClasses)) { $add = true; foreach ($recursionClasses as $class) { if ($var === $class) { $add = false; } } if ($add === true) { $recursionClasses[] = $var; } } else { $recursionClasses[] = $var; } } $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent) . colorize($webmode === true ? htmlentities($var_name) : $var_name, 'varname', $background, $mode); if (is_callable($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('*CALLABLE*', 'recursion', $background, $mode); } elseif (is_array($var)) { echo ' ' . colorize('=>', 'black', $background, $mode) . ' ' . colorize('Array (' . count($var) . ')', 'gray', $background, $mode) . "\n" . str_repeat($doDump_indent, $indent) . colorize('(', 'lightgray', $background, $mode) . "\n"; foreach ($var as $key => $value) { if (is_callable($var[$key])) { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1) . colorize('[\'' . ($webmode === true ? htmlentities($key) : $key) . '\']', 'varname', $background, $mode); echo ' ' . colorize('=', 'black', $background, $mode) . ' '; if (!is_string($var[$key])) { echo colorize('*CALLABLE*', 'recursion', $background, $mode); } else { echo colorize('\'' . (string) $var[$key] . '\'', 'recursion', $background, $mode); } echo "\n"; continue; } if (strpos(print_r($var[$key], true), '*RECURSION*') !== false) { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1) . colorize('[\'' . ($webmode === true ? htmlentities($key) : $key) . '\']', 'varname', $background, $mode); echo ' ' . colorize('=', 'black', $background, $mode) . ' '; if (!is_string($var[$key])) { echo colorize('*RECURSION*', 'recursion', $background, $mode); } else { echo colorize('\'' . (string) $var[$key] . '\'', 'recursion', $background, $mode); } echo "\n"; continue; } if (is_object($value)) { $same = false; foreach ($recursionClasses as $class) { if ($class === $value) { $same = true; } } if ($same === true) { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1) . colorize('[\'' . ($webmode === true ? htmlentities($key) : $key) . '\']', 'varname', $background, $mode); echo ' ' . colorize('=', 'black', $background, $mode) . ' '; echo colorize(get_class($value) . '()', 'recursion', $background, $mode); echo "\n"; } elseif (get_class($value) === 'Closure') { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1) . colorize('[\'' . ($webmode === true ? htmlentities($key) : $key) . '\']', 'varname', $background, $mode); echo ' ' . colorize('=', 'black', $background, $mode) . ' '; echo colorize(get_class($value) . '()', 'recursion', $background, $mode); echo "\n"; } else { $dodump($value, '[\'' . $key . '\']', $indent + 1); } continue; } $dodump($value, '[\'' . $key . '\']', $indent + 1); } echo str_repeat($doDump_indent, $indent) . colorize(')', 'lightgray', $background, $mode); } elseif (is_string($var)) { if (isset($params['error']) && $params['error'] === true) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Error: ' . $fixDumpString($var_name, $var, $webmode), 'error', $background, $mode); } else { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('String(' . strlen($var) . ')', 'gray', $background, $mode) . ' ' . colorize('\'' . $fixDumpString($var_name, $var, $webmode) . '\'', 'string', $background, $mode); } } elseif (is_int($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Integer(' . strlen($var) . ')', 'gray', $background, $mode) . ' ' . colorize($var, 'int', $background, $mode); } elseif (is_bool($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Boolean', 'gray', $background, $mode) . ' ' . colorize($var === true ? 'true' : 'false', 'bool', $background, $mode); } elseif (is_object($var)) { $class = new \ReflectionObject($var); $parents = ''; if ($parent = $class->getParentClass()) { $parents .= ' extends ' . $class->getParentClass()->name; } unset($parent); $interfaces = $class->getInterfaces(); if (!empty($interfaces)) { $parents .= ' implements ' . implode(', ', array_keys($interfaces)); } unset($interfaces); if ($var instanceof Iterator) { echo ' ' . colorize('=>', 'black', $background, $mode) . ' ' . colorize($class->getName() . ' Object (Iterator)' . $parents, 'gray', $background, $mode) . "\n" . str_repeat($doDump_indent, $indent) . colorize('(', 'lightgray', $background, $mode) . "\n"; var_dump($var); } else { echo ' ' . colorize('=>', 'black', $background, $mode) . ' ' . colorize($class->getName() . ' Object' . $parents, 'gray', $background, $mode) . "\n" . str_repeat($doDump_indent, $indent) . colorize('(', 'lightgray', $background, $mode) . "\n"; $dblcheck = array(); foreach ((array) $var as $key => $value) { if (!property_exists($var, $key)) { $key = ltrim($key, "*"); if (substr($key, 0, strlen($class->getName())) === $class->getName()) { $key = substr($key, strlen($class->getName()) + 1); } else { $parents = class_parents($var); if (!empty($parents)) { foreach ($parents as $parent) { if (substr($key, 0, strlen($parent)) === $parent) { $key = $parent . '->' . substr($key, strlen($parent) + 1); } } } } } $dblcheck[$key] = $value; } $reflect = new \ReflectionClass($var); $constants = $reflect->getConstants(); if (!empty($constants)) { foreach ($constants as $key => $value) { $dodump($value, $key, $indent + 1); } } unset($constants); $props = $reflect->getProperties(); if (!empty($props)) { foreach ($props as $prop) { $append = ''; $error = false; if ($prop->isPrivate()) { $append .= ' private'; } elseif ($prop->isProtected()) { $append .= ' protected'; } $prop->setAccessible(true); if ($prop->isStatic()) { $value = $prop->getValue(); $append .= ' static'; } else { set_error_handler(function ($errno, $errstr) { throw new \Exception($errstr); }); try { $value = $prop->getValue($var); } catch (\Exception $e) { $value = $e->getMessage(); $append .= ' error'; $error = true; } restore_error_handler(); } if (array_key_exists($prop->name, $dblcheck)) { unset($dblcheck[$prop->name]); } if (is_object($value)) { $same = false; foreach ($recursionClasses as $class) { if ($class === $value) { $same = true; } } if ($same === true) { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1) . colorize('[\'' . ($webmode === true ? htmlentities($prop->name . '\'' . $append) : $prop->name . '\'' . $append) . ']', 'varname', $background, $mode); echo ' ' . colorize('=', 'black', $background, $mode) . ' '; echo colorize(get_class($value) . '()', 'recursion', $background, $mode); echo "\n"; } else { $dodump($value, '[\'' . $prop->name . '\'' . $append . ']', $indent + 1, array('error' => $error)); } } else { $dodump($value, '[\'' . $prop->name . '\'' . $append . ']', $indent + 1, array('error' => $error)); } } } if (!empty($dblcheck)) { foreach ($dblcheck as $key => $value) { $dodump($value, '[\'' . $key . '\' magic]', $indent + 1); } } $methods = $reflect->getMethods(); if (!empty($methods)) { foreach ($methods as $method) { $doDump_indent = colorize('|', 'lightgray', $background, $mode) . ' '; echo str_repeat($doDump_indent, $indent + 1); if ($method->getModifiers() & \ReflectionMethod::IS_ABSTRACT) { echo colorize('abstract ', 'gray', $background, $mode); } elseif ($method->getModifiers() & \ReflectionMethod::IS_FINAL) { echo colorize('final ', 'gray', $background, $mode); } if ($method->getModifiers() & \ReflectionMethod::IS_PUBLIC) { echo colorize('public ', 'gray', $background, $mode); } elseif ($method->getModifiers() & \ReflectionMethod::IS_PROTECTED) { echo colorize('protected ', 'gray', $background, $mode); } elseif ($method->getModifiers() & \ReflectionMethod::IS_PRIVATE) { echo colorize('private ', 'gray', $background, $mode); } echo colorize($method->class, 'gray', $background, $mode); $type = '->'; if ($method->getModifiers() & \ReflectionMethod::IS_STATIC) { $type = '::'; } echo colorize($type . $method->name . '(', 'recursion', $background, $mode); $reflectMethod = new \ReflectionMethod($method->class, $method->name); $methodParams = $reflectMethod->getParameters(); if (!empty($methodParams)) { $mParams = []; foreach ($methodParams as $mParam) { if ($mParam->isOptional()) { try { $default = $mParam->getDefaultValue(); if (is_string($default)) { $default = "'" . $default . "'"; } elseif ($default === true) { $default = 'true'; } elseif ($default === false) { $default = 'false'; } elseif ($default === null) { $default = 'null'; } elseif (is_array($default)) { $default = 'Array'; } } catch (\Exception $e) { $default = 'Unknown'; } $mParams[] = colorize(($mParam->isPassedByReference() ? '&' : '') . '$' . $mParam->name . ' = ' . $default, 'gray', $background, $mode); } else { $mParams[] = colorize(($mParam->isPassedByReference() ? '&' : '') . '$' . $mParam->name, 'black', $background, $mode); } } echo implode(', ', $mParams); } echo colorize(')', 'recursion', $background, $mode); echo "\n"; } } unset($props, $reflect); } unset($class); echo str_repeat($doDump_indent, $indent) . colorize(')', 'lightgray', $background, $mode); } elseif (is_null($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('null', 'black', $background, $mode); } elseif (is_float($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Float(' . strlen($var) . ')', 'gray', $background) . ' ' . colorize($var, 'float', $background, $mode); } elseif (is_resource($var)) { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Resource', 'gray', $background, $mode) . ' ' . $var; } else { echo ' ' . colorize('=', 'black', $background, $mode) . ' ' . colorize('Unknown', 'gray', $background, $mode) . ' ' . $var; } echo "\n"; }; $prefix = 'unique'; $suffix = 'value'; if ($return === true) { ob_start(); } if ($webmode) { echo '<pre class="vardump">'; } if ($title === false || is_array($title)) { $backtrace = debug_backtrace(); if (is_array($title) && isset($title['steps']) && isset($backtrace[$title['steps']])) { $backtrace = $backtrace[$title['steps']]; } else { $backtrace = $backtrace[0]; } if (substr($backtrace['file'], -13) == 'eval()\'d code') { $title = 'eval()'; } else { $con = explode("\n", file_get_contents($backtrace['file'])); $callee = $con[$backtrace['line'] - 1]; if (is_array($title) && isset($title['match'])) { preg_match($title['match'], $callee, $matches); } else { preg_match('/([a-zA-Z\\\\]+|)var_dump\\((.*)/', $callee, $matches); } if (!empty($matches)) { $i = 0; $title = ''; foreach (str_split($matches[0], 1) as $value) { if ($value === '(') { $i++; } if ($i === 0 && $value === ',') { break; } if ($value === ')') { $i--; } if ($i === 0 && $value === ')') { $title .= $value; break; } $title .= $value; } } else { $title = 'Unknown dump string'; } } } $dodump($var, $title); if ($webmode) { echo "</pre>\n"; } if ($return === true) { $out = ob_get_contents(); ob_end_clean(); return $out; } }
public function addPlugin(PluginModule $pluginModule, $plugin_service_id) { $pluginModule->setServiceId($plugin_service_id); $name = $pluginModule->getName(); $rc1 = new \ReflectionObject($pluginModule); $parent = $rc1->getParentClass(); if (!$parent || self::PM_BASE_CLASS === $parent->getName() || !is_subclass_of($pluginModule, self::PM_BASE_CLASS)) { throw new \Exception(sprintf("sf.bbs.plugin.module invalid name(%s) on class(%s) file(%s) must extends %s\\*", $name, $rc1->getName(), $rc1->getFileName(), self::PM_BASE_CLASS)); } if (!preg_match('/^[a-z][a-z0-9\\_]+$/', $name)) { throw new \Exception(sprintf("sf.bbs.plugin.module invalid name(%s) on class(%s) file(%s)", $name, $rc1->getName(), $rc1->getFileName())); } if (isset($this->_modules[$name])) { $rc2 = new \ReflectionObject($this->_modules[$name]); throw new \Exception(sprintf("sf.bbs.plugin.module(%s) duplicate for class(%s,%s), file(%s,%s)", $name, $rc1->getName(), $rc2->getName(), $rc1->getFileName(), $rc2->getFileName())); } $type = $pluginModule->getType(); if ($type && !isset($this->_plugin_modules_types[$type])) { throw new \Exception(sprintf("sf.bbs.plugin.module(name: %s,\n class: %s,\n file: %s) \n type(%s) is invalid, available values ( %s ) ", $name, $rc1->getName(), $rc1->getFileName(), json_encode($type), join(', ', array_keys($this->_plugin_modules_types)))); } /** * @var $m \ReflectionMethod */ foreach ($rc1->getMethods() as $m) { $as = $this->_reader->getMethodAnnotations($m); $_as = array(); foreach ($as as $_an) { if ($_an instanceof \Symforce\DiscuzBundle\Annotation\AbstractAnnotation) { $_an_class = get_class($_an); if ($_an instanceof \Symforce\DiscuzBundle\Annotation\AbstractMultiple) { $key = $this->getMultipleKeyValue(); if (isset($_as[$_an_class][$key])) { throw new \Exception(sprintf("class:%s method:%s, file: %s, line:%s annotations(%s) duplicate(%s)", $rc1->getName(), $m->getName(), $rc1->getFileName(), $m->getStartLine(), $_an_class, $key)); } $_as[$_an_class][$key] = $_an; } else { if (isset($_as[$_an_class])) { throw new \Exception(sprintf("class:%s method:%s, file: %s, line:%s annotations(%s) duplicate", $rc1->getName(), $m->getName(), $rc1->getFileName(), $m->getStartLine(), $_an_class)); } $_as[$_an_class] = $_an; } } } if (empty($_as)) { continue; } foreach ($_as as $_an) { $_an->checkMethod($m); } if (isset($_as[self::PM_ANNOTATION_ACTION])) { $pluginModule->addAction($_as[self::PM_ANNOTATION_ACTION], $m); } if (isset($_as[self::PM_ANNOTATION_EMBED])) { $_an = $_as[self::PM_ANNOTATION_EMBED]; if ($_an instanceof \Symforce\DiscuzBundle\Annotation\Embed) { $_embed_helper = new EmbedHelper($_an, $m, $pluginModule); if (isset($this->_embed_helpers[$_an->type][$_an->method])) { $_other_embed_helper = $this->_embed_helpers[$_an->type][$_an->method][0]; if ($_embed_helper->code !== $_other_embed_helper->code) { throw new \Exception(sprintf("@(%s, method=%s) parameters conflict(%s, %s)", $_an_class, $_an->method, \Dev::getMethodDeclaring($m), \Dev::getMethodDeclaring($_other_embed_helper->method))); } } $this->_embed_helpers[$_an->type][$_an->method][] = $_embed_helper; } } } $bundle_name = preg_replace('/^(\\/.+)\\/([A-Z]\\w+)\\/([A-Z]\\w+Bundle)\\/.+$/', '\\2\\3', $rc1->getFileName()); $pluginModule->setBundleName($bundle_name); $this->_modules[$name] = $pluginModule; $pluginModule->setContainer($this->_container); $pluginModule->onLoad($this); }
/** * @param $param * @param \ReflectionObject $reflection */ private function buildFromObject($param, $reflection = null) { foreach ($param as $key => $value) { $this->object['Object default'][$key] = $value; } // Get info on the object $this->object['Reflection']['In namespace'] = $reflection->inNamespace() ? 'Yes' : 'No'; if ($reflection->inNamespace()) { $this->object['Class namespace'] = $reflection->getNamespaceName(); } $this->object['Reflection']['Class name'] = $reflection->getName(); $this->object['Reflection']['Is internal'] = $reflection->isInternal() ? 'Yes' : 'No'; $this->object['Reflection']['Is iterable'] = $reflection->isIterateable() ? 'Yes' : 'No'; $this->object['Reflection']['Is abstract'] = $reflection->isAbstract() ? 'Yes' : 'No'; $this->object['Reflection']['Is final'] = $reflection->isFinal() ? 'Yes' : 'No'; $this->object['Reflection']['Is user defined'] = $reflection->isUserDefined() ? 'Yes' : 'No'; $this->object['Reflection']['Is instantiable'] = $reflection->isInstantiable() ? 'Yes' : 'No'; $this->object['Reflection']['Is clonable'] = $reflection->isCloneable() ? 'Yes' : 'No'; $this->object['Reflection']['Is interface'] = $reflection->isInterface() ? 'Yes' : 'No'; $this->object['Reflection']['Class constants'] = !empty($reflection->getConstants()) ? $reflection->getConstants() : 'Class has no constants'; $this->object['Reflection']['Class static properties'] = !empty($reflection->getStaticProperties()) ? $reflection->getStaticProperties() : 'Class has no static properties'; $this->object['Reflection']['Class default properties'] = !empty($reflection->getDefaultProperties()) ? $reflection->getDefaultProperties() : 'Class has no default properties'; if (null === $reflection->getConstructor()) { $this->object['Reflection']['Class construct'] = 'Class has no construct.'; } else { $this->object['Reflection']['Class construct'] = $reflection->getConstructor(); } $this->object['Reflection']['Class interfaces'] = !empty($reflection->getInterfaces()) ? $reflection->getInterfaces() : 'Class implements no interfaces'; $this->object['Reflection']['Class traits'] = !empty($reflection->getTraits()) ? $reflection->getTraits() : 'Class has no traits'; $this->object['Reflection']['Class parent'] = $reflection->getParentClass() !== false ? $reflection->getParentClass() : 'Class has no parent'; if (false === $reflection->getFileName()) { $this->object['Reflection']['Defined in'] = 'Class is internal, no definition to provide.'; } else { $this->object['Reflection']['Defined in'] = $reflection->getFileName(); } if (false === $reflection->getFileName()) { $this->object['Reflection']['Start line'] = 'Class is internal, no start line to provide.'; } else { $this->object['Reflection']['Start line'] = $reflection->getFileName(); } if (false === $reflection->getEndLine()) { $this->object['Reflection']['End line'] = 'Class is internal, no end line to provide.'; } else { $this->object['Reflection']['End line'] = $reflection->getEndLine(); } if (false === $reflection->getDocComment()) { $this->object['Reflection']['Doc comments'] = 'No documents to provide.'; } else { $this->object['Reflection']['Doc comments'] = $reflection->getDocComment(); } // End get info $this->html .= "<span class=\"js-parent-object\">"; if (!empty($this->object['Object default'])) { $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>"; $this->html .= "<div class=\"js-object-default \">"; $this->buildFromObjectIterationInformationRecursive($this->object['Object default']); $this->html .= "</div>"; } if ($param instanceof \Closure) { $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>"; $this->html .= "<div class=\"js-object-default \">"; $this->html .= "<span class=\"css-type-string\">Nothing here...</span>"; $this->html .= "</div>"; } $this->html .= "<div class=\"js-object-reflection-tab hide\"><button class=\"button-class-default button\">Show default</button></div>"; $this->html .= "<div class=\"js-object-reflection hide\">"; $this->buildFromObjectReflectionInformationRecursive($this->object['Reflection']); $this->html .= "</div>"; $this->html .= "</span>"; $this->object = []; }