mirror of
https://github.com/ivuorinen/monolog-gdpr-filter.git
synced 2026-01-26 11:44:04 +00:00
3.5 KiB
3.5 KiB
GitHub Copilot Instructions for monolog-gdpr-filter
Project Overview
This project is a PHP library that provides a Monolog processor for GDPR compliance.
It allows masking, removing, or replacing sensitive data in logs using regex patterns, field-level configuration, and custom callbacks. It is designed for easy integration with Monolog and Laravel.
Coding Conventions
- Language: PHP 8.2+
- PHP Version: Ensure compatibility with PHP 8.2 and above.
- PSR Standards: Follow PSR-12 for code style and autoloading.
- Testing: Use PHPUnit for all tests. Place tests in the
tests/directory. Runcomposer testto execute tests.- All tests should be written in a way that they can run independently.
- Use Attribute-based annotations for test methods (e.g.,
#[Test]). - Use Attribute-based annotations for Covers (e.g.,
#[CoversClass(GdprProcessor::class)]). - PHPUnit Version: Use PHPUnit 10.x or above.
- PHPUnit Configuration: Use
phpunit.xmlfor configuration. - Code Coverage: Use PHPUnit's code coverage features. Generate reports in the
build/directory.
- Type Declarations: Use strict typing and type declarations for all functions and methods.
- Namespaces: Use appropriate namespaces for all classes
(e.g.,
Ivuorinen\MonologGdprFilter, orTests\for tests). - Error Handling: Use exceptions for error handling.
- Static Analysis:
- Use Psalm and PHPStan for static analysis.
- Config files:
psalm.xml,phpstan.neon(if present).
- Linting: Use PHP_CodeSniffer with
phpcs.xmlfor code style checks. All code must pass linting before merging. - Composer: Use Composer for dependency management. Follow PSR-4 autoloading.
- Use
composer installto install dependencies. - Use
composer updateto update dependencies.
- Use
- Formatting: Use 4 spaces for indentation. No trailing whitespace. Use Unix line endings.
See
.editorconfigandphpcs.xmlfor more details. - Version Control:
- Use Git for version control.
- Follow semantic versioning (MAJOR.MINOR.PATCH).
- Do not commit anything, user will do it themselves.
- Documentation:
- Public classes and methods should have PHPDoc blocks.
- Update
README.mdfor usage and installation changes.
Pull Request Guidelines
- Ensure your branch is up-to-date with
main. - Use descriptive branch names (e.g.,
feature/add-gdpr-processor,fix/issue-42). - Include a clear description of changes in the PR.
- Link to any relevant issues (e.g.,
fixes #42). - Ensure all tests pass (
vendor/bin/phpunit). - Run static analysis (
vendor/bin/psalmand/orvendor/bin/phpstan). - Run code style checks (
vendor/bin/phpcs). - Add or update tests for new features or bug fixes.
- Update documentation as needed.
Directory Structure
src/— Main library source codetests/— PHPUnit testsbuild/— Build artifacts and coverage reportsvendor/— Composer dependencies
Commit Message Guidelines
- Use clear, concise messages in semantic commits style
(e.g.,
fix: mask email addresses in context,feat(logger): add audit logger option). - Reference issues when relevant (e.g.,
fix: #12 ...).
Security & Privacy
- Do not log or expose real sensitive data in tests or documentation.
- Ensure all masking/removal logic is covered by tests.
Automation
- Use Composer scripts for automation if needed.
- CI will run tests, static analysis, and code style checks.
For questions, see the README.md or open an issue.