PSR-12 + action (#1087)
This commit is contained in:
parent
5d11919868
commit
51c8ea3ab2
|
@ -37,3 +37,36 @@ jobs:
|
|||
|
||||
- name: Execute Unit Tests
|
||||
run: composer test
|
||||
|
||||
fix-style:
|
||||
name: Fix Code Style
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
COMPOSER_NO_INTERACTION: 1
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
tools: composer:v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer update --prefer-dist --no-suggest --no-progress
|
||||
|
||||
- run: composer fix-style
|
||||
continue-on-error: true
|
||||
|
||||
# Revert modifications so they don't get commited 💥
|
||||
- run: git checkout -- composer.json
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: composer fix-style
|
||||
commit_author: laravel-debugbar <laravel-debugbar@users.noreply.github.com>
|
|
@ -52,8 +52,8 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check-style": "phpcs -p --standard=PSR12 config/ resources/ src/ tests/",
|
||||
"fix-style": "phpcbf -p --standard=PSR12 config/ resources/ src/ tests/",
|
||||
"check-style": "phpcs -p --standard=PSR12 config/ src/ tests/",
|
||||
"fix-style": "phpcbf -p --standard=PSR12 config/ src/ tests/",
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ return [
|
|||
'timeline' => false, // Add the queries to the timeline
|
||||
'explain' => [ // Show EXPLAIN output on queries
|
||||
'enabled' => false,
|
||||
'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
|
||||
'types' => ['SELECT'], // Deprecated setting, is always only SELECT
|
||||
],
|
||||
'hints' => false, // Show hints for common mistakes
|
||||
'show_copy' => false, // Show copy button next to the query
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
@ -27,7 +28,7 @@ class CreatePhpdebugbarStorageTable extends Migration
|
|||
$table->index('meta_uri');
|
||||
$table->index('meta_ip');
|
||||
$table->index('meta_method');
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Reverse the migrations.
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Console;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Console;
|
||||
|
||||
use DebugBar\DebugBar;
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -21,12 +23,11 @@ class ClearCommand extends Command
|
|||
$this->debugbar->boot();
|
||||
|
||||
if ($storage = $this->debugbar->getStorage()) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$storage->clear();
|
||||
} catch(\InvalidArgumentException $e) {
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// hide InvalidArgumentException if storage location does not exist
|
||||
if(strpos($e->getMessage(), 'does not exist') === false) {
|
||||
if (strpos($e->getMessage(), 'does not exist') === false) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Controllers;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
|
@ -16,7 +18,9 @@ class AssetController extends BaseController
|
|||
$content = $renderer->dumpAssetsToString('js');
|
||||
|
||||
$response = new Response(
|
||||
$content, 200, [
|
||||
$content,
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'text/javascript',
|
||||
]
|
||||
);
|
||||
|
@ -36,7 +40,9 @@ class AssetController extends BaseController
|
|||
$content = $renderer->dumpAssetsToString('css');
|
||||
|
||||
$response = new Response(
|
||||
$content, 200, [
|
||||
$content,
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'text/css',
|
||||
]
|
||||
);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php namespace Barryvdh\Debugbar\Controllers;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Controllers;
|
||||
|
||||
use Barryvdh\Debugbar\LaravelDebugbar;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Telescope\Telescope;
|
||||
|
||||
// phpcs:ignoreFile
|
||||
if (class_exists('Illuminate\Routing\Controller')) {
|
||||
|
||||
class BaseController extends Controller
|
||||
|
@ -15,7 +18,7 @@ if (class_exists('Illuminate\Routing\Controller')) {
|
|||
{
|
||||
$this->debugbar = $debugbar;
|
||||
|
||||
if ($request->hasSession()){
|
||||
if ($request->hasSession()) {
|
||||
$request->session()->reflash();
|
||||
}
|
||||
|
||||
|
@ -38,7 +41,7 @@ if (class_exists('Illuminate\Routing\Controller')) {
|
|||
{
|
||||
$this->debugbar = $debugbar;
|
||||
|
||||
if ($request->hasSession()){
|
||||
if ($request->hasSession()) {
|
||||
$request->session()->reflash();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Controllers;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
|
@ -23,5 +25,4 @@ class CacheController extends BaseController
|
|||
|
||||
return response()->json(compact('success'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Controllers;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Controllers;
|
||||
|
||||
use Barryvdh\Debugbar\Support\Clockwork\Converter;
|
||||
use DebugBar\OpenHandler;
|
||||
|
@ -13,7 +15,9 @@ class OpenHandlerController extends BaseController
|
|||
$data = $openHandler->handle(null, false, false);
|
||||
|
||||
return new Response(
|
||||
$data, 200, [
|
||||
$data,
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'application/json'
|
||||
]
|
||||
);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Controllers;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Controllers;
|
||||
|
||||
use Barryvdh\Debugbar\Support\Clockwork\Converter;
|
||||
use DebugBar\OpenHandler;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
|
@ -22,7 +23,7 @@ class CacheCollector extends TimeDataCollector
|
|||
KeyForgotten::class => 'forgotten',
|
||||
];
|
||||
|
||||
public function __construct($requestStartTime = null, $collectValues)
|
||||
public function __construct($requestStartTime, $collectValues)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use Barryvdh\Debugbar\DataFormatter\SimpleFormatter;
|
||||
|
@ -29,7 +30,6 @@ class EventCollector extends TimeDataCollector
|
|||
|
||||
// Find all listeners for the current event
|
||||
foreach ($this->events->getListeners($name) as $i => $listener) {
|
||||
|
||||
// Check if it's an object + method name
|
||||
if (is_array($listener) && count($listener) > 1 && is_object($listener[0])) {
|
||||
list($class, $method) = $listener;
|
||||
|
@ -53,7 +53,8 @@ class EventCollector extends TimeDataCollector
|
|||
|
||||
// Format the closure to a readable format
|
||||
$filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/');
|
||||
$listener = $reflector->getName() . ' (' . $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . ')';
|
||||
$lines = $reflector->getStartLine() . '-' . $reflector->getEndLine();
|
||||
$listener = $reflector->getName() . ' (' . $filename . ':' . $lines . ')';
|
||||
} else {
|
||||
// Not sure if this is possible, but to prevent edge cases
|
||||
$listener = $this->getDataFormatter()->formatVar($listener);
|
||||
|
|
|
@ -34,7 +34,8 @@ class FilesCollector extends DataCollector implements Renderable
|
|||
foreach ($files as $file) {
|
||||
// Skip the files from Debugbar, they are only loaded for Debugging and confuse the output.
|
||||
// Of course some files are stil always loaded (ServiceProvider, Facade etc)
|
||||
if (strpos($file, 'vendor/maximebf/debugbar/src') !== false || strpos(
|
||||
if (
|
||||
strpos($file, 'vendor/maximebf/debugbar/src') !== false || strpos(
|
||||
$file,
|
||||
'vendor/barryvdh/laravel-debugbar/src'
|
||||
) !== false
|
||||
|
|
|
@ -22,12 +22,12 @@ class GateCollector extends MessagesCollector
|
|||
{
|
||||
parent::__construct('gate');
|
||||
$this->setDataFormatter(new SimpleFormatter());
|
||||
$gate->after(function ($user = null, $ability, $result, $arguments = []) {
|
||||
$gate->after(function ($user, $ability, $result, $arguments = []) {
|
||||
$this->addCheck($user, $ability, $result, $arguments);
|
||||
});
|
||||
}
|
||||
|
||||
public function addCheck($user = null, $ability, $result, $arguments = [])
|
||||
public function addCheck($user, $ability, $result, $arguments = [])
|
||||
{
|
||||
$userKey = 'user';
|
||||
$userId = null;
|
||||
|
|
|
@ -23,12 +23,12 @@ class LivewireCollector extends DataCollector implements DataCollectorInterface,
|
|||
public function __construct(Request $request)
|
||||
{
|
||||
// Listen to Livewire views
|
||||
Livewire::listen('view:render', function(View $view) use ($request) {
|
||||
Livewire::listen('view:render', function (View $view) use ($request) {
|
||||
/** @var \Livewire\Component $component */
|
||||
$component = $view->getData()['_instance'];
|
||||
|
||||
// Create an unique name for each compoent
|
||||
$key = $component->getName() . ' #' .$component->id;
|
||||
$key = $component->getName() . ' #' . $component->id;
|
||||
|
||||
$data = [
|
||||
'data' => $component->getPublicPropertiesDefinedBySubClass(),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
|
|
|
@ -11,7 +11,6 @@ use Illuminate\Contracts\Auth\Guard;
|
|||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
|
@ -55,13 +54,13 @@ class MultiAuthCollector extends DataCollector implements Renderable
|
|||
];
|
||||
$names = '';
|
||||
|
||||
foreach($this->guards as $guardName => $config) {
|
||||
foreach ($this->guards as $guardName => $config) {
|
||||
try {
|
||||
$guard = $this->auth->guard($guardName);
|
||||
if ($this->hasUser($guard)) {
|
||||
$user = $guard->user();
|
||||
|
||||
if(!is_null($user)) {
|
||||
if (!is_null($user)) {
|
||||
$data['guards'][$guardName] = $this->getUserInformation($user);
|
||||
$names .= $guardName . ": " . $data['guards'][$guardName]['name'] . ', ';
|
||||
}
|
||||
|
@ -166,5 +165,4 @@ class MultiAuthCollector extends DataCollector implements Renderable
|
|||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\PhpInfoCollector as DebugBarPhpInfoCollector;
|
||||
|
|
|
@ -126,7 +126,7 @@ class QueryCollector extends PDOCollector
|
|||
$bindings = $connection->prepareBindings($bindings);
|
||||
|
||||
// Run EXPLAIN on this query (if needed)
|
||||
if ($this->explainQuery && $pdo && preg_match('/^\s*('.implode('|', $this->explainTypes).') /i', $query)) {
|
||||
if ($this->explainQuery && $pdo && preg_match('/^\s*(' . implode('|', $this->explainTypes) . ') /i', $query)) {
|
||||
$statement = $pdo->prepare('EXPLAIN ' . $query);
|
||||
$statement->execute($bindings);
|
||||
$explainResults = $statement->fetchAll(\PDO::FETCH_CLASS);
|
||||
|
@ -210,6 +210,7 @@ class QueryCollector extends PDOCollector
|
|||
*/
|
||||
protected function performQueryAnalysis($query)
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
$hints = [];
|
||||
if (preg_match('/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i', $query)) {
|
||||
$hints[] = 'Use <code>SELECT *</code> only if you need all columns from table';
|
||||
|
@ -229,10 +230,12 @@ class QueryCollector extends PDOCollector
|
|||
$hints[] = '<code>LIMIT</code> without <code>ORDER BY</code> causes non-deterministic results, depending on the query execution plan';
|
||||
}
|
||||
if (preg_match('/LIKE\\s[\'"](%.*?)[\'"]/i', $query, $matches)) {
|
||||
$hints[] = 'An argument has a leading wildcard character: <code>' . $matches[1]. '</code>.
|
||||
$hints[] = 'An argument has a leading wildcard character: <code>' . $matches[1] . '</code>.
|
||||
The predicate with this argument is not sargable and cannot use an index if one exists.';
|
||||
}
|
||||
return $hints;
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +278,8 @@ class QueryCollector extends PDOCollector
|
|||
return $frame;
|
||||
}
|
||||
|
||||
if (isset($trace['class']) &&
|
||||
if (
|
||||
isset($trace['class']) &&
|
||||
isset($trace['file']) &&
|
||||
!$this->fileIsInExcludedPath($trace['file'])
|
||||
) {
|
||||
|
@ -369,7 +373,7 @@ class QueryCollector extends PDOCollector
|
|||
$this->reflection['viewfinderViews'] = $property;
|
||||
}
|
||||
|
||||
foreach ($property->getValue($finder) as $name => $path){
|
||||
foreach ($property->getValue($finder) as $name => $path) {
|
||||
if (sha1($path) == $hash || md5($path) == $hash) {
|
||||
return $name;
|
||||
}
|
||||
|
@ -476,9 +480,9 @@ class QueryCollector extends PDOCollector
|
|||
];
|
||||
|
||||
//Add the results from the explain as new rows
|
||||
foreach($query['explain'] as $explain){
|
||||
foreach ($query['explain'] as $explain) {
|
||||
$statements[] = [
|
||||
'sql' => ' - EXPLAIN #' . $explain->id . ': `' . $explain->table . '` (' . $explain->select_type . ')',
|
||||
'sql' => " - EXPLAIN # {$explain->id}: `{$explain->table}` ({$explain->select_type})",
|
||||
'type' => 'explain',
|
||||
'params' => $explain,
|
||||
'row_count' => $explain->rows,
|
||||
|
|
|
@ -30,7 +30,7 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
* Create a new SymfonyRequestCollector
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Symfony\Component\HttpFoundation\Request $response
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
|
||||
*/
|
||||
public function __construct($request, $response, $session = null, $currentRequestId = null)
|
||||
|
@ -116,8 +116,10 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
}
|
||||
|
||||
foreach ($data['request_server'] as $key => $value) {
|
||||
if (Str::is('*_KEY', $key) || Str::is('*_PASSWORD', $key)
|
||||
|| Str::is('*_SECRET', $key) || Str::is('*_PW', $key)) {
|
||||
if (
|
||||
Str::is('*_KEY', $key) || Str::is('*_PASSWORD', $key)
|
||||
|| Str::is('*_SECRET', $key) || Str::is('*_PW', $key)
|
||||
) {
|
||||
$data['request_server'][$key] = '******';
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +131,7 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
if (isset($data['request_server']['PHP_AUTH_PW'])) {
|
||||
$data['request_server']['PHP_AUTH_PW'] = '******';
|
||||
}
|
||||
;
|
||||
;
|
||||
|
||||
foreach ($data as $key => $var) {
|
||||
if (!is_string($data[$key])) {
|
||||
|
@ -137,7 +139,6 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
} else {
|
||||
$data[$key] = e($data[$key]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$htmlData = [];
|
||||
|
@ -147,7 +148,7 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
])->type('debugbar');
|
||||
Telescope::$entriesQueue[] = $entry;
|
||||
$url = route('debugbar.telescope', [$entry->uuid]);
|
||||
$htmlData['telescope'] = '<a href="'.$url.'" target="_blank">View in Telescope</a>';
|
||||
$htmlData['telescope'] = '<a href="' . $url . '" target="_blank">View in Telescope</a>';
|
||||
}
|
||||
|
||||
return $htmlData + $data;
|
||||
|
@ -172,10 +173,10 @@ class RequestCollector extends DataCollector implements DataCollectorInterface,
|
|||
}
|
||||
|
||||
$cookie .= '; expires=' . substr(
|
||||
\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'),
|
||||
0,
|
||||
-5
|
||||
);
|
||||
\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'),
|
||||
0,
|
||||
-5
|
||||
);
|
||||
}
|
||||
|
||||
if ($domain) {
|
||||
|
|
|
@ -49,22 +49,26 @@ class RouteCollector extends DataCollector implements Renderable
|
|||
return [];
|
||||
}
|
||||
$uri = head($route->methods()) . ' ' . $route->uri();
|
||||
$action = $route->getAction();
|
||||
$action = $route->getAction();
|
||||
|
||||
$result = [
|
||||
'uri' => $uri ?: '-',
|
||||
'uri' => $uri ?: '-',
|
||||
];
|
||||
|
||||
$result = array_merge($result, $action);
|
||||
|
||||
|
||||
if (isset($action['controller']) && is_string($action['controller']) && strpos($action['controller'], '@') !== false) {
|
||||
list($controller, $method) = explode('@', $action['controller']);
|
||||
if(class_exists($controller) && method_exists($controller, $method)) {
|
||||
$reflector = new \ReflectionMethod($controller, $method);
|
||||
}
|
||||
if (
|
||||
isset($action['controller'])
|
||||
&& is_string($action['controller'])
|
||||
&& strpos($action['controller'], '@') !== false
|
||||
) {
|
||||
list($controller, $method) = explode('@', $action['controller']);
|
||||
if (class_exists($controller) && method_exists($controller, $method)) {
|
||||
$reflector = new \ReflectionMethod($controller, $method);
|
||||
}
|
||||
unset($result['uses']);
|
||||
} elseif (isset($action['uses']) && $action['uses'] instanceof \Closure) {
|
||||
} elseif (isset($action['uses']) && $action['uses'] instanceof \Closure) {
|
||||
$reflector = new \ReflectionFunction($action['uses']);
|
||||
$result['uses'] = $this->formatVar($result['uses']);
|
||||
}
|
||||
|
@ -74,9 +78,9 @@ class RouteCollector extends DataCollector implements Renderable
|
|||
$result['file'] = $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine();
|
||||
}
|
||||
|
||||
if ($middleware = $this->getMiddleware($route)) {
|
||||
$result['middleware'] = $middleware;
|
||||
}
|
||||
if ($middleware = $this->getMiddleware($route)) {
|
||||
$result['middleware'] = $middleware;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class ViewCollector extends TwigCollector
|
|||
'type' => $type,
|
||||
];
|
||||
|
||||
if ( $this->getXdebugLink($path)) {
|
||||
if ($this->getXdebugLink($path)) {
|
||||
$template['xdebug_link'] = $this->getXdebugLink($path);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ class QueryFormatter extends DataFormatter
|
|||
*/
|
||||
public function formatSql($sql)
|
||||
{
|
||||
$sql = preg_replace("/\?(?=(?:[^'\\\']*'[^'\\']*')*[^'\\\']*$)(?:\?)/", '?', $sql);
|
||||
$sql = trim(preg_replace("/\s*\n\s*/", "\n", $sql));
|
||||
$sql = preg_replace("/\?(?=(?:[^'\\\']*'[^'\\']*')*[^'\\\']*$)(?:\?)/", '?', $sql);
|
||||
$sql = trim(preg_replace("/\s*\n\s*/", "\n", $sql));
|
||||
|
||||
return $sql;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,8 @@ class SimpleFormatter extends DataFormatter
|
|||
}
|
||||
|
||||
if ($deep) {
|
||||
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
|
||||
$args = [$indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1)];
|
||||
return sprintf("[\n%s%s\n%s]", $args);
|
||||
}
|
||||
|
||||
$s = sprintf('[%s]', implode(', ', $a));
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
<?php namespace Barryvdh\Debugbar;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar;
|
||||
|
||||
use DebugBar\DataCollector\DataCollectorInterface;
|
||||
|
||||
/**
|
||||
* @method static \Barryvdh\Debugbar\LaravelDebugbar addCollector(\DebugBar\DataCollector\DataCollectorInterface $collector)
|
||||
* @method static LaravelDebugbar addCollector(DataCollectorInterface $collector)
|
||||
* @method static void addMessage(mixed $message, string $label = 'info')
|
||||
* @method static void alert(mixed $message)
|
||||
* @method static void critical(mixed $message)
|
||||
* @method static void debug(mixed $message)
|
||||
* @method static void emergency(mixed $message)
|
||||
* @method static void error(mixed $message)
|
||||
* @method static \Barryvdh\Debugbar\LaravelDebugbar getCollector(string $name)
|
||||
* @method static LaravelDebugbar getCollector(string $name)
|
||||
* @method static bool hasCollector(string $name)
|
||||
* @method static void info(mixed $message)
|
||||
* @method static void log(mixed $message)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar;
|
||||
|
||||
use DebugBar\DebugBar;
|
||||
use DebugBar\JavascriptRenderer as BaseJavascriptRenderer;
|
||||
|
@ -42,7 +44,6 @@ class JavascriptRenderer extends BaseJavascriptRenderer
|
|||
*/
|
||||
public function setUrlGenerator($url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar;
|
||||
|
||||
use Barryvdh\Debugbar\DataCollector\AuthCollector;
|
||||
use Barryvdh\Debugbar\DataCollector\CacheCollector;
|
||||
|
@ -31,7 +33,6 @@ use DebugBar\DebugBar;
|
|||
use DebugBar\Storage\PdoStorage;
|
||||
use DebugBar\Storage\RedisStorage;
|
||||
use Exception;
|
||||
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Str;
|
||||
|
@ -130,7 +131,7 @@ class LaravelDebugbar extends DebugBar
|
|||
$app = $this->app;
|
||||
|
||||
// Set custom error handler
|
||||
if ($app['config']->get('debugbar.error_handler' , false)) {
|
||||
if ($app['config']->get('debugbar.error_handler', false)) {
|
||||
set_error_handler([$this, 'handleError']);
|
||||
}
|
||||
|
||||
|
@ -147,7 +148,7 @@ class LaravelDebugbar extends DebugBar
|
|||
if ($this->shouldCollect('time', true)) {
|
||||
$this->addCollector(new TimeDataCollector());
|
||||
|
||||
if ( ! $this->isLumen()) {
|
||||
if (! $this->isLumen()) {
|
||||
$this->app->booted(
|
||||
function () use ($debugbar) {
|
||||
$startTime = $this->app['request']->server('REQUEST_TIME_FLOAT');
|
||||
|
@ -190,7 +191,6 @@ class LaravelDebugbar extends DebugBar
|
|||
$eventCollector = new EventCollector($startTime);
|
||||
$this->addCollector($eventCollector);
|
||||
$this->app['events']->subscribe($eventCollector);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
|
@ -218,7 +218,9 @@ class LaravelDebugbar extends DebugBar
|
|||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
|
||||
'Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -277,7 +279,9 @@ class LaravelDebugbar extends DebugBar
|
|||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
|
||||
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -285,7 +289,8 @@ class LaravelDebugbar extends DebugBar
|
|||
|
||||
if ($this->shouldCollect('db', true) && isset($this->app['db'])) {
|
||||
$db = $this->app['db'];
|
||||
if ($debugbar->hasCollector('time') && $this->app['config']->get(
|
||||
if (
|
||||
$debugbar->hasCollector('time') && $this->app['config']->get(
|
||||
'debugbar.options.db.timeline',
|
||||
false
|
||||
)
|
||||
|
@ -329,14 +334,22 @@ class LaravelDebugbar extends DebugBar
|
|||
|
||||
try {
|
||||
$db->listen(
|
||||
function ($query, $bindings = null, $time = null, $connectionName = null) use ($db, $queryCollector) {
|
||||
function (
|
||||
$query,
|
||||
$bindings = null,
|
||||
$time = null,
|
||||
$connectionName = null
|
||||
) use (
|
||||
$db,
|
||||
$queryCollector
|
||||
) {
|
||||
if (!$this->shouldCollect('db', true)) {
|
||||
return; // Issue 776 : We've turned off collecting after the listener was attached
|
||||
}
|
||||
// Laravel 5.2 changed the way some core events worked. We must account for
|
||||
// the first argument being an "event object", where arguments are passed
|
||||
// via object properties, instead of individual arguments.
|
||||
if ( $query instanceof \Illuminate\Database\Events\QueryExecuted ) {
|
||||
if ($query instanceof \Illuminate\Database\Events\QueryExecuted) {
|
||||
$bindings = $query->bindings;
|
||||
$time = $query->time;
|
||||
$connection = $query->connection;
|
||||
|
@ -420,7 +433,7 @@ class LaravelDebugbar extends DebugBar
|
|||
try {
|
||||
$modelsCollector = $this->app->make('Barryvdh\Debugbar\DataCollector\ModelsCollector');
|
||||
$this->addCollector($modelsCollector);
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
// No Models collector
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +442,7 @@ class LaravelDebugbar extends DebugBar
|
|||
try {
|
||||
$livewireCollector = $this->app->make('Barryvdh\Debugbar\DataCollector\LivewireCollector');
|
||||
$this->addCollector($livewireCollector);
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception('Cannot add Livewire Collector: ' . $e->getMessage(), $e->getCode(), $e)
|
||||
);
|
||||
|
@ -440,7 +453,8 @@ class LaravelDebugbar extends DebugBar
|
|||
try {
|
||||
$mailer = $this->app['mailer']->getSwiftMailer();
|
||||
$this->addCollector(new SwiftMailCollector($mailer));
|
||||
if ($this->app['config']->get('debugbar.options.mail.full_log') && $this->hasCollector(
|
||||
if (
|
||||
$this->app['config']->get('debugbar.options.mail.full_log') && $this->hasCollector(
|
||||
'messages'
|
||||
)
|
||||
) {
|
||||
|
@ -449,7 +463,9 @@ class LaravelDebugbar extends DebugBar
|
|||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add MailCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
|
||||
'Cannot add MailCollector to Laravel Debugbar: ' . $e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -462,7 +478,9 @@ class LaravelDebugbar extends DebugBar
|
|||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
|
||||
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -471,29 +489,31 @@ class LaravelDebugbar extends DebugBar
|
|||
$this->addCollector(new FilesCollector($app));
|
||||
}
|
||||
|
||||
if ($this->shouldCollect('auth', false)) {
|
||||
try {
|
||||
$guards = $this->app['config']->get('auth.guards', []);
|
||||
$authCollector = new MultiAuthCollector($app['auth'], $guards);
|
||||
if ($this->shouldCollect('auth', false)) {
|
||||
try {
|
||||
$guards = $this->app['config']->get('auth.guards', []);
|
||||
$authCollector = new MultiAuthCollector($app['auth'], $guards);
|
||||
|
||||
$authCollector->setShowName(
|
||||
$this->app['config']->get('debugbar.options.auth.show_name')
|
||||
);
|
||||
$this->addCollector($authCollector);
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add AuthCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$authCollector->setShowName(
|
||||
$this->app['config']->get('debugbar.options.auth.show_name')
|
||||
);
|
||||
$this->addCollector($authCollector);
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
'Cannot add AuthCollector to Laravel Debugbar: ' . $e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->shouldCollect('gate', false)) {
|
||||
try {
|
||||
$gateCollector = $this->app->make('Barryvdh\Debugbar\DataCollector\GateCollector');
|
||||
$this->addCollector($gateCollector);
|
||||
} catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
// No Gate collector
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +525,6 @@ class LaravelDebugbar extends DebugBar
|
|||
$cacheCollector = new CacheCollector($startTime, $collectValues);
|
||||
$this->addCollector($cacheCollector);
|
||||
$this->app['events']->subscribe($cacheCollector);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
|
@ -676,7 +695,7 @@ class LaravelDebugbar extends DebugBar
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->app->bound(SessionManager::class)){
|
||||
if ($this->app->bound(SessionManager::class)) {
|
||||
|
||||
/** @var \Illuminate\Session\SessionManager $sessionManager */
|
||||
$sessionManager = $app->make(SessionManager::class);
|
||||
|
@ -702,7 +721,8 @@ class LaravelDebugbar extends DebugBar
|
|||
|
||||
if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
|
||||
try {
|
||||
$this->addCollector(new RequestCollector($request, $response, $sessionManager, $this->getCurrentRequestId()));
|
||||
$reqId = $this->getCurrentRequestId();
|
||||
$this->addCollector(new RequestCollector($request, $response, $sessionManager, $reqId));
|
||||
} catch (\Exception $e) {
|
||||
$this->addThrowable(
|
||||
new Exception(
|
||||
|
@ -715,7 +735,6 @@ class LaravelDebugbar extends DebugBar
|
|||
}
|
||||
|
||||
if ($app['config']->get('debugbar.clockwork') && ! $this->hasCollector('clockwork')) {
|
||||
|
||||
try {
|
||||
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
|
||||
} catch (\Exception $e) {
|
||||
|
@ -747,16 +766,15 @@ class LaravelDebugbar extends DebugBar
|
|||
if ($app['config']->get('debugbar.add_ajax_timing', false)) {
|
||||
$this->addServerTimingHeaders($response);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$app['log']->error('Debugbar exception: ' . $e->getMessage());
|
||||
}
|
||||
} elseif (
|
||||
($response->headers->has('Content-Type') &&
|
||||
strpos($response->headers->get('Content-Type'), 'html') === false)
|
||||
|| $request->getRequestFormat() !== 'html'
|
||||
|| $response->getContent() === false
|
||||
|| $this->isJsonRequest($request)
|
||||
strpos($response->headers->get('Content-Type'), 'html') === false) ||
|
||||
$request->getRequestFormat() !== 'html' ||
|
||||
$response->getContent() === false ||
|
||||
$this->isJsonRequest($request)
|
||||
) {
|
||||
try {
|
||||
// Just collect + store data, don't inject it.
|
||||
|
@ -1013,7 +1031,7 @@ class LaravelDebugbar extends DebugBar
|
|||
{
|
||||
$messageLevels = ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug', 'log'];
|
||||
if (in_array($method, $messageLevels)) {
|
||||
foreach($args as $arg) {
|
||||
foreach ($args as $arg) {
|
||||
$this->addMessage($arg, $method);
|
||||
}
|
||||
}
|
||||
|
@ -1097,7 +1115,7 @@ class LaravelDebugbar extends DebugBar
|
|||
$prefix = $this->app['config']->get('debugbar.route_prefix');
|
||||
$response->headers->set('X-Clockwork-Id', $this->getCurrentRequestId(), true);
|
||||
$response->headers->set('X-Clockwork-Version', 1, true);
|
||||
$response->headers->set('X-Clockwork-Path', $prefix .'/clockwork/', true);
|
||||
$response->headers->set('X-Clockwork-Path', $prefix . '/clockwork/', true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar;
|
||||
|
||||
use Laravel\Lumen\Application;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Middleware;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -37,6 +39,5 @@ class DebugbarEnabled
|
|||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Middleware;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Middleware;
|
||||
|
||||
use Error;
|
||||
use Closure;
|
||||
|
@ -74,7 +76,6 @@ class InjectDebugbar
|
|||
$this->debugbar->modifyResponse($request, $response);
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function($) {
|
||||
(function ($) {
|
||||
|
||||
var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');
|
||||
|
||||
|
@ -14,39 +14,39 @@
|
|||
|
||||
className: csscls('timeline cache'),
|
||||
|
||||
onForgetClick: function(e, el) {
|
||||
onForgetClick: function (e, el) {
|
||||
e.stopPropagation();
|
||||
|
||||
$.ajax({
|
||||
url: $(el).attr("data-url"),
|
||||
type: 'DELETE',
|
||||
success: function(result) {
|
||||
success: function (result) {
|
||||
$(el).fadeOut(200);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
render: function () {
|
||||
LaravelCacheWidget.__super__.render.apply(this);
|
||||
|
||||
this.bindAttr('data', function(data) {
|
||||
this.bindAttr('data', function (data) {
|
||||
|
||||
if (data.measures) {
|
||||
var self = this;
|
||||
var lines = this.$el.find('.'+csscls('measure'));
|
||||
var lines = this.$el.find('.' + csscls('measure'));
|
||||
|
||||
for (var i = 0; i < data.measures.length; i++) {
|
||||
var measure = data.measures[i];
|
||||
var m = lines[i];
|
||||
|
||||
if (measure.params && !$.isEmptyObject(measure.params)) {
|
||||
|
||||
if (measure.params.delete && measure.params.key) {
|
||||
$('<a />')
|
||||
.addClass(csscls('forget'))
|
||||
.text('forget')
|
||||
.attr('data-url', measure.params.delete)
|
||||
.one('click', function(e) { self.onForgetClick(e, this); })
|
||||
.one('click', function (e) {
|
||||
self.onForgetClick(e, this); })
|
||||
.appendTo(m);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function($) {
|
||||
(function ($) {
|
||||
|
||||
var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');
|
||||
|
||||
|
@ -12,11 +12,11 @@
|
|||
|
||||
className: csscls('sqlqueries'),
|
||||
|
||||
onFilterClick: function(el) {
|
||||
onFilterClick: function (el) {
|
||||
$(el).toggleClass(csscls('excluded'));
|
||||
|
||||
var excludedLabels = [];
|
||||
this.$toolbar.find(csscls('.filter') + csscls('.excluded')).each(function() {
|
||||
this.$toolbar.find(csscls('.filter') + csscls('.excluded')).each(function () {
|
||||
excludedLabels.push(this.rel);
|
||||
});
|
||||
|
||||
|
@ -52,14 +52,14 @@
|
|||
select(code);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
render: function () {
|
||||
this.$status = $('<div />').addClass(csscls('status')).appendTo(this.$el);
|
||||
|
||||
this.$toolbar = $('<div></div>').addClass(csscls('toolbar')).appendTo(this.$el);
|
||||
|
||||
var filters = [], self = this;
|
||||
|
||||
this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, stmt) {
|
||||
this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function (li, stmt) {
|
||||
if (stmt.type === 'transaction') {
|
||||
$('<strong />').addClass(csscls('sql')).addClass(csscls('name')).text(stmt.sql).appendTo(li);
|
||||
} else {
|
||||
|
@ -86,9 +86,10 @@
|
|||
.addClass(csscls('filter'))
|
||||
.text(stmt.connection)
|
||||
.attr('rel', stmt.connection)
|
||||
.on('click', function() { self.onFilterClick(this); })
|
||||
.on('click', function () {
|
||||
self.onFilterClick(this); })
|
||||
.appendTo(self.$toolbar);
|
||||
if (filters.length>1) {
|
||||
if (filters.length > 1) {
|
||||
self.$toolbar.show();
|
||||
self.$list.$el.css("margin-bottom","20px");
|
||||
}
|
||||
|
@ -120,7 +121,7 @@
|
|||
var $span = $('<span />').addClass('phpdebugbar-text-muted');
|
||||
|
||||
var index = 0;
|
||||
var $bindings = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, binding) {
|
||||
var $bindings = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function (li, binding) {
|
||||
var $index = $span.clone().text(index++ + '.');
|
||||
li.append($index, ' ', binding).removeClass(csscls('list-item')).addClass(csscls('table-list-item'));
|
||||
}});
|
||||
|
@ -143,7 +144,7 @@
|
|||
var $name = $('<td />').addClass(csscls('name')).html('Hints ' + $icon);
|
||||
var $value = $('<td />').addClass(csscls('value'));
|
||||
|
||||
var $hints = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, hint) {
|
||||
var $hints = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function (li, hint) {
|
||||
li.append(hint).removeClass(csscls('list-item')).addClass(csscls('table-list-item'));
|
||||
}});
|
||||
|
||||
|
@ -165,7 +166,7 @@
|
|||
var $value = $('<td />').addClass(csscls('value'));
|
||||
var $span = $('<span />').addClass('phpdebugbar-text-muted');
|
||||
|
||||
var $backtrace = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, source) {
|
||||
var $backtrace = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function (li, source) {
|
||||
var $parts = [
|
||||
$span.clone().text(source.index + '.'),
|
||||
' ',
|
||||
|
@ -201,7 +202,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
li.css('cursor', 'pointer').click(function() {
|
||||
li.css('cursor', 'pointer').click(function () {
|
||||
if (table.is(':visible')) {
|
||||
table.hide();
|
||||
} else {
|
||||
|
@ -211,14 +212,14 @@
|
|||
}});
|
||||
this.$list.$el.appendTo(this.$el);
|
||||
|
||||
this.bindAttr('data', function(data) {
|
||||
this.bindAttr('data', function (data) {
|
||||
this.$list.set('data', data.statements);
|
||||
this.$status.empty();
|
||||
var stmt;
|
||||
|
||||
// Search for duplicate statements.
|
||||
for (var sql = {}, duplicate = 0, i = 0; i < data.statements.length; i++) {
|
||||
if(data.statements[i].type === 'query') {
|
||||
if (data.statements[i].type === 'query') {
|
||||
stmt = data.statements[i].sql;
|
||||
if (data.statements[i].bindings && data.statements[i].bindings.length) {
|
||||
stmt += JSON.stringify(data.statements[i].bindings);
|
||||
|
@ -238,7 +239,7 @@
|
|||
for (i = 0; i < sql[stmt].keys.length; i++) {
|
||||
this.$list.$el.find('.' + csscls('list-item')).eq(sql[stmt].keys[i])
|
||||
.addClass(csscls('sql-duplicate'))
|
||||
.addClass(csscls('sql-duplicate-'+duplicate));
|
||||
.addClass(csscls('sql-duplicate-' + duplicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar;
|
||||
|
||||
use Barryvdh\Debugbar\Middleware\DebugbarEnabled;
|
||||
use Barryvdh\Debugbar\Middleware\InjectDebugbar;
|
||||
|
@ -27,7 +29,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
|||
$configPath = __DIR__ . '/../config/debugbar.php';
|
||||
$this->mergeConfigFrom($configPath, 'debugbar');
|
||||
|
||||
$this->loadRoutesFrom(realpath(__DIR__.'/debugbar-routes.php'));
|
||||
$this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php'));
|
||||
|
||||
$this->app->alias(
|
||||
DataFormatter::class,
|
||||
|
@ -37,19 +39,19 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
|||
$this->app->singleton(LaravelDebugbar::class, function () {
|
||||
$debugbar = new LaravelDebugbar($this->app);
|
||||
|
||||
if ($this->app->bound(SessionManager::class)) {
|
||||
$sessionManager = $this->app->make(SessionManager::class);
|
||||
$httpDriver = new SymfonyHttpDriver($sessionManager);
|
||||
$debugbar->setHttpDriver($httpDriver);
|
||||
}
|
||||
if ($this->app->bound(SessionManager::class)) {
|
||||
$sessionManager = $this->app->make(SessionManager::class);
|
||||
$httpDriver = new SymfonyHttpDriver($sessionManager);
|
||||
$debugbar->setHttpDriver($httpDriver);
|
||||
}
|
||||
|
||||
return $debugbar;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$this->app->alias(LaravelDebugbar::class, 'debugbar');
|
||||
|
||||
$this->app->singleton('command.debugbar.clear',
|
||||
$this->app->singleton(
|
||||
'command.debugbar.clear',
|
||||
function ($app) {
|
||||
return new Console\ClearCommand($app['debugbar']);
|
||||
}
|
||||
|
|
|
@ -67,9 +67,11 @@ class FilesystemStorage implements StorageInterface
|
|||
*/
|
||||
protected function garbageCollect()
|
||||
{
|
||||
foreach (Finder::create()->files()->name('*.json')->date('< ' . $this->gc_lifetime . ' hour ago')->in(
|
||||
$this->dirname
|
||||
) as $file) {
|
||||
foreach (
|
||||
Finder::create()->files()->name('*.json')->date('< ' . $this->gc_lifetime . ' hour ago')->in(
|
||||
$this->dirname
|
||||
) as $file
|
||||
) {
|
||||
$this->files->delete($file->getRealPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,5 +87,4 @@ class ClockworkCollector extends DataCollector implements DataCollectorInterface
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?php namespace Barryvdh\Debugbar\Support\Clockwork;
|
||||
<?php
|
||||
|
||||
class Converter {
|
||||
namespace Barryvdh\Debugbar\Support\Clockwork;
|
||||
|
||||
class Converter
|
||||
{
|
||||
|
||||
/**
|
||||
* Convert the phpdebugbar data to Clockwork format.
|
||||
|
@ -42,7 +45,7 @@ class Converter {
|
|||
$output['time'] = $time['start'];
|
||||
$output['responseTime'] = $time['end'];
|
||||
$output['responseDuration'] = $time['duration'] * 1000;
|
||||
foreach($time['measures'] as $measure) {
|
||||
foreach ($time['measures'] as $measure) {
|
||||
$output['timelineData'][] = [
|
||||
'data' => [],
|
||||
'description' => $measure['label'],
|
||||
|
@ -79,7 +82,7 @@ class Converter {
|
|||
}
|
||||
|
||||
if (isset($data['messages'])) {
|
||||
foreach($data['messages']['messages'] as $message) {
|
||||
foreach ($data['messages']['messages'] as $message) {
|
||||
$output['log'][] = [
|
||||
'message' => $message['message'],
|
||||
'time' => $message['time'],
|
||||
|
@ -90,7 +93,7 @@ class Converter {
|
|||
|
||||
if (isset($data['queries'])) {
|
||||
$queries = $data['queries'];
|
||||
foreach($queries['statements'] as $statement){
|
||||
foreach ($queries['statements'] as $statement) {
|
||||
if ($statement['type'] === 'explain') {
|
||||
continue;
|
||||
}
|
||||
|
@ -121,7 +124,7 @@ class Converter {
|
|||
}
|
||||
|
||||
if (isset($data['swiftmailer_mails'])) {
|
||||
foreach($data['swiftmailer_mails']['mails'] as $mail) {
|
||||
foreach ($data['swiftmailer_mails']['mails'] as $mail) {
|
||||
$output['emailsData'][] = [
|
||||
'data' => [
|
||||
'to' => $mail['to'],
|
||||
|
@ -134,5 +137,4 @@ class Converter {
|
|||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Twig_Environment;
|
||||
|
@ -44,7 +46,9 @@ class Debug extends Twig_Extension
|
|||
{
|
||||
return [
|
||||
new Twig_SimpleFunction(
|
||||
'debug', [$this, 'debug'], ['needs_context' => true, 'needs_environment' => true]
|
||||
'debug',
|
||||
[$this, 'debug'],
|
||||
['needs_context' => true, 'needs_environment' => true]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
use DebugBar\DataFormatter\DataFormatterInterface;
|
||||
use Twig_Environment;
|
||||
|
@ -40,7 +42,9 @@ class Dump extends Twig_Extension
|
|||
{
|
||||
return [
|
||||
new Twig_SimpleFunction(
|
||||
'dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]
|
||||
'dump',
|
||||
[$this, 'dump'],
|
||||
['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
@ -79,6 +83,6 @@ class Dump extends Twig_Extension
|
|||
}
|
||||
}
|
||||
|
||||
return '<pre>'.$output.'</pre>';
|
||||
return '<pre>' . $output . '</pre>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Extension;
|
||||
|
||||
use Barryvdh\Debugbar\Twig\TokenParser\StopwatchTokenParser;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Twig\Node;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\Node;
|
||||
|
||||
/**
|
||||
* Represents a stopwatch node. Based on Symfony\Bridge\Twig\Node\StopwatchNode
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Barryvdh\Debugbar\Twig\TokenParser;
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Twig\TokenParser;
|
||||
|
||||
use Barryvdh\Debugbar\Twig\Node\StopwatchNode;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ $routeConfig = [
|
|||
'middleware' => [\Barryvdh\Debugbar\Middleware\DebugbarEnabled::class],
|
||||
];
|
||||
|
||||
app('router')->group($routeConfig, function($router) {
|
||||
app('router')->group($routeConfig, function ($router) {
|
||||
$router->get('open', [
|
||||
'uses' => 'OpenHandlerController@handle',
|
||||
'as' => 'debugbar.openhandler',
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Barryvdh\Debugbar\Tests\DataCollector;
|
||||
|
||||
use Barryvdh\Debugbar\Tests\Models\Person;
|
||||
use Barryvdh\Debugbar\Tests\Models\User;
|
||||
use Barryvdh\Debugbar\Tests\TestCase;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
|
@ -11,8 +12,7 @@ class ModelsCollectorTest extends TestCase
|
|||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function it_collects_retrieved_models()
|
||||
public function testItCollectsRetrievedModels()
|
||||
{
|
||||
$this->loadLaravelMigrations();
|
||||
|
||||
|
@ -53,13 +53,3 @@ class ModelsCollectorTest extends TestCase
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = 'users';
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
||||
class Person extends User
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ class QueryCollectorTest extends TestCase
|
|||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function it_replaces_question_marks_bindings_correctly()
|
||||
public function testItReplacesQuestionMarksBindingsCorrectly()
|
||||
{
|
||||
$this->loadLaravelMigrations();
|
||||
|
||||
|
@ -31,7 +30,10 @@ class QueryCollectorTest extends TestCase
|
|||
|
||||
tap(Arr::first($collection['statements']), function (array $statement) {
|
||||
$this->assertEquals([3, '{4}'], $statement['bindings']);
|
||||
$this->assertEquals("SELECT ('[1, 2, 3]'::jsonb ? 3) as a, ('[4, 5, 6]'::jsonb ?| '{4}') as b, 'hello world ? example ??' as c", $statement['sql']);
|
||||
$this->assertEquals(<<<SQL
|
||||
SELECT ('[1, 2, 3]'::jsonb ? 3) as a, ('[4, 5, 6]'::jsonb ?| '{4}') as b, 'hello world ? example ??' as c
|
||||
SQL
|
||||
, $statement['sql']);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Tests\Models;
|
||||
|
||||
class Person extends User
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\Tests\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = 'users';
|
||||
protected $guarded = [];
|
||||
}
|
Loading…
Reference in New Issue