Contributing Guide
Thank you for considering contributing to Data Helpers! This guide will help you get started.
Getting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- PHP 8.2 or higher
- Composer
- Git
- Docker & Docker Compose (recommended)
- Task (optional but recommended)
Setup Development Environment
Section titled “Setup Development Environment”-
Fork the repository on GitHub
-
Clone your fork:
Terminal window git clone git@github.com:YOUR_USERNAME/data-helpers.gitcd data-helpers -
Setup development environment:
Terminal window task dev:setupOr manually:
Terminal window docker-compose up -d --builddocker exec -it data-helpers-php84 composer install -
Verify installation:
Terminal window task test:run
See Development Setup for detailed instructions.
Development Workflow
Section titled “Development Workflow”1. Create a Feature Branch
Section titled “1. Create a Feature Branch”git checkout -b feature/my-featureBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test improvements
2. Make Your Changes
Section titled “2. Make Your Changes”- Write clean, readable code
- Follow PSR-12 coding standards
- Add tests for new features
- Update documentation if needed
3. Run Quality Checks
Section titled “3. Run Quality Checks”# Fix code styletask quality:ecs:fix
# Run static analysistask quality:phpstan
# Run teststask test:run
# Or run all checks at oncetask dev:pre-commit4. Commit Your Changes
Section titled “4. Commit Your Changes”Use Conventional Commits:
git add .git commit -m "feat: add new feature"Commit types:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting)refactor:- Code refactoringtest:- Test changeschore:- Build/tooling changes
5. Push and Create Pull Request
Section titled “5. Push and Create Pull Request”git push origin feature/my-featureThen create a Pull Request on GitHub.
Testing
Section titled “Testing”We use Pest for testing. All contributions must include tests.
Running Tests
Section titled “Running Tests”# Run all teststask test:run
# Run unit tests onlytask test:unit
# Run E2E tests onlytask test:e2e
# Run specific test filetask test:unit -- tests/Unit/DataMapper/DataMapperTest.php
# Run tests with filtertask test:unit -- --filter="maps nested key"
# Run with coverage (requires Xdebug)task test:coverageWriting Tests
Section titled “Writing Tests”Place tests in the appropriate directory:
tests/Unit/- Unit teststests-e2e/- End-to-end tests
Use descriptive test names:
test('maps nested data correctly', function (): void { $source = ['user' => ['name' => 'Alice']]; $mapping = ['name' => '{{ user.name }}'];
$result = DataMapper::from($source) ->template($mapping) ->map() ->getTarget();
expect($result)->toBe(['name' => 'Alice']);});Test Guidelines
Section titled “Test Guidelines”- ✅ Test one thing per test
- ✅ Use descriptive test names
- ✅ Follow AAA pattern (Arrange, Act, Assert)
- ✅ Test edge cases and error conditions
- ✅ Aim for high code coverage
- ✅ Keep tests fast and isolated
Code Style
Section titled “Code Style”We follow PSR-12 coding standards and use PHP Easy Coding Standard (ECS).
Running Code Style Checks
Section titled “Running Code Style Checks”# Check code styletask quality:ecs
# Fix code style automaticallytask quality:ecs:fixCode Style Guidelines
Section titled “Code Style Guidelines”- Use 4 spaces for indentation
- Use type hints for all parameters and return types
- Use strict types:
declare(strict_types=1); - Use readonly properties where possible
- Document complex logic with comments
- Keep methods short and focused
Static Analysis
Section titled “Static Analysis”We use PHPStan at Level 9 for static analysis.
Running PHPStan
Section titled “Running PHPStan”# Run PHPStantask quality:phpstan
# Generate baseline (if needed)task quality:phpstan:baselinePHPStan Guidelines
Section titled “PHPStan Guidelines”- Fix all PHPStan errors before submitting PR
- Don’t add to baseline unless absolutely necessary
- Use proper type hints to avoid PHPStan errors
- Use
@phpstan-ignore-next-linesparingly
Documentation
Section titled “Documentation”Code Documentation
Section titled “Code Documentation”- Add PHPDoc blocks for all public methods
- Document parameters and return types
- Include usage examples for complex features
- Keep documentation up to date
Example:
/** * Maps source data to target structure using template expressions. * * @param array<string, mixed> $source Source data * @param array<string, mixed> $source Source data * @param array<string, string> $mapping Mapping configuration * @return array<string, mixed> Mapped result * * @example * $result = DataMapper::from(['user' => ['name' => 'Alice']]) * ->template(['name' => '{{ user.name }}']) * ->map() * ->getTarget(); */public static function map(array $source, array $target, array $mapping): array{ // Implementation}User Documentation
Section titled “User Documentation”If your contribution adds new features:
- Update relevant documentation pages in
documentation/src/content/docs/ - Add code examples
- Update the changelog
Pull Request Process
Section titled “Pull Request Process”Before Submitting
Section titled “Before Submitting”- ✅ All tests pass:
task test:run - ✅ Code style is correct:
task quality:ecs:fix - ✅ PHPStan passes:
task quality:phpstan - ✅ Documentation is updated
- ✅ Changelog is updated (if applicable)
PR Guidelines
Section titled “PR Guidelines”-
Title: Use conventional commit format
- Example:
feat: add support for nested wildcards
- Example:
-
Description: Include:
- What changes were made
- Why the changes were needed
- How to test the changes
- Related issues (if any)
-
Size: Keep PRs focused and reasonably sized
- Large PRs are harder to review
- Consider splitting into multiple PRs
-
Tests: Include tests for all changes
- New features must have tests
- Bug fixes should include regression tests
Review Process
Section titled “Review Process”- Automated checks will run (tests, code style, PHPStan)
- Maintainers will review your code
- Address any feedback or requested changes
- Once approved, your PR will be merged
Reporting Issues
Section titled “Reporting Issues”Bug Reports
Section titled “Bug Reports”Include:
- PHP version
- Framework version (Laravel/Symfony)
- Steps to reproduce
- Expected behavior
- Actual behavior
- Code example (if possible)
Feature Requests
Section titled “Feature Requests”Include:
- Use case description
- Proposed solution
- Alternative solutions considered
- Code examples (if applicable)
Code of Conduct
Section titled “Code of Conduct”- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Assume good intentions
Questions?
Section titled “Questions?”- Open a GitHub Discussion
- Check existing Issues
- Read the Documentation
Next Steps
Section titled “Next Steps”- Development Setup - Setup your environment
- Testing Guide - Learn about testing
- Architecture - Understand the codebase structure
Thank you for contributing! 🎉