diff --git a/composer.json b/composer.json index 1672c141..3f6209bc 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ ], "stan-baseline": "phpstan.phar --generate-baseline", "psalm-baseline": "psalm.phar --set-baseline=psalm-baseline.xml", - "stan-setup": "cp composer.json composer.backup && composer require --dev symfony/polyfill-php81 phpstan/phpstan:~1.7.0 psalm/phar:~4.23.0 && mv composer.backup composer.json", + "stan-setup": "cp composer.json composer.backup && composer require --dev symfony/polyfill-php81 phpstan/phpstan:~1.9.0 psalm/phar:~5.1.0 && mv composer.backup composer.json", "test": "phpunit" }, "minimum-stability": "dev", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 289e0dbe..83e2555b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -19,3 +19,13 @@ parameters: message: "#^Call to an undefined method Cake\\\\ORM\\\\Locator\\\\LocatorInterface\\:\\:genericInstances\\(\\)\\.$#" count: 1 path: src/Panel/SqlLogPanel.php + + - + message: "#^Dead catch \\- Cake\\\\Core\\\\Exception\\\\CakeException is never thrown in the try block\\.$#" + count: 1 + path: src/ToolbarService.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: src/ToolbarService.php diff --git a/src/DebugSql.php b/src/DebugSql.php index 6b73996e..6a15569b 100644 --- a/src/DebugSql.php +++ b/src/DebugSql.php @@ -84,7 +84,7 @@ public static function sql( } /** @var array $trace */ - $trace = Debugger::trace(['start' => 1, 'depth' => $stackDepth + 2, 'format' => 'array']); + $trace = Debugger::trace(['start' => 0, 'depth' => $stackDepth + 1, 'format' => 'array']); $file = isset($trace[$stackDepth]) ? $trace[$stackDepth]['file'] : 'n/a'; $line = isset($trace[$stackDepth]) ? $trace[$stackDepth]['line'] : 0; $lineInfo = ''; diff --git a/src/Model/Table/PanelsTable.php b/src/Model/Table/PanelsTable.php index 402a0a19..3e167ef9 100644 --- a/src/Model/Table/PanelsTable.php +++ b/src/Model/Table/PanelsTable.php @@ -62,7 +62,7 @@ public function findByRequest(SelectQuery $query, array $options): SelectQuery } return $query->where(['Panels.request_id' => $options['requestId']]) - ->order(['Panels.title' => 'ASC']); + ->orderBy(['Panels.title' => 'ASC']); } /** diff --git a/src/Model/Table/RequestsTable.php b/src/Model/Table/RequestsTable.php index 5d610d9c..75cefc4a 100644 --- a/src/Model/Table/RequestsTable.php +++ b/src/Model/Table/RequestsTable.php @@ -75,7 +75,7 @@ public static function defaultConnectionName(): string */ public function findRecent(SelectQuery $query, array $options): SelectQuery { - return $query->order(['Requests.requested_at' => 'DESC']) + return $query->orderBy(['Requests.requested_at' => 'DESC']) ->limit(10); } @@ -108,7 +108,7 @@ public function gc(): void $noPurge = $this->find() ->select(['id']) ->enableHydration(false) - ->order(['requested_at' => 'desc']) + ->orderBy(['requested_at' => 'desc']) ->limit(Configure::read('DebugKit.requestCount') ?: 20) ->all() ->extract('id') diff --git a/src/ToolbarService.php b/src/ToolbarService.php index 071b0c68..cd9577ae 100644 --- a/src/ToolbarService.php +++ b/src/ToolbarService.php @@ -14,6 +14,7 @@ namespace DebugKit; use Cake\Core\Configure; +use Cake\Core\Exception\CakeException; use Cake\Core\InstanceConfigTrait; use Cake\Core\Plugin as CorePlugin; use Cake\Datasource\Exception\MissingDatasourceConfigException; @@ -25,7 +26,6 @@ use DebugKit\Model\Entity\Request; use DebugKit\Panel\PanelRegistry; use Exception; -use PDOException; use Psr\Http\Message\ResponseInterface; /** @@ -302,7 +302,7 @@ public function saveData(ServerRequest $request, ResponseInterface $response): R try { return $requests->save($row); - } catch (PDOException $e) { + } catch (CakeException $e) { Log::warning('Unable to save request. This is probably due to concurrent requests.'); Log::warning($e->getMessage()); } diff --git a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php index eb0fdca6..86c50839 100644 --- a/tests/TestCase/Middleware/DebugKitMiddlewareTest.php +++ b/tests/TestCase/Middleware/DebugKitMiddlewareTest.php @@ -109,7 +109,7 @@ public function testInvokeSaveData() $requests = $this->getTableLocator()->get('DebugKit.Requests'); $result = $requests->find() - ->order(['Requests.requested_at' => 'DESC']) + ->orderBy(['Requests.requested_at' => 'DESC']) ->contain('Panels') ->first(); diff --git a/tests/TestCase/View/Helper/ToolbarHelperTest.php b/tests/TestCase/View/Helper/ToolbarHelperTest.php index db66516a..19c73be9 100644 --- a/tests/TestCase/View/Helper/ToolbarHelperTest.php +++ b/tests/TestCase/View/Helper/ToolbarHelperTest.php @@ -69,7 +69,7 @@ public function tearDown(): void public function testDumpNodesSorted() { - $path = '//*[@class="cake-dbg-array-item"]/*[@class="cake-dbg-string"]'; + $path = '//*[@class="cake-debug-array-item"]/*[@class="cake-debug-string"]'; $data = ['z' => 1, 'a' => 99, 'm' => 123]; $nodes = array_map(function ($v) { return Debugger::exportVarAsNodes($v); @@ -104,7 +104,7 @@ public function testDumpCoerceHtml() public function testDumpSorted() { - $path = '//*[@class="cake-dbg-array-item"]/*[@class="cake-dbg-string"]'; + $path = '//*[@class="cake-debug-array-item"]/*[@class="cake-debug-string"]'; $data = ['z' => 1, 'a' => 99, 'm' => 123]; $result = $this->Toolbar->dump($data); $xml = new SimpleXmlElement($result);