Thank you for your interest in contributing to StringManipulation! This document provides guidelines and instructions for contributing to the project.
- Docker and Docker Compose
- Git
- PHP 8.3+ (optional, only for local development without Docker)
This project uses pre-commit hooks to ensure code quality. All tests run in Docker containers to maintain consistency across different development environments.
-
Clone the repository
git clone https://github.com/MarjovanLier/StringManipulation.git cd StringManipulation -
Run the setup script
./setup-hooks.sh
This script will:
- Check Docker is installed and running
- Build the Docker test image
- Install pre-commit framework
- Configure git hooks
- Run initial tests to verify setup
If you prefer to set up manually:
-
Install pre-commit
# Using pip pip install pre-commit # Or using Homebrew (macOS) brew install pre-commit
-
Build Docker image
docker-compose build tests
-
Install hooks
pre-commit install pre-commit install --hook-type commit-msg
The project includes a convenient test runner script:
# Run all tests
./test-runner.sh all
# Run quick essential tests
./test-runner.sh quick
# Run specific test suite
./test-runner.sh phpunit
./test-runner.sh phpstan
./test-runner.sh psalm
./test-runner.sh style
# Open shell in test container
./test-runner.sh shell# Run all tests
docker-compose run --rm tests
# Run specific test
docker-compose run --rm test-phpunit
docker-compose run --rm test-phpstan
docker-compose run --rm test-code-style# Run all tests
docker-compose run --rm tests composer tests
# Run specific test
docker-compose run --rm tests composer test:phpunit
docker-compose run --rm tests composer test:phpstantest:code-style- Check code style (Laravel Pint)test:composer-validate- Validate composer.jsontest:infection- Run mutation testing (via Pest)test:lint- Check for syntax errorstest:phan- Static analysis with Phantest:phpmd- PHP Mess Detectortest:phpstan- PHPStan static analysistest:pest- Run Pest test suitetest:psalm- Psalm static analysistest:rector- Code quality checkstest:vulnerabilities-check- Security vulnerability scan
The following checks run automatically before each commit:
- composer.json validation - Ensures composer.json is valid
- PHP syntax check - Verifies PHP files have no syntax errors
- Code style - Enforces consistent code formatting
- Static analysis - PHPStan and Psalm checks
- Unit tests - Runs PHPUnit test suite
- Security check - Scans for known vulnerabilities
- File formatting - Trailing whitespace, EOF, line endings
This project follows the Conventional Commits specification.
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, missing semicolons, etc.)refactor: Code refactoring without changing functionalityperf: Performance improvementstest: Adding or updating testsbuild: Build system or dependency changesci: CI/CD configuration changeschore: Other changes that don't modify src or test filesrevert: Reverting a previous commit
feat(auth): add user authentication endpoint
fix(parser): resolve memory leak in tokenizer
docs: update installation instructions
feat!: add breaking change to APIAll commits must include a Signed-off-by line, which is automatically added by the commit-msg hook.
If you need to bypass pre-commit hooks in an emergency:
git commit --no-verifyNote: This should only be used in exceptional circumstances. All commits should pass the pre-commit checks.
ERROR: Docker is not running. Please start Docker and try again.
Solution: Start Docker Desktop or Docker daemon.
Permission denied while trying to connect to the Docker daemon socket
Solution: Add your user to the docker group or use sudo (not recommended).
This usually indicates environment differences. Always trust the container results as they match the CI environment.
The first run downloads Docker images and installs dependencies. Subsequent runs use cached layers and are much faster.
- Follow PSR-12 coding standards
- Use strict typing:
declare(strict_types=1); - Document all public methods with comprehensive PHPDoc
- Include examples in documentation where appropriate
- Write self-documenting code with clear variable names
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Ensure all tests pass (
./test-runner.sh all) - Commit your changes using conventional commits
- Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request
- Check existing issues and pull requests
- Read the project documentation
- Ask questions in issues (label as 'question')
Thank you for contributing to StringManipulation!