diff --git a/bin/gpm b/bin/gpm
index d4932a20e..e8eff5a00 100755
--- a/bin/gpm
+++ b/bin/gpm
@@ -1,6 +1,7 @@
#!/usr/bin/env php
$autoload));
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
diff --git a/bin/plugin b/bin/plugin
index a8b089a89..a219655b6 100755
--- a/bin/plugin
+++ b/bin/plugin
@@ -1,6 +1,7 @@
#!/usr/bin/env php
getFormatter()->setStyle('white', new OutputFormatterStyle('white', nul
if (!$name) {
$output->writeln('');
- $output->writeln("Usage:");
+ $output->writeln('Usage:');
$output->writeln(" {$bin} [slug] [command] [arguments]");
$output->writeln('');
- $output->writeln("Example:");
+ $output->writeln('Example:');
$output->writeln(" {$bin} error log -l 1 --trace");
$list = Folder::all('plugins://', ['compare' => 'Pathname', 'pattern' => '/\/cli\/' . $pattern . '$/usm', 'levels' => 2]);
@@ -104,7 +105,7 @@ if (!$name) {
}
$available[] = $entry;
- $output->writeln(' ' . $index . ". " . str_pad($entry, 15) . " ${bin} ${entry} list");
+ $output->writeln(' ' . $index . '. ' . str_pad($entry, 15) . " ${bin} ${entry} list");
}
}
diff --git a/index.php b/index.php
index 4a9c64984..64154df89 100644
--- a/index.php
+++ b/index.php
@@ -9,6 +9,7 @@
namespace Grav;
+\define('GRAV_REQUEST_TIME', microtime(true));
\define('GRAV_PHP_MIN', '7.1.3');
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
diff --git a/system/src/Grav/Common/Composer.php b/system/src/Grav/Common/Composer.php
index 26719252c..65c994564 100644
--- a/system/src/Grav/Common/Composer.php
+++ b/system/src/Grav/Common/Composer.php
@@ -11,7 +11,7 @@ namespace Grav\Common;
class Composer
{
/** @const Default composer location */
- const DEFAULT_PATH = "bin/composer.phar";
+ const DEFAULT_PATH = 'bin/composer.phar';
/**
* Returns the location of composer.
@@ -20,12 +20,12 @@ class Composer
*/
public static function getComposerLocation()
{
- if (!function_exists('shell_exec') || strtolower(substr(PHP_OS, 0, 3)) === 'win') {
+ if (!\function_exists('shell_exec') || stripos(PHP_OS, 'win') === 0) {
return self::DEFAULT_PATH;
}
// check for global composer install
- $path = trim(shell_exec("command -v composer"));
+ $path = trim(shell_exec('command -v composer'));
// fall back to grav bundled composer
if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) {
diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php
index 8fee09fa7..50c77bbe4 100644
--- a/system/src/Grav/Common/Debugger.php
+++ b/system/src/Grav/Common/Debugger.php
@@ -9,7 +9,13 @@
namespace Grav\Common;
use DebugBar\DataCollector\ConfigCollector;
+use DebugBar\DataCollector\ExceptionsCollector;
+use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\MessagesCollector;
+use DebugBar\DataCollector\PhpInfoCollector;
+use DebugBar\DataCollector\RequestDataCollector;
+use DebugBar\DataCollector\TimeDataCollector;
+use DebugBar\DebugBar;
use DebugBar\JavascriptRenderer;
use DebugBar\StandardDebugBar;
use Grav\Common\Config\Config;
@@ -28,13 +34,16 @@ class Debugger
/** @var StandardDebugBar $debugbar */
protected $debugbar;
+ /** @var bool */
protected $enabled;
+ /** @var array */
protected $timers = [];
/** @var string[] $deprecations */
protected $deprecations = [];
+ /** @var callable */
protected $errorHandler;
/**
@@ -42,11 +51,26 @@ class Debugger
*/
public function __construct()
{
+ $currentTime = microtime(true);
+
+ if (!\defined('GRAV_REQUEST_TIME')) {
+ \define('GRAV_REQUEST_TIME', $currentTime);
+ }
+
// Enable debugger until $this->init() gets called.
$this->enabled = true;
- $this->debugbar = new StandardDebugBar();
- $this->debugbar['time']->addMeasure('Loading', $this->debugbar['time']->getRequestStartTime(), microtime(true));
+ $debugbar = new DebugBar();
+ $debugbar->addCollector(new PhpInfoCollector());
+ $debugbar->addCollector(new MessagesCollector());
+ $debugbar->addCollector(new RequestDataCollector());
+ $debugbar->addCollector(new TimeDataCollector($_SERVER['REQUEST_TIME_FLOAT'] ?? GRAV_REQUEST_TIME));
+
+ $debugbar['time']->addMeasure('Server', $debugbar['time']->getRequestStartTime(), GRAV_REQUEST_TIME);
+ $debugbar['time']->addMeasure('Loading', GRAV_REQUEST_TIME, $currentTime);
+ $debugbar['time']->addMeasure('Debugger', $currentTime, microtime(true));
+
+ $this->debugbar = $debugbar;
// Set deprecation collector.
$this->setErrorHandler();
@@ -72,9 +96,11 @@ class Debugger
ksort($plugins_config);
-
- $this->debugbar->addCollector(new ConfigCollector((array)$this->config->get('system'), 'Config'));
- $this->debugbar->addCollector(new ConfigCollector($plugins_config, 'Plugins'));
+ $debugbar = $this->debugbar;
+ $debugbar->addCollector(new MemoryCollector());
+ $debugbar->addCollector(new ExceptionsCollector());
+ $debugbar->addCollector(new ConfigCollector((array)$this->config->get('system'), 'Config'));
+ $debugbar->addCollector(new ConfigCollector($plugins_config, 'Plugins'));
$this->addMessage('Grav v' . GRAV_VERSION);
}
@@ -229,7 +255,7 @@ class Debugger
/**
* Start a timer with an associated name and description
*
- * @param $name
+ * @param string $name
* @param string|null $description
*
* @return $this
@@ -253,7 +279,7 @@ class Debugger
*/
public function stopTimer($name)
{
- if (in_array($name, $this->timers, true) && ($name[0] === '_' || $this->enabled())) {
+ if (\in_array($name, $this->timers, true) && ($name[0] === '_' || $this->enabled())) {
$this->debugbar['time']->stopMeasure($name);
}
@@ -411,8 +437,8 @@ class Debugger
$trace = [];
foreach ($deprecated['trace'] as $current) {
- $class = isset($current['class']) ? $current['class'] : '';
- $type = isset($current['type']) ? $current['type'] : '';
+ $class = $current['class'] ?? '';
+ $type = $current['type'] ?? '';
$function = $this->getFunction($current);
if (isset($current['file'])) {
$current['file'] = str_replace(GRAV_ROOT . '/', '', $current['file']);