/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Error/Debug
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Error/Debug/HtmlFormatter.php (8039B)
id = uniqid('', true);
}
/**
* Check if the current environment is not a CLI context
*
* @return bool
*/
public static function environmentMatches(): bool
{
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
return false;
}
return true;
}
/**
* @inheritDoc
*/
public function formatWrapper(string $contents, array $location): string
{
$lineInfo = '';
if (isset($location['file'], $location['file'])) {
$lineInfo = sprintf(
'
%s (line %s)',
$location['file'],
$location['line']
);
}
$parts = [
'
',
$lineInfo,
$contents,
'
',
];
return implode("\n", $parts);
}
/**
* Generate the CSS and Javascript for dumps
*
* Only output once per process as we don't need it more than once.
*
* @return string
*/
protected function dumpHeader(): string
{
ob_start();
include __DIR__ . DIRECTORY_SEPARATOR . 'dumpHeader.html';
return ob_get_clean();
}
/**
* Convert a tree of NodeInterface objects into HTML
*
* @param \Cake\Error\Debug\NodeInterface $node The node tree to dump.
* @return string
*/
public function dump(NodeInterface $node): string
{
$html = $this->export($node);
$head = '';
if (!static::$outputHeader) {
static::$outputHeader = true;
$head = $this->dumpHeader();
}
return $head . '
' . $html . '
';
}
/**
* Convert a tree of NodeInterface objects into HTML
*
* @param \Cake\Error\Debug\NodeInterface $var The node tree to dump.
* @return string
*/
protected function export(NodeInterface $var): string
{
if ($var instanceof ScalarNode) {
switch ($var->getType()) {
case 'bool':
return $this->style('const', $var->getValue() ? 'true' : 'false');
case 'null':
return $this->style('const', 'null');
case 'string':
return $this->style('string', "'" . (string)$var->getValue() . "'");
case 'int':
case 'float':
return $this->style('visibility', "({$var->getType()})") .
' ' . $this->style('number', "{$var->getValue()}");
default:
return "({$var->getType()}) {$var->getValue()}";
}
}
if ($var instanceof ArrayNode) {
return $this->exportArray($var);
}
if ($var instanceof ClassNode || $var instanceof ReferenceNode) {
return $this->exportObject($var);
}
if ($var instanceof SpecialNode) {
return $this->style('special', (string)$var->getValue());
}
throw new RuntimeException('Unknown node received ' . get_class($var));
}
/**
* Export an array type object
*
* @param \Cake\Error\Debug\ArrayNode $var The array to export.
* @return string Exported array.
*/
protected function exportArray(ArrayNode $var): string
{
$open = '
' .
$this->style('punct', '[') .
'';
$vars = [];
$arrow = $this->style('punct', ' => ');
foreach ($var->getChildren() as $item) {
$val = $item->getValue();
$vars[] = '' .
$this->export($item->getKey()) . $arrow . $this->export($val) .
$this->style('punct', ',') .
'';
}
$close = '' .
$this->style('punct', ']') .
'';
return $open . implode('', $vars) . $close;
}
/**
* Handles object to string conversion.
*
* @param \Cake\Error\Debug\ClassNode|\Cake\Error\Debug\ReferenceNode $var Object to convert.
* @return string
* @see \Cake\Error\Debugger::exportVar()
*/
protected function exportObject($var): string
{
$objectId = "cake-db-object-{$this->id}-{$var->getId()}";
$out = sprintf(
'
',
$objectId
);
if ($var instanceof ReferenceNode) {
$link = sprintf(
'id: %s',
$objectId,
$var->getId()
);
return '' .
$this->style('punct', 'object(') .
$this->style('class', $var->getValue()) .
$this->style('punct', ') ') .
$link .
$this->style('punct', ' {}') .
'';
}
$out .= $this->style('punct', 'object(') .
$this->style('class', $var->getValue()) .
$this->style('punct', ') id:') .
$this->style('number', (string)$var->getId()) .
$this->style('punct', ' {') .
'';
$props = [];
foreach ($var->getChildren() as $property) {
$arrow = $this->style('punct', ' => ');
$visibility = $property->getVisibility();
$name = $property->getName();
if ($visibility && $visibility !== 'public') {
$props[] = '' .
$this->style('visibility', $visibility) .
' ' .
$this->style('property', $name) .
$arrow .
$this->export($property->getValue()) .
'';
} else {
$props[] = '' .
$this->style('property', $name) .
$arrow .
$this->export($property->getValue()) .
'';
}
}
$end = '' .
$this->style('punct', '}') .
'';
if (count($props)) {
return $out . implode('', $props) . $end;
}
return $out . $end;
}
/**
* Style text with HTML class names
*
* @param string $style The style name to use.
* @param string $text The text to style.
* @return string The styled output.
*/
protected function style(string $style, string $text): string
{
return sprintf(
'
%s',
$style,
h($text)
);
}
}