diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c3da837 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: [8.2, 8.3, 8.4, 8.5] + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + # - name: Check code style + # run: composer cs-check + + # - name: Run PHPStan + # run: composer stan + + # - name: Run tests + # run: composer test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2a81267 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# Contributing + +Contributions are welcome! Please follow these steps to set up the project and ensure your changes pass all checks before submitting a PR. + +## Setup + +1. Fork the repository +2. Clone your fork +3. Install dependencies: + +```bash +composer install +``` + +## Available Scripts + +| Command | Description | +|---|---| +| `composer cs-check` | Check code style with PHPCS (PSR-12) | +| `composer cs-fix` | Auto-fix code style violations | +| `composer stan` | Run PHPStan static analysis (level 1) | +| `composer test` | Run the test suite (Pest) | +| `composer check` | Run all checks (style, static analysis, tests) | + +## Before Submitting a PR + +Make sure all checks pass locally: + +```bash +composer check +``` + +This runs the three checks sequentially: + +1. **Code style** (`composer cs-check`) — must pass with no violations +2. **Static analysis** (`composer stan`) — must pass with no errors +3. **Tests** (`composer test`) — all tests must pass + +If you have code style violations, you can auto-fix most of them: + +```bash +composer cs-fix +``` + +## CI Pipeline + +A GitHub Actions CI pipeline runs automatically on every push and pull request targeting `main`. It runs all checks across **PHP 8.2, 8.3, 8.4, and 8.5**. diff --git a/composer.json b/composer.json index 15dc7ce..0c31811 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,19 @@ } }, "require-dev": { - "pestphp/pest": "^3" + "pestphp/pest": "^3", + "squizlabs/php_codesniffer": "^4.0", + "phpstan/phpstan": "^2.1" + }, + "scripts": { + "test": "pest", + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "stan": "phpstan analyse", + "check": [ + "@cs-check", + "@stan", + "@test" + ] } } diff --git a/composer.lock b/composer.lock index 534fed0..7ba6a0b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e0efbaeb7b6bfc400b23cfffe3795d31", + "content-hash": "71798ca3ccf65b3002efd11d920a1b41", "packages": [ { "name": "guzzlehttp/guzzle", @@ -2038,6 +2038,59 @@ }, "time": "2026-01-25T14:56:51+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.54", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8be50c3992107dc837b17da4d140fbbdf9a5c5bd", + "reference": "8be50c3992107dc837b17da4d140fbbdf9a5c5bd", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2026-04-29T13:31:09+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.12", @@ -3634,6 +3687,85 @@ ], "time": "2024-10-09T05:16:32+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "0525c73950de35ded110cffafb9892946d7771b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0525c73950de35ded110cffafb9892946d7771b5", + "reference": "0525c73950de35ded110cffafb9892946d7771b5", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=7.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-11-10T16:43:36+00:00" + }, { "name": "staabm/side-effects-detector", "version": "1.0.5", @@ -4607,5 +4739,5 @@ "platform-overrides": { "php": "8.2.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..ea6cce3 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,15 @@ + + + Coding standard for moyasar-php + + + + + src/ + tests/ + + + + + tests/Pest.php + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..74bf342 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + paths: + - src + level: 1