First off, thanks for taking the time to contribute! 🎉
The following is a set of guidelines for contributing to GatePay. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
This project and everyone participating in it is governed by our commitment to providing a welcoming and inclusive environment. By participating, you are expected to:
- Be respectful and considerate
- Accept constructive criticism gracefully
- Focus on what is best for the community
- Show empathy towards other community members
Before creating bug reports, please check existing issues to avoid duplicates.
When reporting a bug, include:
- Clear title - Descriptive summary of the issue
- Steps to reproduce - Detailed steps to reproduce the behavior
- Expected behavior - What you expected to happen
- Actual behavior - What actually happened
- Environment - PHP version, OS, relevant package versions
- Code samples - Minimal reproducible example if possible
### Bug Report Template
**Description:**
A clear description of what the bug is.
**Steps to Reproduce:**
1. Go to '...'
2. Click on '...'
3. See error
**Expected Behavior:**
What you expected to happen.
**Actual Behavior:**
What actually happened.
**Environment:**
- PHP Version: [e.g., 8.2]
- OS: [e.g., Ubuntu 22.04]
- GatePay Version: [e.g., 1.0.0]
**Additional Context:**
Any other context about the problem.Enhancement suggestions are welcome! Please provide:
- Use case - Why is this enhancement needed?
- Proposed solution - How should it work?
- Alternatives considered - Other approaches you've thought about
- Additional context - Any other relevant information
- Fork the repository and create your branch from
main - Follow the style guidelines outlined below
- Add tests for any new functionality
- Ensure all tests pass before submitting
- Update documentation if needed
- Write a clear PR description explaining your changes
- PHP 8.1 or higher
- Composer
# Clone your fork
git clone https://github.com/YOUR_USERNAME/GatePay-Core.git
cd GatePay-Core
# Install dependencies
composer install
# Run tests to verify setup
composer test# Run tests
composer test
# or
./vendor/bin/phpunit
# Run tests with coverage
./vendor/bin/phpunit
# Run code style check
./vendor/bin/phpcs
# Fix code style automatically
./vendor/bin/phpcbf
# Run static analysis
./vendor/bin/phpstan analyseWe follow PSR-12 coding standards with some additional conventions:
- Strict types - All PHP files must declare
strict_types=1 - Type declarations - Use parameter and return type declarations
- DocBlocks - Document all public methods and complex logic
- No unused imports - Remove unused
usestatements
<?php
declare(strict_types=1);
namespace GatePay\Core;
use GatePay\Core\Interfaces\ExampleInterface;
/**
* Brief description of the class.
*/
class Example implements ExampleInterface
{
/**
* Brief description of the method.
*
* @param string $param Description of parameter
* @return bool Description of return value
*/
public function doSomething(string $param): bool
{
// Implementation
return true;
}
}| Type | Convention | Example |
|---|---|---|
| Classes | PascalCase | TransactionProcessor |
| Methods | camelCase | processTransaction() |
| Properties | camelCase | $transactionId |
| Constants | UPPER_SNAKE_CASE | MAX_RETRY_COUNT |
| Interfaces | PascalCase + Interface suffix | GatewayInterface |
| Abstract Classes | Abstract prefix + PascalCase | AbstractGateway |
| Enums | PascalCase | TransactionState |
- Place tests in the
tests/directory mirroring thesrc/structure - Use descriptive test method names (without
testprefix when using#[Test]attribute) - Test both happy paths and edge cases
- Use data providers for testing multiple scenarios
<?php
declare(strict_types=1);
namespace GatePay\CoreTests;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
#[Test]
public function processTransactionReturnsSuccessForValidInput(): void
{
// Arrange
$processor = new TransactionProcessor();
// Act
$result = $processor->process($validTransaction);
// Assert
$this->assertTrue($result->isSuccess());
}
#[Test]
public function processTransactionThrowsExceptionForInvalidInput(): void
{
$this->expectException(InvalidArgumentException::class);
$processor = new TransactionProcessor();
$processor->process($invalidTransaction);
}
}# Run all tests
./vendor/bin/phpunit
# Run specific test file
./vendor/bin/phpunit tests/TransactionTest.php
# Run specific test method
./vendor/bin/phpunit --filter testMethodName
# Run with coverage report
./vendor/bin/phpunit --coverage-html coverage/- Aim for 80%+ code coverage for new code
- Critical paths (payment processing, state management) should have 100% coverage
We follow the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
| Type | Description |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation only changes |
style |
Code style changes (formatting, etc.) |
refactor |
Code refactoring without feature changes |
test |
Adding or updating tests |
chore |
Maintenance tasks |
# Feature
feat(gateway): add support for PayPal Express Checkout
# Bug fix
fix(transaction): handle null response from gateway
# Documentation
docs(readme): update installation instructions
# Tests
test(parser): add coverage for CDATA handlingFeel free to open an issue with the question label if you have any questions about contributing.
Thank you for contributing to GatePay! 🙏