Skip to content

Version 5.0 - #35

Merged
hugo-goncalves-kununu merged 7 commits into
mainfrom
version-5
Sep 14, 2026
Merged

Version 5.0#35
hugo-goncalves-kununu merged 7 commits into
mainfrom
version-5

Conversation

@hugo-goncalves-kununu

@hugo-goncalves-kununu hugo-goncalves-kununu commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Description

The objective of this PR is to prepare the 5.0 major release: move the package onto a conventional src/ layout under a single Kununu\CodeTools namespace, 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 is installed_paths in a published phpcs.xml, the Architecture Sniffer class name in phpstan.neon, and a one-off hook reinstall.

Details

  • src/ (was Kununu/)

    • Every class moved to the Kununu\CodeTools namespace under a conventional PSR-4 src/ root.
    • The PHP_CodeSniffer standard now lives at src/PHPCodeSniffer/Kununu, so installed_paths resolves inside the package. The standard name and the Kununu\Sniffs\ namespace are unchanged, so existing <rule ref="Kununu.Files.LineLength"/> references keep working.
    • The four sniffs are now final.
  • src/PHPCSFixer/Hooks/git-pre-commit and CsFixerGitHookCommand

    • The hook now uses the project's own php-cs-fixer.php when it has published one, and the shipped dist/php-cs-fixer.php.dist otherwise. Previously it always used the package's internal config, so paths a project excluded were reformatted anyway.
    • Filtering happens in the hook itself, gated on a .git/kununu/filter-by-config marker 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 inside vendor/ and would match nothing.
    • Fixed an installer bug where the existing symlink was removed before the new target was validated, which could leave a repository with no hook config at all and block every commit.
  • src/PHPCSFixer/CsFixerPlugin.php and composer.json

    • Added CsFixerPlugin::installGitHooks(), wired to post-install-cmd/post-update-cmd. Composer only loads plugins from installed packages, never the root package, so this repository's own composer install never reached the plugin events and never installed its hook. Consumers installing with --no-plugins can use the same callable.
    • Plugin output moved to php://output so it honours output buffering and tests can capture it.
  • tests/

    • Tests now mirror src/ one-for-one under Kununu\CodeTools\Tests, with no Unit/ level, since every test here is a unit test, so the single suite is named Full.
    • Fixtures moved out of the mirror into tests/resources/PHPCodeSniffer and tests/resources/PHPCSFixer.
    • Installer tests now run against a throwaway git repository; previously they rewrote this repository's own hooks as a side effect of running the suite.
  • Quality gates (composer.json, .github/workflows/continuous-integration.yml)

    • composer-dependency-analyser and composer-require-checker moved into require-dev and run from vendor/bin, and composer audit replaces the external composer-audit tool. A fresh clone plus composer install is now enough to run composer ci; nothing has to be installed globally.
    • composer audit runs with --abandoned=report: composer-require-checker pulls in the abandoned azjezz/psl. Security advisories still fail the build for production and dev dependencies alike.
  • Root configs

    • The repository's own tool configs are now *.dist (php-cs-fixer.php.dist, phpcs.xml.dist, phpstan.neon.dist, phpunit.xml.dist, psalm.xml.dist), and Rector's is rector-ci.php, named for the CI gate that enforces it. .gitignore covers the unsuffixed local overrides.
    • php-cs-fixer.php.dist consumes the published template and only adjusts the finder, so the rules used here cannot drift from the ones shipped to consumers.
  • dist/

    • New dist/phpstan.neon.dist, publishable with code-tools publish:config phpstan.
    • dist/rector.php.dist switched to withPhpSets() and withComposerBased(phpunit: true).
    • dist/.editorconfig.dist now covers .neon files.
  • Documentation

    • README.md reduced to a tool index linking one page per tool; folders renamed to match the tool names (CodeSnifferPHPCodeSniffer, CsFixerPHPCSFixer, PhpInK8sPHPInK8s), plus a new PHPStan page.
    • Added UPGRADE.md, and a back-to-index footer on every documentation page.
    • AGENTS.md records the conventions and the non-obvious constraints behind them.

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>
@hugo-goncalves-kununu hugo-goncalves-kununu changed the title Restructure the package for the 5.0 release Version 5.0 Sep 11, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hugo-goncalves-kununu
hugo-goncalves-kununu marked this pull request as ready for review September 11, 2026 15:08
@hugo-goncalves-kununu
hugo-goncalves-kununu requested a review from a team as a code owner 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>
@hugo-goncalves-kununu
hugo-goncalves-kununu merged commit 845c72d into main Sep 14, 2026
5 checks passed
@hugo-goncalves-kununu
hugo-goncalves-kununu deleted the version-5 branch September 14, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants