updated-packages
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataFormatter;
|
||||
|
||||
use DebugBar\DataFormatter\DataFormatter;
|
||||
|
||||
class QueryFormatter extends DataFormatter
|
||||
{
|
||||
|
||||
/**
|
||||
* Removes extra spaces at the beginning and end of the SQL query and its lines.
|
||||
*
|
||||
* @param string $sql
|
||||
* @return string
|
||||
*/
|
||||
public function formatSql($sql)
|
||||
{
|
||||
return trim(preg_replace("/\s*\n\s*/", "\n", $sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check bindings for illegal (non UTF-8) strings, like Binary data.
|
||||
*
|
||||
* @param $bindings
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkBindings($bindings)
|
||||
{
|
||||
foreach ($bindings as &$binding) {
|
||||
if (is_string($binding) && !mb_check_encoding($binding, 'UTF-8')) {
|
||||
$binding = '[BINARY DATA]';
|
||||
}
|
||||
}
|
||||
|
||||
return $bindings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the bindings safe for outputting.
|
||||
*
|
||||
* @param array $bindings
|
||||
* @return array
|
||||
*/
|
||||
public function escapeBindings($bindings)
|
||||
{
|
||||
foreach ($bindings as &$binding) {
|
||||
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
|
||||
}
|
||||
|
||||
return $bindings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a source object.
|
||||
*
|
||||
* @param object|null $source If the backtrace is disabled, the $source will be null.
|
||||
* @return string
|
||||
*/
|
||||
public function formatSource($source)
|
||||
{
|
||||
if (! is_object($source)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
|
||||
if ($source->namespace) {
|
||||
$parts['namespace'] = $source->namespace . '::';
|
||||
}
|
||||
|
||||
$parts['name'] = $source->name;
|
||||
$parts['line'] = ':' . $source->line;
|
||||
|
||||
return implode($parts);
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataFormatter;
|
||||
|
||||
use DebugBar\DataFormatter\DataFormatter;
|
||||
|
||||
/**
|
||||
* Simple DataFormatter based on the deprecated Symfony ValueExporter
|
||||
*
|
||||
* @see https://github.com/symfony/symfony/blob/v3.4.4/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
|
||||
*/
|
||||
class SimpleFormatter extends DataFormatter
|
||||
{
|
||||
/**
|
||||
* @param $data
|
||||
* @return string
|
||||
*/
|
||||
public function formatVar($data)
|
||||
{
|
||||
return $this->exportValue($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a PHP value to a string.
|
||||
*
|
||||
* @param mixed $value The PHP value
|
||||
* @param int $depth Only for internal usage
|
||||
* @param bool $deep Only for internal usage
|
||||
*
|
||||
* @return string The string representation of the given value
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
private function exportValue($value, $depth = 1, $deep = false)
|
||||
{
|
||||
if ($value instanceof \__PHP_Incomplete_Class) {
|
||||
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
|
||||
}
|
||||
|
||||
if (is_object($value)) {
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM));
|
||||
}
|
||||
|
||||
return sprintf('Object(%s)', get_class($value));
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
if (empty($value)) {
|
||||
return '[]';
|
||||
}
|
||||
|
||||
$indent = str_repeat(' ', $depth);
|
||||
|
||||
$a = array();
|
||||
foreach ($value as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$deep = true;
|
||||
}
|
||||
$a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep));
|
||||
}
|
||||
|
||||
if ($deep) {
|
||||
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
|
||||
}
|
||||
|
||||
$s = sprintf('[%s]', implode(', ', $a));
|
||||
|
||||
if (80 > strlen($s)) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
return sprintf("[\n%s%s\n]", $indent, implode(sprintf(",\n%s", $indent), $a));
|
||||
}
|
||||
|
||||
if (is_resource($value)) {
|
||||
return sprintf('Resource(%s#%d)', get_resource_type($value), $value);
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (false === $value) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $value) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \__PHP_Incomplete_Class $value
|
||||
* @return mixed
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
|
||||
{
|
||||
$array = new \ArrayObject($value);
|
||||
|
||||
return $array['__PHP_Incomplete_Class_Name'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user