Version 5.0 - #35
Merged
Merged
Conversation
Move every class to the Kununu\CodeTools namespace under a conventional src/ layout, with the PHP_CodeSniffer standard at src/PHPCodeSniffer/Kununu so installed_paths resolves inside the package. Tests mirror src/ one-for-one under Kununu\CodeTools\Tests, with fixtures in tests/resources. - Make the pre-commit hook honour the project's own php-cs-fixer.php when it has one, so paths that config excludes are no longer reformatted - Install the git hook from post-install-cmd, since Composer never loads the root package as a plugin and so never reaches the plugin events - Add a PHPStan config template, publishable with `code-tools publish:config phpstan` - Mark the four sniffs final and require ext-mbstring and ext-tokenizer - Rename the repo's own tool configs to *.dist, and Rector's to rector-ci.php - Run every quality gate from vendor/bin, so `composer ci` needs nothing installed globally - Add UPGRADE.md and reduce README.md to a tool index linking per-tool pages Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
hugo-goncalves-kununu
marked this pull request as ready for review
September 11, 2026 15:08
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A consuming repository had the working-directory relative form, "vendor/kununu/code-tools", not the "../../" form used by the shipped template. Both need the same /src/PHPCodeSniffer suffix, so document both and the error that shows when it is missing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
danielsantos-kununu
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The objective of this PR is to prepare the
5.0major release: move the package onto a conventionalsrc/layout under a singleKununu\CodeToolsnamespace, make the PHP-CS-Fixer pre-commit hook respect a consuming project's own configuration, and make every quality gate runnable from a clean clone.It is intentionally one commit, because the restructure touches namespaces, paths and configs together, and splitting it would leave intermediate states that do not build.
Consumers have work to do on upgrade. That is written up in
UPGRADE.md; the short version isinstalled_pathsin a publishedphpcs.xml, the Architecture Sniffer class name inphpstan.neon, and a one-off hook reinstall.Details
src/(wasKununu/)Kununu\CodeToolsnamespace under a conventional PSR-4src/root.src/PHPCodeSniffer/Kununu, soinstalled_pathsresolves inside the package. The standard name and theKununu\Sniffs\namespace are unchanged, so existing<rule ref="Kununu.Files.LineLength"/>references keep working.final.src/PHPCSFixer/Hooks/git-pre-commitandCsFixerGitHookCommandphp-cs-fixer.phpwhen it has published one, and the shippeddist/php-cs-fixer.php.distotherwise. Previously it always used the package's internal config, so paths a project excluded were reformatted anyway..git/kununu/filter-by-configmarker written by the installer, because PHP-CS-Fixer ignores its own finder as soon as explicit paths are passed, which is how the hook invokes it. The marker is not written for the packaged template, whose finder is rooted insidevendor/and would match nothing.src/PHPCSFixer/CsFixerPlugin.phpandcomposer.jsonCsFixerPlugin::installGitHooks(), wired topost-install-cmd/post-update-cmd. Composer only loads plugins from installed packages, never the root package, so this repository's owncomposer installnever reached the plugin events and never installed its hook. Consumers installing with--no-pluginscan use the same callable.php://outputso it honours output buffering and tests can capture it.tests/src/one-for-one underKununu\CodeTools\Tests, with noUnit/level, since every test here is a unit test, so the single suite is namedFull.tests/resources/PHPCodeSnifferandtests/resources/PHPCSFixer.Quality gates (
composer.json,.github/workflows/continuous-integration.yml)composer-dependency-analyserandcomposer-require-checkermoved intorequire-devand run fromvendor/bin, andcomposer auditreplaces the externalcomposer-audittool. A fresh clone pluscomposer installis now enough to runcomposer ci; nothing has to be installed globally.composer auditruns with--abandoned=report:composer-require-checkerpulls in the abandonedazjezz/psl. Security advisories still fail the build for production and dev dependencies alike.Root configs
*.dist(php-cs-fixer.php.dist,phpcs.xml.dist,phpstan.neon.dist,phpunit.xml.dist,psalm.xml.dist), and Rector's isrector-ci.php, named for the CI gate that enforces it..gitignorecovers the unsuffixed local overrides.php-cs-fixer.php.distconsumes the published template and only adjusts the finder, so the rules used here cannot drift from the ones shipped to consumers.dist/dist/phpstan.neon.dist, publishable withcode-tools publish:config phpstan.dist/rector.php.distswitched towithPhpSets()andwithComposerBased(phpunit: true).dist/.editorconfig.distnow covers.neonfiles.Documentation
README.mdreduced to a tool index linking one page per tool; folders renamed to match the tool names (CodeSniffer→PHPCodeSniffer,CsFixer→PHPCSFixer,PhpInK8s→PHPInK8s), plus a new PHPStan page.UPGRADE.md, and a back-to-index footer on every documentation page.AGENTS.mdrecords the conventions and the non-obvious constraints behind them.