php-standards
Use when writing, reviewing, testing, formatting, or configuring any modern PHP (8.3/8.4) code in a touchstone repo — covers Composer, strict_types, PHPStan, Pint, Pest, and PHP-FPM/OPcache. Triggers on .php files, composer.json/composer.lock, phpstan.neon, pint.json. Not Laravel/Symfony framework specifics or the OWASP Top 10 (see app-security).
- License 许可
- MIT
- 最近更新
- 2026-08-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- php-standards
- license
- MIT
- metadata
- { "author": "touchstone", "version": "0.2.0" }
- description
- Use when writing, reviewing, testing, formatting, or configuring any modern PHP (8.3/8.4) code in a touchstone repo — covers Composer, strict_types, PHPStan, Pint, Pest, and PHP-FPM/OPcache. Triggers on .php files, composer.json/composer.lock, phpstan.neon, pint.json. Not Laravel/Symfony framework specifics or the OWASP Top 10 (see app-security).
03 SKILL.md 正文
PHP Standards
Full standard: standards/languages/php.md in the touchstone repo. This skill inlines the
load-bearing rules so it stays useful even when installed standalone in ~/.claude/skills/:
Always
declare(strict_types=1)as the first line of every file — without it PHP silently coerces args; enforce via the Pintdeclare_strict_typesrule.- Composer only;
composer.lockcommitted and law in CI (composer install, neverupdate). Prod installs--no-dev --optimize-autoloader. - Format with Laravel Pint; CI runs
pint --test(read-only). Type-check with PHPStan atmax— baseline legacy findings, never lower the level. - Type every signature and property;
final+readonlyvalue objects + constructor promotion by default.
Don't get burned
- Static analysis: new code held to
max; suppress only a real false positive with a narrow commented@phpstan-ignore. One analyzer per repo (PHPStan or Psalm). - Modern idioms:
match(===, throws on miss) overswitch; backedenumover string constants; nullsafe?->; first-class callables; named args are part of your API contract. - Concurrency: PHP is share-nothing per request — keep Fibers/ReactPHP/AMPHP off the FPM request path; use a client's concurrent-request pool for parallel HTTP. (scale-up)
- Tests self-skip when fixtures are absent — never hard-fail; harden
phpunit.xml(failOnWarning/failOnRisky/failOnDeprecation). - Errors: throw typed exceptions, rethrow with
previous;Throwable(notException) for a true catch-all; never echo a trace —display_errors=Offin prod. - Runtime: OPcache mandatory in prod (
validate_timestamps=0on immutable images); JIT only for CPU-bound paths — measure first. - Security:
composer auditgates CI; installroave/security-advisories(dev) so a vulnerable dep can't enter the lock. Allowlist Composer plugins.
Done
declare(strict_types=1) everywhere · pint --test clean · phpstan analyse clean at max · pest green (coverage ≥ floor) · composer validate --strict + lock committed · composer audit clean. See standards/languages/php.md.
04 同仓库更多 Skills
ok-standards
Use when writing shell, per standards/languages/shell.md.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.