diff --git a/.travis.yml b/.travis.yml index 22c4a68a1..e9af3075c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4snapshot env: - PHP_BIN=php @@ -69,6 +70,7 @@ jobs: allow_failures: - stage: Static Analysis (informative) - stage: Code Coverage + - php: 7.4snapshot sudo: false diff --git a/composer.json b/composer.json index 8168015da..eebbafc97 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,14 @@ "ext-json": "*" }, "require-dev": { - "nette/utils": "^2.4 || ^3.0", - "nette/di": "^2.4 || ~3.0.0", + "nette/utils": "^3.0", + "nette/di": "^3.0", "nette/tester": "^2.2", "psr/log": "^1.0" }, + "conflict": { + "nette/di": "<3.0" + }, "suggest": { "https://nette.org/donate": "Please support Tracy via a donation" }, @@ -35,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.7-dev" } } } diff --git a/readme.md b/readme.md index 9b1869783..242a192dc 100644 --- a/readme.md +++ b/readme.md @@ -42,6 +42,7 @@ Alternatively, you can download the whole package or [tracy.phar](https://github | Tracy | PHP | compatible with browsers |-----------|---------------|---------- +| Tracy 2.7 | PHP 7.1 – 7.3 | Chrome 49+, Firefox 45+, MS Edge 14+, Safari 10+ and iOS Safari 10.2+ | Tracy 2.6 | PHP 7.1 – 7.3 | Chrome 49+, Firefox 45+, MS Edge 14+, Safari 10+ and iOS Safari 10.2+ | Tracy 2.5 | PHP 5.4.4 – 7.3 | Chrome 49+, Firefox 45+, MS Edge 12+, Safari 10+ and iOS Safari 10.2+ | Tracy 2.4 | PHP 5.4.4 – 7.2 | Chrome 29+, Firefox 28+, IE 11+ (except AJAX), MS Edge 12+, Safari 9+ and iOS Safari 9.2+ diff --git a/src/Bridges/Nette/Bridge.php b/src/Bridges/Nette/Bridge.php index 0221cbe7c..d57d197b6 100644 --- a/src/Bridges/Nette/Bridge.php +++ b/src/Bridges/Nette/Bridge.php @@ -52,13 +52,13 @@ public static function renderLatteError(?\Throwable $e): ?array $lines = file($file); if (preg_match('#// source: (\S+\.latte)#', $lines[1], $m) && @is_file($m[1])) { // @ - may trigger error $templateFile = $m[1]; - $templateLine = preg_match('#/\* line (\d+) \*/#', $lines[$e->getLine() - 1], $m) ? (int) $m[1] : null; + $templateLine = $e->getLine() && preg_match('#/\* line (\d+) \*/#', $lines[$e->getLine() - 1], $m) ? (int) $m[1] : null; return [ 'tab' => 'Template', 'panel' => '

File: ' . Helpers::editorLink($templateFile, $templateLine) . '

' . ($templateLine === null ? '' - : '
' . BlueScreen::highlightFile($templateFile, $templateLine) . '
'), + : BlueScreen::highlightFile($templateFile, $templateLine)), ]; } } diff --git a/src/Bridges/Nette/TracyExtension.php b/src/Bridges/Nette/TracyExtension.php index 6b82df021..b2d9102fa 100644 --- a/src/Bridges/Nette/TracyExtension.php +++ b/src/Bridges/Nette/TracyExtension.php @@ -10,6 +10,7 @@ namespace Tracy\Bridges\Nette; use Nette; +use Nette\Schema\Expect; use Tracy; @@ -18,26 +19,6 @@ */ class TracyExtension extends Nette\DI\CompilerExtension { - public $defaults = [ - 'email' => null, - 'fromEmail' => null, - 'logSeverity' => null, - 'editor' => null, - 'browser' => null, - 'errorTemplate' => null, - 'strictMode' => null, - 'showBar' => null, - 'maxLen' => null, - 'maxLength' => null, - 'maxDepth' => null, - 'showLocation' => null, - 'scream' => null, - 'bar' => [], // of class name - 'blueScreen' => [], // of callback - 'editorMapping' => [], - 'netteMailer' => true, - ]; - /** @var bool */ private $debugMode; @@ -52,9 +33,31 @@ public function __construct(bool $debugMode = false, bool $cliMode = false) } + public function getConfigSchema(): Nette\Schema\Schema + { + return Expect::structure([ + 'email' => Expect::email()->dynamic(), + 'fromEmail' => Expect::email()->dynamic(), + 'logSeverity' => Expect::scalar(), + 'editor' => Expect::string()->dynamic(), + 'browser' => Expect::string()->dynamic(), + 'errorTemplate' => Expect::string()->dynamic(), + 'strictMode' => Expect::bool()->dynamic(), + 'showBar' => Expect::bool()->dynamic(), + 'maxLength' => Expect::int()->dynamic(), + 'maxDepth' => Expect::int()->dynamic(), + 'showLocation' => Expect::bool()->dynamic(), + 'scream' => Expect::bool()->dynamic(), + 'bar' => Expect::listOf('class|Nette\DI\Definitions\Statement'), + 'blueScreen' => Expect::listOf('callable'), + 'editorMapping' => Expect::arrayOf('string')->dynamic(), + 'netteMailer' => Expect::bool(true), + ]); + } + + public function loadConfiguration() { - $this->validateConfig($this->defaults); $builder = $this->getContainerBuilder(); $builder->addDefinition($this->prefix('logger')) @@ -74,7 +77,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) $initialize = $class->getMethod('initialize'); $builder = $this->getContainerBuilder(); - $options = $this->config; + $options = (array) $this->config; unset($options['bar'], $options['blueScreen'], $options['netteMailer']); if (isset($options['logSeverity'])) { $res = 0; @@ -94,17 +97,17 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) } $logger = $builder->getDefinition($this->prefix('logger')); - if ($logger->getFactory()->getEntity() !== [Tracy\Debugger::class, 'getLogger']) { + if (!$logger instanceof Nette\DI\ServiceDefinition || $logger->getFactory()->getEntity() !== [Tracy\Debugger::class, 'getLogger']) { $initialize->addBody($builder->formatPhp('Tracy\Debugger::setLogger(?);', [$logger])); } - if ($this->config['netteMailer'] && $builder->getByType(Nette\Mail\IMailer::class)) { + if ($this->config->netteMailer && $builder->getByType(Nette\Mail\IMailer::class)) { $initialize->addBody($builder->formatPhp('Tracy\Debugger::getLogger()->mailer = ?;', [ - [new Nette\DI\Statement(Tracy\Bridges\Nette\MailSender::class, ['fromEmail' => $this->config['fromEmail']]), 'send'], + [new Nette\DI\Statement(Tracy\Bridges\Nette\MailSender::class, ['fromEmail' => $this->config->fromEmail]), 'send'], ])); } if ($this->debugMode) { - foreach ((array) $this->config['bar'] as $item) { + foreach ($this->config->bar as $item) { if (is_string($item) && substr($item, 0, 1) === '@') { $item = new Nette\DI\Statement(['@' . $builder::THIS_CONTAINER, 'getService'], [substr($item, 1)]); } elseif (is_string($item)) { @@ -122,7 +125,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) } } - foreach ((array) $this->config['blueScreen'] as $item) { + foreach ($this->config->blueScreen as $item) { $initialize->addBody($builder->formatPhp( '$this->getService(?)->addPanel(?);', Nette\DI\Helpers::filterArguments([$this->prefix('blueScreen'), $item]) diff --git a/src/Tracy/Bar/Bar.php b/src/Tracy/Bar/Bar.php index e105a505c..db4d4d6a1 100644 --- a/src/Tracy/Bar/Bar.php +++ b/src/Tracy/Bar/Bar.php @@ -24,6 +24,8 @@ class Bar /** @var string|NULL generated by renderLoader() */ private $contentId; + /** @var array|string[] */ + private $ignorePanels = []; /** * Add custom panel. @@ -52,6 +54,16 @@ public function getPanel(string $id): ?IBarPanel /** + * @param string $panelId + * @return static + */ + public function ignorePanel(string $panelId) { + $this->ignorePanels[] = $panelId; + return $this; + } + + + /** * Renders loading