Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 1 addition & 7 deletions Kununu/ArchitectureSniffer/Helper/TypeChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
->withSkip([
AddOverrideAttributeToOverriddenMethodsRector::class,
__DIR__ . '/tests/bootstrap.php',
__DIR__ . '/tests/_data',
__DIR__ . '/rector.php',
])
->withImportNames();
Loading