1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-03-15 11:50:01 +01:00
This commit is contained in:
Graham Campbell 2014-10-30 16:38:46 +00:00
parent 3fe312bf23
commit d122b7e570
24 changed files with 70 additions and 73 deletions

View File

@ -10,12 +10,12 @@
namespace DebugBar\Bridge;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DebugBarException;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\ORM\EntityManager;
/**
* Collects Doctrine queries

View File

@ -10,11 +10,11 @@
namespace DebugBar\Bridge;
use Monolog\Logger;
use Monolog\Handler\AbstractProcessingHandler;
use DebugBar\DataCollector\DataCollectorInterface;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\MessagesAggregateInterface;
use DebugBar\DataCollector\Renderable;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
/**
* A monolog handler as well as a data collector

View File

@ -10,15 +10,15 @@
namespace DebugBar\Bridge;
use Propel;
use PropelPDO;
use PropelConfiguration;
use BasicLogger;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
use Psr\Log\LoggerInterface;
use Propel;
use PropelConfiguration;
use PropelPDO;
use Psr\Log\LogLevel;
use Psr\Log\LoggerInterface;
/**
* A Propel logger which acts as a data collector
@ -191,7 +191,7 @@ class PropelCollector extends DataCollector implements BasicLogger, Renderable,
$memory = (float) $matches[1];
if ($matches[2] == 'KB') {
$memory *= 1024;
} else if ($matches[2] == 'MB') {
} elseif ($matches[2] == 'MB') {
$memory *= 1024 * 1024;
}
}

View File

@ -11,9 +11,9 @@
namespace DebugBar\Bridge;
use DebugBar\DataCollector\MessagesCollector;
use Slim\Slim;
use Slim\Log;
use Psr\Log\LogLevel;
use Slim\Log;
use Slim\Slim;
/**
* Collects messages from a Slim logger

View File

@ -10,9 +10,9 @@
namespace DebugBar\Bridge\SwiftMailer;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
use Swift_Mailer;
use Swift_Plugins_MessageLogger;
@ -49,7 +49,9 @@ class SwiftMailCollector extends DataCollector implements Renderable, AssetProvi
protected function formatTo($to)
{
if (!$to) return '';
if (!$to) {
return '';
}
$f = array();
foreach ($to as $k => $v) {

View File

@ -10,17 +10,17 @@
namespace DebugBar\Bridge\Twig;
use Twig_Environment;
use Twig_LexerInterface;
use Twig_ParserInterface;
use Twig_TokenStream;
use Twig_CompilerInterface;
use Twig_NodeInterface;
use Twig_LoaderInterface;
use Twig_ExtensionInterface;
use Twig_TokenParserInterface;
use Twig_NodeVisitorInterface;
use DebugBar\DataCollector\TimeDataCollector;
use Twig_CompilerInterface;
use Twig_Environment;
use Twig_ExtensionInterface;
use Twig_LexerInterface;
use Twig_LoaderInterface;
use Twig_NodeInterface;
use Twig_NodeVisitorInterface;
use Twig_ParserInterface;
use Twig_TokenParserInterface;
use Twig_TokenStream;
/**
* Wrapped a Twig Environment to provide profiling features

View File

@ -10,8 +10,8 @@
namespace DebugBar\Bridge\Twig;
use Twig_TemplateInterface;
use Twig_Template;
use Twig_TemplateInterface;
/**
* Wraps a Twig_Template to add profiling features

View File

@ -10,9 +10,9 @@
namespace DebugBar\Bridge\Twig;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
/**
* Collects data about rendered templates

View File

@ -124,13 +124,13 @@ class AggregatedCollector implements DataCollectorInterface, ArrayAccess
{
if (is_string($this->sort)) {
$p = $this->sort;
usort($data, function($a, $b) use ($p) {
usort($data, function ($a, $b) use ($p) {
if ($a[$p] == $b[$p]) {
return 0;
}
return $a[$p] < $b[$p] ? -1 : 1;
});
} else if ($this->sort === true) {
} elseif ($this->sort === true) {
sort($data);
}
return $data;

View File

@ -10,8 +10,8 @@
namespace DebugBar\DataCollector;
use DebugBar\DataFormatter\DataFormatterInterface;
use DebugBar\DataFormatter\DataFormatter;
use DebugBar\DataFormatter\DataFormatterInterface;
/**
* Abstract class for data collectors

View File

@ -10,8 +10,6 @@
namespace DebugBar\DataCollector;
use Exception;
/**
* Collects info about the current localization state
*/

View File

@ -88,7 +88,7 @@ class MessagesCollector extends AbstractLogger implements DataCollectorInterface
{
$messages = $this->messages;
foreach ($this->aggregates as $collector) {
$msgs = array_map(function($m) use ($collector) {
$msgs = array_map(function ($m) use ($collector) {
$m['collector'] = $collector->getName();
return $m;
}, $collector->getMessages());
@ -96,7 +96,7 @@ class MessagesCollector extends AbstractLogger implements DataCollectorInterface
}
// sort messages by their timestamp
usort($messages, function($a, $b) {
usort($messages, function ($a, $b) {
if ($a['time'] === $b['time']) {
return 0;
}

View File

@ -2,9 +2,9 @@
namespace DebugBar\DataCollector\PDO;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\TimeDataCollector;
/**
@ -96,7 +96,7 @@ class PDOCollector extends DataCollector implements Renderable, AssetProvider
$data['memory_usage'] += $pdodata['memory_usage'];
$data['peak_memory_usage'] = max($data['peak_memory_usage'], $pdodata['peak_memory_usage']);
$data['statements'] = array_merge($data['statements'],
array_map(function($s) use ($name) { $s['connection'] = $name; return $s; }, $pdodata['statements']));
array_map(function ($s) use ($name) { $s['connection'] = $name; return $s; }, $pdodata['statements']));
}
$data['accumulated_duration_str'] = $this->getDataFormatter()->formatDuration($data['accumulated_duration']);

View File

@ -136,7 +136,7 @@ class TraceablePDO extends PDO
*/
public function getAccumulatedStatementsDuration()
{
return array_reduce($this->executedStatements, function($v, $s) { return $v + $s->getDuration(); });
return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getDuration(); });
}
/**
@ -146,7 +146,7 @@ class TraceablePDO extends PDO
*/
public function getMemoryUsage()
{
return array_reduce($this->executedStatements, function($v, $s) { return $v + $s->getMemoryUsage(); });
return array_reduce($this->executedStatements, function ($v, $s) { return $v + $s->getMemoryUsage(); });
}
/**
@ -156,7 +156,7 @@ class TraceablePDO extends PDO
*/
public function getPeakMemoryUsage()
{
return array_reduce($this->executedStatements, function($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; });
return array_reduce($this->executedStatements, function ($v, $s) { $m = $s->getEndMemory(); return $m > $v ? $m : $v; });
}
/**
@ -176,7 +176,7 @@ class TraceablePDO extends PDO
*/
public function getFailedExecutedStatements()
{
return array_filter($this->executedStatements, function($s) { return !$s->isSuccess(); });
return array_filter($this->executedStatements, function ($s) { return !$s->isSuccess(); });
}
public function __get($name)

View File

@ -3,8 +3,8 @@
namespace DebugBar\DataCollector\PDO;
use PDO;
use PDOStatement;
use PDOException;
use PDOStatement;
/**
* A traceable PDO statement to use with Traceablepdo
@ -20,19 +20,22 @@ class TraceablePDOStatement extends PDOStatement
$this->pdo = $pdo;
}
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null) {
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
{
$this->boundParameters[$column] = $param;
$args = array_merge(array($column, &$param), array_slice(func_get_args(), 2));
return call_user_func_array(array("parent", 'bindColumn'), $args);
}
public function bindParam($param, &$var, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null) {
public function bindParam($param, &$var, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null)
{
$this->boundParameters[$param] = $var;
$args = array_merge(array($param, &$var), array_slice(func_get_args(), 2));
return call_user_func_array(array("parent", 'bindParam'), $args);
}
public function bindValue($param, $value, $data_type = PDO::PARAM_STR) {
public function bindValue($param, $value, $data_type = PDO::PARAM_STR)
{
$this->boundParameters[$param] = $value;
return call_user_func_array(array("parent", 'bindValue'), func_get_args());
}

View File

@ -69,7 +69,7 @@ class TracedStatement
public function checkParameters($params)
{
foreach ($params as &$param) {
if(!mb_check_encoding($param, 'UTF-8')) {
if (!mb_check_encoding($param, 'UTF-8')) {
$param = '[BINARY DATA]';
}
}

View File

@ -18,7 +18,6 @@ use DebugBar\DebugBarException;
*/
class TimeDataCollector extends DataCollector implements Renderable
{
/**
* @var float
*/

View File

@ -21,7 +21,7 @@ class DataFormatter implements DataFormatterInterface
{
if ($seconds < 0.001) {
return round($seconds * 1000000) . 'μs';
} else if ($seconds < 1) {
} elseif ($seconds < 1) {
return round($seconds * 1000, 2) . 'ms';
}
return round($seconds, 2) . 's';
@ -58,7 +58,6 @@ class DataFormatter implements DataFormatterInterface
$count = "count";
$getClass = "get_class";
if ( $var === null ) {
return 'NULL';
} elseif ( is_bool( $var ) ) {
@ -68,8 +67,7 @@ class DataFormatter implements DataFormatterInterface
} elseif ( is_int( $var ) ) {
return 'integer ' . $var;
} elseif ( is_resource( $var ) ) {
if ( ( $type = get_resource_type( $var ) ) === 'stream' AND $meta = stream_get_meta_data( $var ) ) {
if ( ( $type = get_resource_type( $var ) ) === 'stream' and $meta = stream_get_meta_data( $var ) ) {
if ( isset( $meta['uri'] ) ) {
$file = $meta['uri'];
@ -104,9 +102,10 @@ class DataFormatter implements DataFormatterInterface
$var[$marker] = true;
foreach ( $var as $key => &$val ) {
if ( $key === $marker ) continue;
if ( $key === $marker ) {
continue;
}
$key = $space . $s . ( $isSeq ? "" : "'{$html( $key, 0 )}' => " );
@ -116,7 +115,6 @@ class DataFormatter implements DataFormatterInterface
unset( $var[$marker] );
$output[] = "$space]";
} else {
$output[] = "[\n$space$s*depth too great*\n$space]";
}
@ -127,7 +125,7 @@ class DataFormatter implements DataFormatterInterface
}
// Copy the object as an array
$array = (array)$var;
$array = (array) $var;
$output = array();
$space = str_repeat( $s = ' ', $level );
@ -147,7 +145,6 @@ class DataFormatter implements DataFormatterInterface
foreach ( $array as $key => & $val ) {
if ( $key[0] === "\x00" ) {
$access = $key[1] === "*" ? "protected" : "private";
// Remove the access level from the variable name
@ -160,7 +157,6 @@ class DataFormatter implements DataFormatterInterface
}
unset( $objects[$hash] );
$output[] = "$space}";
} else {
$output[] = "{\n$space$s*depth too great*\n$space}";
}

View File

@ -216,7 +216,7 @@ class DebugBar implements ArrayAccess
}
// Remove all invalid (non UTF-8) characters
array_walk_recursive($this->data, function(&$item){
array_walk_recursive($this->data, function (&$item) {
if (is_string($item) && !mb_check_encoding($item, 'UTF-8')) {
$item = mb_convert_encoding($item, 'UTF-8', 'UTF-8');
}
@ -258,7 +258,7 @@ class DebugBar implements ArrayAccess
'data' => $this->getData()
)));
if (strlen($data) > $maxTotalHeaderLength){
if (strlen($data) > $maxTotalHeaderLength) {
$data = rawurlencode(json_encode(array(
'error' => 'Maximum header size exceeded'
)));
@ -314,7 +314,7 @@ class DebugBar implements ArrayAccess
$data = null;
if (!$this->isDataPersisted() || $this->stackAlwaysUseSessionStorage) {
$data = $this->getData();
} else if ($this->data === null) {
} elseif ($this->data === null) {
$this->collect();
}

View File

@ -12,5 +12,5 @@ namespace DebugBar;
class DebugBarException extends \Exception
{
//
}

View File

@ -10,8 +10,8 @@
namespace DebugBar;
use DebugBar\DataCollector\Renderable;
use DebugBar\DataCollector\AssetProvider;
use DebugBar\DataCollector\Renderable;
/**
* Renders the debug bar using the client side javascript implementation
@ -69,7 +69,7 @@ class JavascriptRenderer
protected $ajaxHandlerClass = 'PhpDebugBar.AjaxHandler';
protected $ajaxHandlerBindToJquery = true;
protected $ajaxHandlerBindToXHR = false;
protected $openHandlerClass = 'PhpDebugBar.OpenHandler';
@ -468,7 +468,7 @@ class JavascriptRenderer
{
return $this->ajaxHandlerBindToXHR;
}
/**
* Sets the class name of the js open handler
*
@ -842,7 +842,7 @@ class JavascriptRenderer
$js .= sprintf("%s.ajaxHandler = new %s(%s);\n", $this->variableName, $this->ajaxHandlerClass, $this->variableName);
if ($this->ajaxHandlerBindToXHR) {
$js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName);
} else if ($this->ajaxHandlerBindToJquery) {
} elseif ($this->ajaxHandlerBindToJquery) {
$js .= sprintf("if (jQuery) %s.ajaxHandler.bindToJquery(jQuery);\n", $this->variableName);
}
}
@ -881,7 +881,6 @@ class JavascriptRenderer
}
$controls = array_merge($widgets, $this->controls);
foreach (array_filter($controls) as $name => $options) {
$opts = array_diff_key($options, array_flip($excludedOptions));
@ -896,7 +895,7 @@ class JavascriptRenderer
substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1),
isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : ''
);
} else if (isset($options['indicator']) || isset($options['icon'])) {
} elseif (isset($options['indicator']) || isset($options['icon'])) {
$js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n",
$varname,
$name,

View File

@ -49,7 +49,7 @@ class OpenHandler
if ($sendHeader) {
$this->debugBar->getHttpDriver()->setHeaders(array(
'Content-Type'=> 'application/json'
'Content-Type' => 'application/json'
));
}

View File

@ -10,12 +10,12 @@
namespace DebugBar;
use DebugBar\DataCollector\PhpInfoCollector;
use DebugBar\DataCollector\MessagesCollector;
use DebugBar\DataCollector\TimeDataCollector;
use DebugBar\DataCollector\RequestDataCollector;
use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\ExceptionsCollector;
use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\MessagesCollector;
use DebugBar\DataCollector\PhpInfoCollector;
use DebugBar\DataCollector\RequestDataCollector;
use DebugBar\DataCollector\TimeDataCollector;
/**
* Debug bar subclass which adds all included collectors

View File

@ -52,7 +52,7 @@ class FileStorage implements StorageInterface
}
//Sort the files, newest first
usort($files, function($a, $b) {
usort($files, function ($a, $b) {
return $a['time'] < $b['time'];
});