From 0d8cfe9edab4a9fc5dfe1c1d3f9ef735c977ea96 Mon Sep 17 00:00:00 2001 From: "andre.soares" Date: Thu, 2 Jul 2026 17:23:08 +0100 Subject: [PATCH 1/2] docs: add kun-init 4-file documentation structure --- AGENTS.md | 41 +++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 1 + CONTRIBUTING.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ 4 files changed, 94 insertions(+) create mode 100644 AGENTS.md create mode 100644 CLAUDE.md create mode 100644 CONTRIBUTING.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..6760383 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,41 @@ +# AGENTS.md + +Guidance for AI agents working in this repository. For install and usage see `README.md`; for dev workflow see `CONTRIBUTING.md`. + +## What this is + +`kununu/code-tools` is a shared dev-tooling package (`composer-plugin`) consumed by most kununu PHP repositories. It centralises static-analysis and code-style configuration and ships a `code-tools` binary that publishes those configs into consuming projects. + +## Bundled tools + +- PHP-CS-Fixer, PHP_CodeSniffer (with custom `Kununu` sniffs), Psalm, PHPStan, Rector. +- Architecture Sniffer, built on PHPAT, for architecture/dependency rules. +- `bin/code-tools`: publishes `dist/*.dist` configs into a consuming project. +- `bin/php-in-k8s`: runs PHP commands inside a local Kubernetes pod. + +## Code layout + +- `Kununu/` — PSR-4 source (`Kununu\` namespace): `CsFixer/` (composer plugin, command, git hook, provider), `Sniffs/` (custom PHP_CodeSniffer sniffs), `ArchitectureSniffer/`. +- `bin/` — the `code-tools` and `php-in-k8s` executables. +- `dist/` — `*.dist` config templates published into consuming projects. +- `docs/` — per-tool deep documentation, one folder per tool. +- `tests/` — PHPUnit tests under `tests/Unit/`, mirroring the `Kununu/` tree. + +## Conventions + +- `declare(strict_types=1);` in every PHP file. +- Follow the repo's own PHP-CS-Fixer and PHP_CodeSniffer rulesets; changes must stay clean under both. +- Custom sniffs live under `Kununu\Sniffs`; register them in `Kununu/Sniffs/ruleset.xml`. +- Tests mirror the source namespace under `tests/Unit/`. +- PHP version is pinned in `composer.json` (`require.php`). + +## Quality gates + +Run `composer ci-checks` (cs-fixer, code sniffer, PHPStan, Rector, Psalm, PHPUnit). PHPStan runs at max level and Psalm must pass with no cache. See `scripts` in `composer.json` for individual commands and `CONTRIBUTING.md` for details. + +## Hard constraints + +- Do not edit `vendor/`. +- Do not hardcode tool versions in docs; reference `composer.json`. +- Changes to `dist/*.dist` affect every consuming repo — treat them as public API. +- Keep the `code-tools` binary interface backward compatible. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1136d6f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,48 @@ +# Contributing + +How to develop, test, and ship changes to `kununu/code-tools`. + +## Development setup + +Requires PHP as pinned in `composer.json` (`require.php`) and Composer. + +```console +composer install +``` + +## Testing + +Run the unit test suite: + +```console +composer test-unit +``` + +## Quality checks + +Run the full check suite before opening a PR: + +```console +composer ci-checks +``` + +This runs PHP-CS-Fixer, PHP_CodeSniffer, PHPStan, Rector, Psalm, and PHPUnit. Auto-fixers are available for style and refactors: + +```console +composer cs-fixer-fix +composer cs-fix +composer rector-fix +``` + +See the `scripts` section of `composer.json` for the complete list of commands. + +## Pull requests + +- Branch from `main`. +- Fill in `.github/PULL_REQUEST_TEMPLATE.md`, including the linked JIRA issue. +- Ensure CI is green; the Continuous Integration workflow runs the checks above plus composer dependency and normalization checks, and reports coverage to SonarCloud. +- `@kununu/backend-libraries` is the code owner and reviews all changes. + +## Releasing + +The package is distributed via Composer and versioned with Git tags following SemVer. Because most kununu PHP repos depend on this package, and `dist/*.dist` templates and the `code-tools` binary form its public API, treat any change to them as breaking unless proven otherwise. diff --git a/README.md b/README.md index 064b4c9..07b079e 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,7 @@ composer require --dev kununu/code-tools --no-plugins - [bin/code-tools](docs/CodeTools/README.md) instructions. - [bin/php-in-k8s](docs/PhpInK8s/README.md) instructions. - [Architecture Sniffer & PHPAT](docs/ArchitectureSniffer/README.md) instructions. + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and the PR/release process. From 55e35299f4db90f4584495b1432faf4157557952 Mon Sep 17 00:00:00 2001 From: "andre.soares" Date: Fri, 3 Jul 2026 12:14:57 +0100 Subject: [PATCH 2/2] refactor: apply rector-fix and skip test fixtures --- Kununu/ArchitectureSniffer/Helper/TypeChecker.php | 8 +------- rector.php | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Kununu/ArchitectureSniffer/Helper/TypeChecker.php b/Kununu/ArchitectureSniffer/Helper/TypeChecker.php index 677e5a8..d2dd5c7 100644 --- a/Kununu/ArchitectureSniffer/Helper/TypeChecker.php +++ b/Kununu/ArchitectureSniffer/Helper/TypeChecker.php @@ -22,13 +22,7 @@ public static function isArrayOfStrings(mixed $arr): bool return false; } - foreach ($arr as $item) { - if (!is_string($item)) { - return false; - } - } - - return true; + return array_all($arr, static fn($item) => is_string($item)); } /** diff --git a/rector.php b/rector.php index d356972..71d75a6 100644 --- a/rector.php +++ b/rector.php @@ -15,6 +15,7 @@ ->withSkip([ AddOverrideAttributeToOverriddenMethodsRector::class, __DIR__ . '/tests/bootstrap.php', + __DIR__ . '/tests/_data', __DIR__ . '/rector.php', ]) ->withImportNames();