From 8eecd026c8f41d951449e8a4e5344588fcee6358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Ignacio=20Torres?= Date: Fri, 15 May 2026 22:29:36 -0700 Subject: [PATCH] chore: workspace improvements --- .githooks/pre-commit | 4 ++++ .gitignore | 2 ++ .vscode/extensions.json | 5 +++++ .vscode/settings.json | 7 +++++++ README.md | 20 +++++++++++++++++++ src/Application/Handlers/HttpErrorHandler.php | 6 +----- 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100755 .githooks/pre-commit create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..3488c61 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +composer phpcs diff --git a/.gitignore b/.gitignore index 865b8d2..b942f71 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .idea/ .vscode/ +!.vscdode/extensions.json +!.vscode/settings.json /coverage/ /vendor/ /logs/* diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..406a6ac --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "shevaua.phpcs" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..fb05d6f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "phpcs.enable": true, + "phpcs.executablePath": "vendor/bin/phpcs", + "phpcs.standard": "PSR12", + "phpcs.showWarnings": true, + "phpcs.autoFixOnSave": true +} diff --git a/README.md b/README.md index 46206a8..287e4ac 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,26 @@ Run this command in the application directory to run the test suite composer test ``` +To run PHPCS manually: + +```bash +composer phpcs +``` + +To auto-fix what PHPCBF can fix: + +```bash +composer phpcbf +``` + +To run PHPCS automatically in VS Code, install the recommended PHPCS extension from `.vscode/extensions.json` and use the workspace settings in `.vscode/settings.json`. + +To run PHPCS before every commit, enable the tracked Git hook with: + +```bash +git config core.hooksPath .githooks +``` + ## License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/src/Application/Handlers/HttpErrorHandler.php b/src/Application/Handlers/HttpErrorHandler.php index 64e02b1..2e4fe85 100644 --- a/src/Application/Handlers/HttpErrorHandler.php +++ b/src/Application/Handlers/HttpErrorHandler.php @@ -50,11 +50,7 @@ class HttpErrorHandler extends SlimErrorHandler } } - if ( - !($exception instanceof HttpException) - && $exception instanceof Throwable - && $this->displayErrorDetails - ) { + if (!($exception instanceof HttpException) && $this->displayErrorDetails) { $error->setDescription($exception->getMessage()); } -- 2.51.2