diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1b855cdb7..396244b28 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: 8.0 + php-version: 8.1 coverage: none - run: composer install --no-progress --prefer-dist diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71bbf0ccf..7f5a475e7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - php: ['8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['8.1', '8.2', '8.3', '8.4', '8.5'] sapi: ['php', 'php-cgi'] fail-fast: false @@ -41,7 +41,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: 8.0 + php-version: 8.1 extensions: ds coverage: none diff --git a/composer.json b/composer.json index 4d974c5e7..b1a1f38b3 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "8.0 - 8.4", + "php": "8.1 - 8.5", "ext-session": "*", "ext-json": "*" }, @@ -46,7 +46,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.10-dev" + "dev-master": "3.0-dev" } } } diff --git a/eslint.config.js b/eslint.config.js index 228a52673..13e699e08 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,40 +1,19 @@ -import globals from 'globals'; -import pluginJs from '@eslint/js'; -import stylistic from '@stylistic/eslint-plugin'; +import nette from '@nette/eslint-plugin'; +import { defineConfig } from 'eslint/config'; -export default [ +export default defineConfig([ { - ignores: ['*/', '!src/'], + ignores: [ + 'vendor', 'tests', 'x', + ], }, - pluginJs.configs.recommended, - - stylistic.configs.customize({ - indent: 'tab', - braceStyle: '1tbs', - arrowParens: true, - semi: true, - jsx: false, - }), - { - languageOptions: { - ecmaVersion: 'latest', - globals: globals.browser, - }, - plugins: { - '@stylistic': stylistic, - }, - rules: { - '@stylistic/no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], - '@stylistic/new-parens': ['error', 'never'], - '@stylistic/padded-blocks': 'off', - 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], - 'prefer-arrow-callback': 'error', - 'arrow-body-style': 'error', - 'eqeqeq': ['error', 'always', { null: 'ignore' }], - 'no-var': 'error', - 'prefer-const': 'off', - }, + files: [ + '*.js', + 'src/**/*.js', + ], + + extends: [nette.configs.recommended], }, -]; +]); diff --git a/package.json b/package.json index 0c8092127..038505b4b 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,11 @@ { "type": "module", "devDependencies": { - "@eslint/js": "^9.4.0", - "@stylistic/eslint-plugin": "^2.1.0", - "eslint": "^9.4.0", - "globals": "^15.3.0" + "@nette/eslint-plugin": "^0.2", + "eslint": "^9.26.0" }, "scripts": { - "lint": "eslint", - "lint:fix": "eslint --fix" + "lint": "eslint --cache", + "lint:fix": "eslint --cache --fix" } } diff --git a/readme.md b/readme.md index bacf2aee9..162dab103 100644 --- a/readme.md +++ b/readme.md @@ -48,7 +48,7 @@ composer require tracy/tracy Alternatively, you can download the whole package or [tracy.phar](https://github.com/nette/tracy/releases) file. -Tracy is compatible with PHP 8.0 to 8.4. +Tracy is compatible with PHP 8.1 to 8.5. @@ -456,5 +456,6 @@ This is a list of unofficial integrations to other frameworks and CMS: - [Slim Framework](https://github.com/runcmf/runtracy) - Symfony framework: [kutny/tracy-bundle](https://github.com/kutny/tracy-bundle), [VasekPurchart/Tracy-Blue-Screen-Bundle](https://github.com/VasekPurchart/Tracy-Blue-Screen-Bundle) - [Wordpress](https://github.com/ktstudio/WP-Tracy) +- [Joomla! CMS](https://n3t.bitbucket.io/extension/n3t-debug/) ... feel free to be famous, create an integration for your favourite platform! diff --git a/src/Bridges/Nette/Bridge.php b/src/Bridges/Nette/Bridge.php index b79624531..1f095716c 100644 --- a/src/Bridges/Nette/Bridge.php +++ b/src/Bridges/Nette/Bridge.php @@ -9,95 +9,26 @@ namespace Tracy\Bridges\Nette; -use Latte; use Nette; use Tracy; use Tracy\BlueScreen; use Tracy\Helpers; +use const ENT_IGNORE; /** - * Bridge for NEON & Latte. + * Bridge for Utils & NEON. */ class Bridge { public static function initialize(): void { $blueScreen = Tracy\Debugger::getBlueScreen(); - if (!class_exists(Latte\Bridges\Tracy\BlueScreenPanel::class)) { - $blueScreen->addPanel([self::class, 'renderLatteError']); - $blueScreen->addAction([self::class, 'renderLatteUnknownMacro']); - $blueScreen->addFileGenerator(fn(string $file) => substr($file, -6) === '.latte' - ? "{block content}\n\$END\$" - : null); - Tracy\Debugger::addSourceMapper([self::class, 'mapLatteSourceCode']); - } - $blueScreen->addAction([self::class, 'renderMemberAccessException']); $blueScreen->addPanel([self::class, 'renderNeonError']); } - public static function renderLatteError(?\Throwable $e): ?array - { - if ($e instanceof Latte\CompileException && $e->sourceName) { - return [ - 'tab' => 'Template', - 'panel' => (preg_match('#\n|\?#', $e->sourceName) - ? '' - : '
' - . (@is_file($e->sourceName) // @ - may trigger error - ? 'File: ' . Helpers::editorLink($e->sourceName, $e->sourceLine) - : '' . htmlspecialchars($e->sourceName . ($e->sourceLine ? ':' . $e->sourceLine : '')) . '') - . '
') - . BlueScreen::highlightFile($e->sourceCode, $e->sourceLine, php: false), - ]; - } - - return null; - } - - - public static function renderLatteUnknownMacro(?\Throwable $e): ?array - { - if ( - $e instanceof Latte\CompileException - && $e->sourceName - && @is_file($e->sourceName) // @ - may trigger error - && (preg_match('#Unknown macro (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m) - || preg_match('#Unknown attribute (n:\w+), did you mean (n:\w+)\?#A', $e->getMessage(), $m)) - ) { - return [ - 'link' => Helpers::editorUri($e->sourceName, $e->sourceLine, 'fix', $m[1], $m[2]), - 'label' => 'fix it', - ]; - } - - return null; - } - - - /** @return array{file: string, line: int, label: string, active: bool} */ - public static function mapLatteSourceCode(string $file, int $line): ?array - { - if (!strpos($file, '.latte--')) { - return null; - } - - $lines = file($file); - if ( - !preg_match('#^/(?:\*\*|/) source: (\S+\.latte)#m', implode('', array_slice($lines, 0, 10)), $m) - || !@is_file($m[1]) // @ - may trigger error - ) { - return null; - } - - $file = $m[1]; - $line = $line && preg_match('#/\* line (\d+) \*/#', $lines[$line - 1], $m) ? (int) $m[1] : 0; - return ['file' => $file, 'line' => $line, 'label' => 'Latte', 'active' => true]; - } - - public static function renderMemberAccessException(?\Throwable $e): ?array { if (!$e instanceof Nette\MemberAccessException && !$e instanceof \LogicException) { diff --git a/src/Bridges/Nette/TracyExtension.php b/src/Bridges/Nette/TracyExtension.php index 3f0c6ac2b..e1ba09527 100644 --- a/src/Bridges/Nette/TracyExtension.php +++ b/src/Bridges/Nette/TracyExtension.php @@ -13,6 +13,7 @@ use Nette\DI\Definitions\Statement; use Nette\Schema\Expect; use Tracy; +use function is_array, is_string; /** @@ -130,7 +131,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void if ($this->debugMode) { foreach ($this->config->bar as $item) { if (is_string($item) && substr($item, 0, 1) === '@') { - $item = new Statement(['@' . $builder::THIS_CONTAINER, 'getService'], [substr($item, 1)]); + $item = new Statement(['@' . $builder::ThisContainer, 'getService'], [substr($item, 1)]); } elseif (is_string($item)) { $item = new Statement($item); } diff --git a/src/Bridges/Psr/PsrToTracyLoggerAdapter.php b/src/Bridges/Psr/PsrToTracyLoggerAdapter.php index 5d8b0430b..8bf66781a 100644 --- a/src/Bridges/Psr/PsrToTracyLoggerAdapter.php +++ b/src/Bridges/Psr/PsrToTracyLoggerAdapter.php @@ -11,6 +11,7 @@ use Psr; use Tracy; +use function is_string; /** diff --git a/src/Tracy/Bar/Bar.php b/src/Tracy/Bar/Bar.php index 00d85b5c4..ddc3a47a8 100644 --- a/src/Tracy/Bar/Bar.php +++ b/src/Tracy/Bar/Bar.php @@ -9,6 +9,8 @@ namespace Tracy; +use function count; + /** * Debug Bar. diff --git a/src/Tracy/Bar/assets/bar.js b/src/Tracy/Bar/assets/bar.js index 403757350..56f237958 100644 --- a/src/Tracy/Bar/assets/bar.js +++ b/src/Tracy/Bar/assets/bar.js @@ -157,9 +157,9 @@ class Panel { let meta = this.elem.parentElement.lastElementChild; doc.body.innerHTML = 'We're sorry! The server encountered an internal error and - was unable to complete your request. Please try again later.
+We're sorry! The server encountered an internal error and + was unable to complete your request. Please try again later.
-error 500 |
Tracy is unable to log error.
error 500 |
Tracy is unable to log error.
Exception #123
+ +File: %a%Debugger.exception.in-generator.html.phpt:%d%
++%d%: +%d%: +%d%: Debugger::$productionMode = false; +%d%: setHtmlMode(); +%d%: +%d%: Debugger::enable(); +%d%: +%d%: +%d%: $generator = (function (): iterable { +%d%: yield 5; +%d%: throw new Exception('The my exception', 123); +%d%: })(); +%d%: $fn = function ($generator) { +%d%: foreach ($generator as $value) { +%d%: } +
+ +%d%: setHtmlMode(); +%d%: +%d%: Debugger::enable(); +%d%: +%d%: +%d%: $generator = (function (): iterable { +%d%: yield 5; +%d%: throw new Exception('The my exception', 123); +%d%: })(); +%d%: $fn = function ($generator) { +%d%: foreach ($generator as $value) { +%d%: } +%d%: }; +%d%: +%d%: $fn($generator); +
+ +%d%: +%d%: $generator = (function (): iterable { +%d%: yield 5; +%d%: throw new Exception('The my exception', 123); +%d%: })(); +%d%: $fn = function ($generator) { +%d%: foreach ($generator as $value) { +%d%: } +%d%: }; +%d%: +%d%: $fn($generator); +
| #0 | + |
|---|