Neos\Flow\Error\Debugger::renderDump PHP Метод

renderDump() публичный статический Метод

Renders a dump of the given variable
public static renderDump ( mixed $variable, integer $level, boolean $plaintext = false, boolean $ansiColors = false ) : string
$variable mixed
$level integer
$plaintext boolean
$ansiColors boolean
Результат string
    public static function renderDump($variable, $level, $plaintext = false, $ansiColors = false)
    {
        if ($level > 50) {
            return 'RECURSION ... ' . chr(10);
        }
        if (is_string($variable)) {
            $croppedValue = strlen($variable) > 2000 ? substr($variable, 0, 2000) . '…' : $variable;
            if ($plaintext) {
                $dump = 'string ' . self::ansiEscapeWrap('"' . $croppedValue . '"', '33', $ansiColors) . ' (' . strlen($variable) . ')';
            } else {
                $dump = sprintf('\'<span class="debug-string">%s</span>\' (%s)', htmlspecialchars($croppedValue), strlen($variable));
            }
        } elseif (is_numeric($variable)) {
            $dump = sprintf('%s %s', gettype($variable), self::ansiEscapeWrap($variable, '35', $ansiColors));
        } elseif (is_array($variable)) {
            $dump = self::renderArrayDump($variable, $level + 1, $plaintext, $ansiColors);
        } elseif (is_object($variable)) {
            $dump = self::renderObjectDump($variable, $level + 1, true, $plaintext, $ansiColors);
        } elseif (is_bool($variable)) {
            $dump = $variable ? self::ansiEscapeWrap('TRUE', '32', $ansiColors) : self::ansiEscapeWrap('FALSE', '31', $ansiColors);
        } elseif (is_null($variable) || is_resource($variable)) {
            $dump = gettype($variable);
        } else {
            $dump = '[unhandled type]';
        }
        return $dump;
    }

Usage Example

 /**
  * @test
  */
 public function ignoredClassesCanBeOverwrittenBySettings()
 {
     $object = new ApplicationContext('Development');
     $this->assertEquals(sprintf('%s prototype object', ApplicationContext::class), Debugger::renderDump($object, 10, true));
     Debugger::clearState();
     $currentConfiguration = ObjectAccess::getProperty($this->configurationManager, 'configurations', true);
     $configurationOverwrite['Settings']['Neos']['Flow']['error']['debugger']['ignoredClasses']['Neos\\\\Flow\\\\Core\\\\.*'] = false;
     $newConfiguration = Arrays::arrayMergeRecursiveOverrule($currentConfiguration, $configurationOverwrite);
     ObjectAccess::setProperty($this->configurationManager, 'configurations', $newConfiguration, true);
     $this->assertContains('rootContextString', Debugger::renderDump($object, 10, true));
 }
All Usage Examples Of Neos\Flow\Error\Debugger::renderDump