supportsColors example

$this->dumpLine($cursor->depth);
                }
            }
        }
    }

    /** * @return void */
    public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
    {
        $this->colors ??= $this->supportsColors();

        $this->dumpKey($cursor);
        $this->expandNextHash = false;
        $attr = $cursor->attr;

        if ($this->collapseNextHash) {
            $cursor->skipChildren = true;
            $this->collapseNextHash = $hasChild = false;
        }

        $class = $this->utf8Encode($class);
        
$this->dumpLine($cursor->depth);
                }
            }
        }
    }

    /** * @return void */
    public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
    {
        $this->colors ??= $this->supportsColors();

        $this->dumpKey($cursor);
        $this->expandNextHash = false;
        $attr = $cursor->attr;

        if ($this->collapseNextHash) {
            $cursor->skipChildren = true;
            $this->collapseNextHash = $hasChild = false;
        }

        $class = $this->utf8Encode($class);
        

    public function render(\Throwable $exception): FlattenException
    {
        $cloner = new VarCloner();
        $dumper = new class() extends CliDumper {
            protected function supportsColors(): bool
            {
                $outputStream = $this->outputStream;
                $this->outputStream = fopen('php://stdout', 'w');

                try {
                    return parent::supportsColors();
                } finally {
                    $this->outputStream = $outputStream;
                }
            }
        };

        return FlattenException::createFromThrowable($exception)
            ->setAsString($dumper->dump($cloner->cloneVar($exception), true));
    }
}

    public function render(\Throwable $exception): FlattenException
    {
        $cloner = new VarCloner();
        $dumper = new class() extends CliDumper {
            protected function supportsColors(): bool
            {
                $outputStream = $this->outputStream;
                $this->outputStream = fopen('php://stdout', 'w');

                try {
                    return parent::supportsColors();
                } finally {
                    $this->outputStream = $outputStream;
                }
            }
        };

        return FlattenException::createFromThrowable($exception)
            ->setAsString($dumper->dump($cloner->cloneVar($exception), true));
    }
}
Home | Imprint | This part of the site doesn't use cookies.