From 5c5dc8c0c280a2c042b8a2688c2d14927bf4ad3b Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sat, 31 Oct 2026 22:03:12 +0100 Subject: [PATCH 1/8] devops: move dresscode's config beside vendor, at the root its type rules found nothing and passed --- .claude/skills/adminer-plugin/SKILL.md | 2 +- CLAUDE.md | 6 +++++- Makefile | 9 ++++++--- app/AdminerDesktop.php | 1 + dresscode.neon => app/dresscode.neon | 25 ++++++++++++++++++------- app/src/Latte.php | 1 + cli/dresscode-hook.php | 6 +++++- 7 files changed, 37 insertions(+), 13 deletions(-) rename dresscode.neon => app/dresscode.neon (61%) diff --git a/.claude/skills/adminer-plugin/SKILL.md b/.claude/skills/adminer-plugin/SKILL.md index 791adad4..25bcbc21 100644 --- a/.claude/skills/adminer-plugin/SKILL.md +++ b/.claude/skills/adminer-plugin/SKILL.md @@ -170,7 +170,7 @@ your output and `exit` — this is how `sql-gemini.php` answers its own AJAX POS Our own code is PSR-4 `Desktop\` under `app/src/`, native types on properties, `[]` not `array()`, enums over magic strings. The downloaded catalogue in `available/` is -**excluded** from phpstan and dresscode (`phpstan.neon`, `dresscode.neon`) — so upstream's +**excluded** from phpstan and dresscode (`phpstan.neon`, `app/dresscode.neon`) — so upstream's untyped style there is not a signal for code you write. A hook overriding an untyped adminer method keeps adminer's shape (phpdoc `@param`/`@return`, or a `// dresscode:ignore`), because PHP forbids narrowing an inherited signature. diff --git a/CLAUDE.md b/CLAUDE.md index b3d9ba99..cd1e25fb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -131,6 +131,10 @@ in the packaged app (where `app/` is the document root and there is no root abov `composer.json`/`composer.lock` moved there too; run composer with `--working-dir=app`, as the `app/vendor` target does. We do not vendor Go deps. +**`dresscode.neon` stays in `app/`, beside `vendor/`.** Anywhere else DressCode takes `app/` for +foreign code, and a rule that needs types finds nothing there and exits 0. The cost is that `cli/` +lies outside its root, so the Makefile names those files and the hook drops `--skip-excluded` for them. + **Our code is PSR-4 under `src/`.** `app/composer.json` maps `"Desktop\\": "src/"`, so a `Desktop\` class loads from the matching path — `Desktop\Settings\Theme\Theme` → `src/Settings/Theme/Theme.php`, filename and case matching the class. The case match is not @@ -275,7 +279,7 @@ type on every property (`private ?string $file`, not a bare `private $file` on a stays only for what the native type can't say — an array's shape), `[]` not `array()`, and an enum for a fixed set of values (`Desktop\Mode` for the light/dark scheme) rather than a magic string. `make qa` enforces these: phpstan at level 6 for parameter, return and value types, -and dresscode (`dresscode.neon`) for what phpstan does not judge — native +and dresscode (`app/dresscode.neon`) for what phpstan does not judge — native property and constant declarations, short array syntax, tabs, `strict_types`. Both run through the bundled frankenphp, no separate PHP install. The exceptions are adminer's own downloaded files (excluded) and a method or property that overrides an untyped one in adminer's base class — those keep diff --git a/Makefile b/Makefile index 670bc502..908cb459 100644 --- a/Makefile +++ b/Makefile @@ -229,11 +229,13 @@ phpstan: fetch app/vendor $(PHPSTAN_INI)/phpstan.ini PHP_INI_SCAN_DIR=$(PHPSTAN_INI) ./bin/frankenphp$(EXE) php-cli app/vendor/phpstan/phpstan/phpstan.phar analyse -c phpstan.neon \ --no-progress --debug --memory-limit=2G -# The conventions phpstan does not judge, listed in dresscode.neon, which also excludes adminer's +# The conventions phpstan does not judge, listed in app/dresscode.neon, which also excludes adminer's # own downloaded files. --jobs 1 because its workers start through PHP_BINARY, and under # frankenphp's php-cli that is frankenphp itself, which takes `check` for a command of its own. -dresscode: app/vendor - ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 +# fetch because typeAnalysis reads phpstan.neon, and without the files it names only warns. +# cli/ file by file: a directory outside the config's root is dropped without a word, a file is not. +dresscode: fetch app/vendor + ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(wildcard cli/*.php) # What .claude/settings.json runs after an agent's edit, the edit's JSON on stdin. Silent and with no # prerequisites: what it prints goes to the agent, and an edit must not start a composer install. @@ -585,6 +587,7 @@ DIST = build.noindex/pkg/adminer-desktop define package-app rm -rf $(1)/cli $(COMPOSER) install --no-dev --no-interaction --working-dir=$(1) + rm -f $(1)/dresscode.neon $(if $(EXE),,./bin/frankenphp php-cli cli/latte-precompile.php $(1)) endef diff --git a/app/AdminerDesktop.php b/app/AdminerDesktop.php index f75c4bc3..9ac334a7 100644 --- a/app/AdminerDesktop.php +++ b/app/AdminerDesktop.php @@ -116,6 +116,7 @@ function t(string $idf): string { * the language files with every other string rather than as a special case. * @return string */ + #[Override] function description(): string { return $this->t('plugin.description'); } diff --git a/dresscode.neon b/app/dresscode.neon similarity index 61% rename from dresscode.neon rename to app/dresscode.neon index 72e94857..7d2c5002 100644 --- a/dresscode.neon +++ b/app/dresscode.neon @@ -2,17 +2,23 @@ # follows adminer's, and only what is decided here gets reported. # https://dresscode.run/ +# ../cli only gives the type rules its files: a directory outside this root is not walked, so the +# Makefile names them. paths: - - app - - cli + - . + - ../cli + +# Beside vendor/ on purpose: from anywhere else DressCode takes app/, its own installation, for +# foreign code, and the rules that need types find nothing there and still exit 0. +typeAnalysis: phpstan # Everything that ships verbatim from the adminer release keeps its own conventions. excludePaths: - - app/vendor - - app/adminer.php - - app/editor.php - - app/src/Settings/Plugins/available - - app/src/Settings/Theme/designs + - vendor + - adminer.php + - editor.php + - src/Settings/Plugins/available + - src/Settings/Theme/designs # composer.json names no PHP version; this is frankenphp's, the one the app runs on. targets: @@ -39,3 +45,8 @@ types: declaration: property: required constant: required + +# PHP then refuses a parent renaming a member under us, instead of leaving a silent new one. +upgrading: + classes: + Override: required diff --git a/app/src/Latte.php b/app/src/Latte.php index 021c05a0..28fd6157 100644 --- a/app/src/Latte.php +++ b/app/src/Latte.php @@ -23,6 +23,7 @@ static function engine(): Engine { // differs on every machine, so a cache compiled by the build would never be found; // relative to app/ it is the same wherever the app was unpacked. $latte->setLoader(new class extends FileLoader { + #[\Override] function getUniqueId(string $file): string { return str_replace(dirname(__DIR__), "", $file); } diff --git a/cli/dresscode-hook.php b/cli/dresscode-hook.php index da3c75ab..42e2637e 100644 --- a/cli/dresscode-hook.php +++ b/cli/dresscode-hook.php @@ -16,7 +16,11 @@ } $root = dirname(__DIR__); -$command = [PHP_BINARY, "php-cli", $root . "/app/vendor/bin/dresscode", "fix", $file, "--format", "agent", "--no-color", "--skip-excluded", "--jobs", "1"]; +$command = [PHP_BINARY, "php-cli", $root . "/app/vendor/bin/dresscode", "fix", $file, "-c", $root . "/app/dresscode.neon", "--format", "agent", "--no-color", "--jobs", "1"]; +// cli/ lies outside the config's root, so --skip-excluded would leave every file there unchecked. +if (dirname($file) !== $root . "/cli") { + $command[] = "--skip-excluded"; +} $original = $input["tool_response"]["originalFile"] ?? null; $before = is_string($original) ? tempnam(sys_get_temp_dir(), "dresscode-before-") : false; if ($before !== false && file_put_contents($before, $original) !== false) { From 98eb1d353b640ae0cfdf3bb2ac3f8ec59d5f9de5 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sat, 31 Oct 2026 23:19:55 +0100 Subject: [PATCH 2/8] devops: fail make dresscode when its type rules go silent, a clean run looks the same --- CLAUDE.md | 1 + Makefile | 4 +++- app/dresscode-canary.php | 16 ++++++++++++++++ app/dresscode.neon | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/dresscode-canary.php diff --git a/CLAUDE.md b/CLAUDE.md index cd1e25fb..7d5180b8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -134,6 +134,7 @@ in the packaged app (where `app/` is the document root and there is no root abov **`dresscode.neon` stays in `app/`, beside `vendor/`.** Anywhere else DressCode takes `app/` for foreign code, and a rule that needs types finds nothing there and exits 0. The cost is that `cli/` lies outside its root, so the Makefile names those files and the hook drops `--skip-excluded` for them. +`make dresscode` fails unless it reports `app/dresscode-canary.php`, which breaks a type rule on purpose. **Our code is PSR-4 under `src/`.** `app/composer.json` maps `"Desktop\\": "src/"`, so a `Desktop\` class loads from the matching path — `Desktop\Settings\Theme\Theme` → diff --git a/Makefile b/Makefile index 908cb459..e97f19a7 100644 --- a/Makefile +++ b/Makefile @@ -234,8 +234,10 @@ phpstan: fetch app/vendor $(PHPSTAN_INI)/phpstan.ini # frankenphp's php-cli that is frankenphp itself, which takes `check` for a command of its own. # fetch because typeAnalysis reads phpstan.neon, and without the files it names only warns. # cli/ file by file: a directory outside the config's root is dropped without a word, a file is not. +# The canary is excluded, so only naming it checks it: a clean run cannot tell type rules from silence. dresscode: fetch app/vendor ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(wildcard cli/*.php) + @./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app/dresscode-canary.php | grep -q upgrading.classes.Override || { echo "dresscode's type rules went silent: app/dresscode-canary.php was not reported"; exit 1; } # What .claude/settings.json runs after an agent's edit, the edit's JSON on stdin. Silent and with no # prerequisites: what it prints goes to the agent, and an edit must not start a composer install. @@ -587,7 +589,7 @@ DIST = build.noindex/pkg/adminer-desktop define package-app rm -rf $(1)/cli $(COMPOSER) install --no-dev --no-interaction --working-dir=$(1) - rm -f $(1)/dresscode.neon + rm -f $(1)/dresscode.neon $(1)/dresscode-canary.php $(if $(EXE),,./bin/frankenphp php-cli cli/latte-precompile.php $(1)) endef diff --git a/app/dresscode-canary.php b/app/dresscode-canary.php new file mode 100644 index 00000000..c6fba90a --- /dev/null +++ b/app/dresscode-canary.php @@ -0,0 +1,16 @@ + Date: Sat, 31 Oct 2026 23:19:55 +0100 Subject: [PATCH 3/8] devops: check php in cli subfolders too, one would have been skipped without a word --- Makefile | 2 +- cli/dresscode-hook.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e97f19a7..9a3d0501 100644 --- a/Makefile +++ b/Makefile @@ -236,7 +236,7 @@ phpstan: fetch app/vendor $(PHPSTAN_INI)/phpstan.ini # cli/ file by file: a directory outside the config's root is dropped without a word, a file is not. # The canary is excluded, so only naming it checks it: a clean run cannot tell type rules from silence. dresscode: fetch app/vendor - ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(wildcard cli/*.php) + ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(shell find cli -name '*.php') @./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app/dresscode-canary.php | grep -q upgrading.classes.Override || { echo "dresscode's type rules went silent: app/dresscode-canary.php was not reported"; exit 1; } # What .claude/settings.json runs after an agent's edit, the edit's JSON on stdin. Silent and with no diff --git a/cli/dresscode-hook.php b/cli/dresscode-hook.php index 42e2637e..b909ea22 100644 --- a/cli/dresscode-hook.php +++ b/cli/dresscode-hook.php @@ -18,7 +18,7 @@ $root = dirname(__DIR__); $command = [PHP_BINARY, "php-cli", $root . "/app/vendor/bin/dresscode", "fix", $file, "-c", $root . "/app/dresscode.neon", "--format", "agent", "--no-color", "--jobs", "1"]; // cli/ lies outside the config's root, so --skip-excluded would leave every file there unchecked. -if (dirname($file) !== $root . "/cli") { +if (!str_starts_with($file, $root . "/cli/")) { $command[] = "--skip-excluded"; } $original = $input["tool_response"]["originalFile"] ?? null; From 00b74d3a4b6929837d761e31bdff0c6d2f4fd935 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sat, 31 Oct 2026 23:19:55 +0100 Subject: [PATCH 4/8] devops: run the dresscode hook with the worktree's own install, it skipped those files and exited 0 --- cli/dresscode-hook.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/dresscode-hook.php b/cli/dresscode-hook.php index b909ea22..469f88e9 100644 --- a/cli/dresscode-hook.php +++ b/cli/dresscode-hook.php @@ -15,7 +15,12 @@ exit(0); } -$root = dirname(__DIR__); +// The hook runs from the session's checkout, but an edit in a worktree belongs to that worktree's +// config and dresscode: an installation outside the config's root finds nothing, and exits 0. +$root = preg_match('~^(.*/\.claude/worktrees/[^/]+)/~', $file, $match) === 1 ? $match[1] : dirname(__DIR__); +if (!is_file($root . "/app/vendor/bin/dresscode")) { + exit(0); +} $command = [PHP_BINARY, "php-cli", $root . "/app/vendor/bin/dresscode", "fix", $file, "-c", $root . "/app/dresscode.neon", "--format", "agent", "--no-color", "--jobs", "1"]; // cli/ lies outside the config's root, so --skip-excluded would leave every file there unchecked. if (!str_starts_with($file, $root . "/cli/")) { From 7cf86b56219c2a432e419e369aa5adc1d5be49ea Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sat, 31 Oct 2026 23:58:43 +0100 Subject: [PATCH 5/8] devops: keep the deliberately bad dresscode file in tests, it had no business in the document root --- CLAUDE.md | 2 +- Makefile | 9 ++++++--- app/dresscode-canary.php | 16 ---------------- app/dresscode.neon | 1 - tests/dresscode/override-missing.php | 15 +++++++++++++++ 5 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 app/dresscode-canary.php create mode 100644 tests/dresscode/override-missing.php diff --git a/CLAUDE.md b/CLAUDE.md index 7d5180b8..15e57b4d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -134,7 +134,7 @@ in the packaged app (where `app/` is the document root and there is no root abov **`dresscode.neon` stays in `app/`, beside `vendor/`.** Anywhere else DressCode takes `app/` for foreign code, and a rule that needs types finds nothing there and exits 0. The cost is that `cli/` lies outside its root, so the Makefile names those files and the hook drops `--skip-excluded` for them. -`make dresscode` fails unless it reports `app/dresscode-canary.php`, which breaks a type rule on purpose. +`make dresscode` fails unless it reports `tests/dresscode/override-missing.php`, copied into `app/` for that run, which breaks a type rule on purpose. **Our code is PSR-4 under `src/`.** `app/composer.json` maps `"Desktop\\": "src/"`, so a `Desktop\` class loads from the matching path — `Desktop\Settings\Theme\Theme` → diff --git a/Makefile b/Makefile index 9a3d0501..12d2d384 100644 --- a/Makefile +++ b/Makefile @@ -234,10 +234,13 @@ phpstan: fetch app/vendor $(PHPSTAN_INI)/phpstan.ini # frankenphp's php-cli that is frankenphp itself, which takes `check` for a command of its own. # fetch because typeAnalysis reads phpstan.neon, and without the files it names only warns. # cli/ file by file: a directory outside the config's root is dropped without a word, a file is not. -# The canary is excluded, so only naming it checks it: a clean run cannot tell type rules from silence. +# The bad file is copied in for one run, because only under app/ does it go silent with the rest: a clean +# run cannot tell type rules from silence. dresscode: fetch app/vendor ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(shell find cli -name '*.php') - @./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app/dresscode-canary.php | grep -q upgrading.classes.Override || { echo "dresscode's type rules went silent: app/dresscode-canary.php was not reported"; exit 1; } + @cp tests/dresscode/override-missing.php app/override-missing.php; \ + ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app/override-missing.php | grep -q upgrading.classes.Override; found=$$?; \ + rm -f app/override-missing.php; test $$found = 0 || { echo "dresscode's type rules went silent: tests/dresscode/override-missing.php was not reported"; exit 1; } # What .claude/settings.json runs after an agent's edit, the edit's JSON on stdin. Silent and with no # prerequisites: what it prints goes to the agent, and an edit must not start a composer install. @@ -589,7 +592,7 @@ DIST = build.noindex/pkg/adminer-desktop define package-app rm -rf $(1)/cli $(COMPOSER) install --no-dev --no-interaction --working-dir=$(1) - rm -f $(1)/dresscode.neon $(1)/dresscode-canary.php + rm -f $(1)/dresscode.neon $(if $(EXE),,./bin/frankenphp php-cli cli/latte-precompile.php $(1)) endef diff --git a/app/dresscode-canary.php b/app/dresscode-canary.php deleted file mode 100644 index c6fba90a..00000000 --- a/app/dresscode-canary.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Sun, 1 Nov 2026 00:17:57 +0100 Subject: [PATCH 6/8] devops: give dresscode's type rules phpstan.neon and check cli too, they ran without it and a dropped file passed --- CLAUDE.md | 9 ++++-- Makefile | 15 ++++------ app/dresscode.neon | 4 +-- app/phpstan.neon | 3 ++ cli/dresscode.sh | 41 +++++++++++++++++++++++++ tests/cli/dresscode-test.sh | 60 +++++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 app/phpstan.neon create mode 100755 cli/dresscode.sh create mode 100755 tests/cli/dresscode-test.sh diff --git a/CLAUDE.md b/CLAUDE.md index 15e57b4d..f9b4f7ef 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -132,9 +132,12 @@ in the packaged app (where `app/` is the document root and there is no root abov `--working-dir=app`, as the `app/vendor` target does. We do not vendor Go deps. **`dresscode.neon` stays in `app/`, beside `vendor/`.** Anywhere else DressCode takes `app/` for -foreign code, and a rule that needs types finds nothing there and exits 0. The cost is that `cli/` -lies outside its root, so the Makefile names those files and the hook drops `--skip-excluded` for them. -`make dresscode` fails unless it reports `tests/dresscode/override-missing.php`, copied into `app/` for that run, which breaks a type rule on purpose. +foreign code, and a rule that needs types finds nothing there and exits 0. Its type rules read +`phpstan.neon` from that root too, hence `app/phpstan.neon`, which includes the real one. `cli/` lies +outside the root, so `cli/dresscode.sh` names those files and the hook drops `--skip-excluded` for them; +run dresscode through `make dresscode`, because `check -c app/dresscode.neon` alone skips `cli/` and +says OK. That script fails unless `tests/dresscode/override-missing.php`, copied into `app/` and `cli/` +for one run, is reported from both. **Our code is PSR-4 under `src/`.** `app/composer.json` maps `"Desktop\\": "src/"`, so a `Desktop\` class loads from the matching path — `Desktop\Settings\Theme\Theme` → diff --git a/Makefile b/Makefile index 12d2d384..bda6531d 100644 --- a/Makefile +++ b/Makefile @@ -233,14 +233,8 @@ phpstan: fetch app/vendor $(PHPSTAN_INI)/phpstan.ini # own downloaded files. --jobs 1 because its workers start through PHP_BINARY, and under # frankenphp's php-cli that is frankenphp itself, which takes `check` for a command of its own. # fetch because typeAnalysis reads phpstan.neon, and without the files it names only warns. -# cli/ file by file: a directory outside the config's root is dropped without a word, a file is not. -# The bad file is copied in for one run, because only under app/ does it go silent with the rest: a clean -# run cannot tell type rules from silence. dresscode: fetch app/vendor - ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon app $(shell find cli -name '*.php') - @cp tests/dresscode/override-missing.php app/override-missing.php; \ - ./bin/frankenphp$(EXE) php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app/override-missing.php | grep -q upgrading.classes.Override; found=$$?; \ - rm -f app/override-missing.php; test $$found = 0 || { echo "dresscode's type rules went silent: tests/dresscode/override-missing.php was not reported"; exit 1; } + ./cli/dresscode.sh ./bin/frankenphp$(EXE) # What .claude/settings.json runs after an agent's edit, the edit's JSON on stdin. Silent and with no # prerequisites: what it prints goes to the agent, and an edit must not start a composer install. @@ -332,8 +326,8 @@ qa: fetch app/vendor i18n mcp-bridge-data ## Run every static check (php, go, j || { echo "launcher: no non-darwin definition of $$f() (menu_other.go stub, or *_linux.go + *_other.go or *_windows.go split)"; exit 1; }; \ done && echo "platform stubs ok" @command -v shellcheck >/dev/null \ - && { shellcheck check.sh cli/compile-adminer.sh cli/kill-orphans.sh cli/demo-mysql.sh tests/cli/kill-orphans-test.sh tests/launcher/downloads.sh && echo "shellcheck ok"; } \ - || { sh -n check.sh && sh -n cli/compile-adminer.sh && sh -n cli/kill-orphans.sh && sh -n cli/demo-mysql.sh && echo "sh ok (shellcheck not installed)"; } + && { shellcheck check.sh cli/compile-adminer.sh cli/dresscode.sh cli/kill-orphans.sh cli/demo-mysql.sh tests/cli/dresscode-test.sh tests/cli/kill-orphans-test.sh tests/launcher/downloads.sh && echo "shellcheck ok"; } \ + || { sh -n check.sh && sh -n cli/compile-adminer.sh && sh -n cli/dresscode.sh && sh -n cli/kill-orphans.sh && sh -n cli/demo-mysql.sh && echo "sh ok (shellcheck not installed)"; } @# Native-shell strings: the `i18n` prerequisite already generated the real files (which is @# also what makes i18n_gen.h exist before `go vet` compiles the cgo launcher above). Assert the @# generator's output quality and lint the emitted plists. `make i18n-check` reports coverage. @@ -342,6 +336,7 @@ qa: fetch app/vendor i18n mcp-bridge-data ## Run every static check (php, go, j ./bin/frankenphp$(EXE) php-cli tests/shortcuts/ShortcutsTest.php ./bin/frankenphp$(EXE) php-cli tests/cli/WindowsIcoTest.php @sh tests/cli/kill-orphans-test.sh + @sh tests/cli/dresscode-test.sh @# The launcher's own download code against the real webview, every way adminer starts one. @sh tests/launcher/downloads.sh @command -v plutil >/dev/null && plutil -lint Info.plist.in lproj/*/Localizable.strings >/dev/null && echo "i18n + plists ok" || echo "i18n ok (plutil skipped, macOS only)" @@ -592,7 +587,7 @@ DIST = build.noindex/pkg/adminer-desktop define package-app rm -rf $(1)/cli $(COMPOSER) install --no-dev --no-interaction --working-dir=$(1) - rm -f $(1)/dresscode.neon + rm -f $(1)/*.neon $(if $(EXE),,./bin/frankenphp php-cli cli/latte-precompile.php $(1)) endef diff --git a/app/dresscode.neon b/app/dresscode.neon index 7d2c5002..66ca75e0 100644 --- a/app/dresscode.neon +++ b/app/dresscode.neon @@ -2,11 +2,9 @@ # follows adminer's, and only what is decided here gets reported. # https://dresscode.run/ -# ../cli only gives the type rules its files: a directory outside this root is not walked, so the -# Makefile names them. +# cli/ lies outside this root, where a directory is not walked: cli/dresscode.sh names its files. paths: - . - - ../cli # Beside vendor/ on purpose: from anywhere else DressCode takes app/, its own installation, for # foreign code, and the rules that need types find nothing there and still exit 0. diff --git a/app/phpstan.neon b/app/phpstan.neon new file mode 100644 index 00000000..51d9c08b --- /dev/null +++ b/app/phpstan.neon @@ -0,0 +1,3 @@ +# What dresscode's type rules read: it looks for this file only in its own root, app/. +includes: + - ../phpstan.neon diff --git a/cli/dresscode.sh b/cli/dresscode.sh new file mode 100755 index 00000000..f25a0154 --- /dev/null +++ b/cli/dresscode.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Runs dresscode over app/ and each PHP file in cli/, then again with a file that breaks a type rule +# in both. A clean run cannot tell a checked file from one dropped without a word, and the type rules +# go silent with exit 0 when dresscode.neon leaves app/. +# Usage: cli/dresscode.sh +set -eu + +frankenphp=$1 + +run() { + find cli -name '*.php' -exec "$frankenphp" php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app {} + +} + +if [ ! -f app/phpstan.neon ]; then + echo "app/phpstan.neon is missing: dresscode's type rules would run without phpstan.neon, and not say so" >&2 + exit 1 +fi + +run + +trap 'rm -f app/override-missing.php cli/override-missing.php' EXIT +# dash skips the EXIT trap on a signal unless the signal itself exits +trap 'exit 130' INT TERM +for file in app/override-missing.php cli/override-missing.php; do + cp tests/dresscode/override-missing.php "$file" +done + +output=$(run || true) +case $output in +*"the types go without it"*) + printf '%s\n' "$output" + echo "dresscode's type rules run without phpstan.neon" >&2 + exit 1 + ;; +esac +found=$(printf '%s\n' "$output" | grep -c upgrading.classes.Override || true) +if [ "$found" != 2 ]; then + printf '%s\n' "$output" + echo "dresscode's type rules went silent: reported tests/dresscode/override-missing.php $found times of 2, once from app/ and once from cli/" >&2 + exit 1 +fi diff --git a/tests/cli/dresscode-test.sh b/tests/cli/dresscode-test.sh new file mode 100755 index 00000000..8bed8143 --- /dev/null +++ b/tests/cli/dresscode-test.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# What cli/dresscode.sh would get wrong silently: passing when a type rule went quiet in app/ or cli/, +# or when phpstan.neon was not read, and leaving its bad files behind. Stubs dresscode. Run by `make qa`. +set -eu + +script=$(cd "$(dirname "$0")/../.." && pwd)/cli/dresscode.sh +dir=$(mktemp -d) +trap 'rm -rf "$dir"' EXIT +cd "$dir" +mkdir -p app cli tests/dresscode +touch app/phpstan.neon cli/a.php tests/dresscode/override-missing.php +cat > stub <<'STUB' +#!/bin/sh +[ -e app/override-missing.php ] || exit "${CLEAN_EXIT:-0}" +printf '%b\n' "$REPORT" +exit 1 +STUB +chmod +x stub +rule=upgrading.classes.Override +failed=0 + +check() { # [clean run's exit] + got=0 + REPORT=$3 CLEAN_EXIT=${4:-0} "$script" ./stub >/dev/null 2>&1 || got=$? + if [ "$got" = "$2" ] && [ ! -e app/override-missing.php ] && [ ! -e cli/override-missing.php ]; then + echo "ok $1" + else + echo "FAIL $1 (exit $got)" + failed=1 + fi +} + +check "passes when both bad files are reported" 0 "$rule\n$rule" +check "fails when only one is reported" 1 "$rule" +check "fails when neither is" 1 "OK" +check "fails when phpstan.neon was not read" 1 "$rule\n$rule\nthe types go without it" +check "fails on a finding in the real code" 1 "" 3 + +rm app/phpstan.neon +check "fails when app/phpstan.neon is gone" 1 "$rule\n$rule" +touch app/phpstan.neon + +cat > stub <<'STUB' +#!/bin/sh +[ -e app/override-missing.php ] || exit 0 +touch started +sleep 1 +STUB +"$script" ./stub >/dev/null 2>&1 & +pid=$! +while [ ! -e started ]; do sleep 0.1; done +kill -TERM "$pid" +wait "$pid" || true +if [ -e app/override-missing.php ] || [ -e cli/override-missing.php ]; then + echo "FAIL an interrupted run removes its bad files" + failed=1 +else + echo "ok an interrupted run removes its bad files" +fi +exit "$failed" From 54035b403ea54487b38b38134aaf42866e788c20 Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sun, 1 Nov 2026 00:17:58 +0100 Subject: [PATCH 7/8] devops: say when the dresscode hook could not check a file, it looked the same as a clean one --- Makefile | 3 ++- cli/dresscode-hook.php | 17 ++++++++++++++--- tests/cli/dresscode-hook-test.sh | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 tests/cli/dresscode-hook-test.sh diff --git a/Makefile b/Makefile index bda6531d..77b03d81 100644 --- a/Makefile +++ b/Makefile @@ -326,7 +326,7 @@ qa: fetch app/vendor i18n mcp-bridge-data ## Run every static check (php, go, j || { echo "launcher: no non-darwin definition of $$f() (menu_other.go stub, or *_linux.go + *_other.go or *_windows.go split)"; exit 1; }; \ done && echo "platform stubs ok" @command -v shellcheck >/dev/null \ - && { shellcheck check.sh cli/compile-adminer.sh cli/dresscode.sh cli/kill-orphans.sh cli/demo-mysql.sh tests/cli/dresscode-test.sh tests/cli/kill-orphans-test.sh tests/launcher/downloads.sh && echo "shellcheck ok"; } \ + && { shellcheck check.sh cli/compile-adminer.sh cli/dresscode.sh cli/kill-orphans.sh cli/demo-mysql.sh tests/cli/dresscode-test.sh tests/cli/dresscode-hook-test.sh tests/cli/kill-orphans-test.sh tests/launcher/downloads.sh && echo "shellcheck ok"; } \ || { sh -n check.sh && sh -n cli/compile-adminer.sh && sh -n cli/dresscode.sh && sh -n cli/kill-orphans.sh && sh -n cli/demo-mysql.sh && echo "sh ok (shellcheck not installed)"; } @# Native-shell strings: the `i18n` prerequisite already generated the real files (which is @# also what makes i18n_gen.h exist before `go vet` compiles the cgo launcher above). Assert the @@ -337,6 +337,7 @@ qa: fetch app/vendor i18n mcp-bridge-data ## Run every static check (php, go, j ./bin/frankenphp$(EXE) php-cli tests/cli/WindowsIcoTest.php @sh tests/cli/kill-orphans-test.sh @sh tests/cli/dresscode-test.sh + @sh tests/cli/dresscode-hook-test.sh @# The launcher's own download code against the real webview, every way adminer starts one. @sh tests/launcher/downloads.sh @command -v plutil >/dev/null && plutil -lint Info.plist.in lproj/*/Localizable.strings >/dev/null && echo "i18n + plists ok" || echo "i18n ok (plutil skipped, macOS only)" diff --git a/cli/dresscode-hook.php b/cli/dresscode-hook.php index 469f88e9..bc95caa7 100644 --- a/cli/dresscode-hook.php +++ b/cli/dresscode-hook.php @@ -5,8 +5,8 @@ * Not nette's php-fixer plugin, which needs a `php` on PATH and starts dresscode through * PHP_BINARY: there is no `php` here, and that binary is frankenphp. * -* A rule the file already broke stays broken (--before), and a file dresscode.neon leaves out -* stays as written (--skip-excluded), so an edit never rewrites adminer's own files. +* A rule the file already broke stays broken (--before), and a file dresscode.neon leaves out stays +* as written (--skip-excluded, for all but cli/), so an edit never rewrites adminer's own files. */ $input = json_decode((string) file_get_contents("php://stdin"), true); @@ -15,10 +15,13 @@ exit(0); } +$file = (string) realpath($file); + // The hook runs from the session's checkout, but an edit in a worktree belongs to that worktree's // config and dresscode: an installation outside the config's root finds nothing, and exits 0. $root = preg_match('~^(.*/\.claude/worktrees/[^/]+)/~', $file, $match) === 1 ? $match[1] : dirname(__DIR__); if (!is_file($root . "/app/vendor/bin/dresscode")) { + tellAgent("dresscode did not run on $file: $root has no app/vendor. Run make qa there."); exit(0); } $command = [PHP_BINARY, "php-cli", $root . "/app/vendor/bin/dresscode", "fix", $file, "-c", $root . "/app/dresscode.neon", "--format", "agent", "--no-color", "--jobs", "1"]; @@ -52,6 +55,14 @@ fwrite(STDERR, ($stdout ?: $stderr ?: "dresscode failed on $file with exit code $status") . "\n"); exit(2); } +// Without adminer's files a method overriding Adminer\Plugin has no parent, and its rules report clean. +if (!is_file($root . "/app/adminer.php")) { + $stdout = trim("$stdout\nThe rules that need adminer's classes did not check $file: $root has no app/adminer.php. Run make fetch there."); +} if ($stdout !== "") { - echo json_encode(["hookSpecificOutput" => ["hookEventName" => "PostToolUse", "additionalContext" => $stdout]], JSON_INVALID_UTF8_SUBSTITUTE); + tellAgent($stdout); +} + +function tellAgent(string $text): void { + echo json_encode(["hookSpecificOutput" => ["hookEventName" => "PostToolUse", "additionalContext" => $text]], JSON_INVALID_UTF8_SUBSTITUTE); } diff --git a/tests/cli/dresscode-hook-test.sh b/tests/cli/dresscode-hook-test.sh new file mode 100755 index 00000000..418de9e4 --- /dev/null +++ b/tests/cli/dresscode-hook-test.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# cli/dresscode-hook.php given a file in cli/ spelled through a symlink, as /tmp is on macOS: a plain +# comparison takes it for a file outside cli/ and skips it with exit 0. Run by `make qa`. +set -eu + +root=$(cd "$(dirname "$0")/../.." && pwd) +dir=$(mktemp -d) +probe=$root/cli/hook-probe-$$.php +trap 'rm -rf "$dir" "$probe"' EXIT +ln -s "$root" "$dir/link" +cat > "$probe" <<'PHP' +/dev/null 2>&1 || true +if grep -q 'array()' "$probe"; then + echo "dresscode-hook skipped a file in cli/ reached through a symlink" >&2 + exit 1 +fi +echo "dresscode-hook ok" From 933a03068c99aefa21765cff7f47c5cef880612b Mon Sep 17 00:00:00 2001 From: Michal Landsman Date: Sun, 1 Nov 2026 00:25:02 +0100 Subject: [PATCH 8/8] devops: count dresscode's findings in a fixed format, github's own prints each one twice --- cli/dresscode.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/dresscode.sh b/cli/dresscode.sh index f25a0154..fabc53ee 100755 --- a/cli/dresscode.sh +++ b/cli/dresscode.sh @@ -8,7 +8,7 @@ set -eu frankenphp=$1 run() { - find cli -name '*.php' -exec "$frankenphp" php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color app {} + + find cli -name '*.php' -exec "$frankenphp" php-cli app/vendor/bin/dresscode check --jobs 1 -c app/dresscode.neon --no-color "$@" app {} + } if [ ! -f app/phpstan.neon ]; then @@ -25,7 +25,8 @@ for file in app/override-missing.php cli/override-missing.php; do cp tests/dresscode/override-missing.php "$file" done -output=$(run || true) +# A fixed format: under GitHub Actions the default one prints each finding twice. +output=$(run --format agent || true) case $output in *"the types go without it"*) printf '%s\n' "$output"