This file contains instructions for AI agents working on this repository.
| Command | Description |
|---|---|
composer install |
Install dependencies |
composer test |
Run all tests |
composer lint |
Check PSR-12 compliance |
composer format |
Fix coding style automatically |
composer analyze |
Run static analysis with PHPStan |
- Unit tests: Located in
tests/Unit/ - Testing guidelines: See
docs/contributing/testing-guidelines.mdfor patterns - Data-driven testing: Use comprehensive providers with descriptive keys
- Arrange-Act-Assert: Structure tests with clear setup, action, and assertion sections
- No mocks: Create custom test implementations instead of PHPUnit mocks
- All contributions must include tests that pass
- Code style: Follow PSR-12 coding standard
- Static analysis: Use PHPStan, fix any issues before submitting
When creating new formatters:
- Class template:
docs/contributing/templates/php/src/TemplateFormatter.php - Test template:
docs/contributing/templates/php/tests/TemplateFormatterTest.php - Documentation template:
docs/contributing/templates/formatter-documentation-template.md
All formatters must implement the Respect\StringFormatter\Formatter interface.
When creating new modifiers:
- Follow Chain of Responsibility pattern: Check pipe value and delegate to next modifier
- Use template structure: Similar to
src/Modifier/QuoteModifier.php - Test with TestingModifier: Located in
tests/Helper/TestingModifier.php - Handle type checking: Always check input types before processing
- Return string values: Modifiers must return strings
- Use Stringifier Quoter: For string operations, inject
\Respect\Stringifier\Quoterwith CodeQuoter as default
All modifiers must implement the Respect\StringFormatter\Modifier interface.
- Avoid PHPUnit mocks: Create custom test implementations instead of using createMock()
- Use custom test quoter: Follow pattern in
tests/Helper/TestingQuoter.php - Test contracts not implementations: Verify interactions without depending on specific behavior
- Make test properties public: When using anonymous classes to access test state
- Verify method calls: Track whether methods were called and with what parameters
Follow the detailed rules in docs/contributing/commit-guidelines.md:
- Title: 5-116 characters, imperative mood, starts with capital
- Body: Explain WHY, max 116 characters per line
- Footer: Use trailers for references and AI attribution
/src/- Formatter implementations/tests/Unit/- Unit tests/docs/- Documentation including formatter docs/docs/contributing/- Contribution guidelines and templates
- Run composer commands:
test,lint,analyze - Ensure documentation follows templates
- Check commit message follows guidelines
- Verify all tests pass
Remember: Reference external docs rather than duplicating information in this file.