From 3a0fd0afa0d7cd069371407bf9c5260aaaadc1c7 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 25 Mar 2026 12:32:58 +0800 Subject: [PATCH 1/2] docs: add static analysis documentation (Issue #43) Document PHPStan and PHPCS usage for Issue #43. Related: #43 --- docs/STATIC_ANALYSIS.md | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docs/STATIC_ANALYSIS.md diff --git a/docs/STATIC_ANALYSIS.md b/docs/STATIC_ANALYSIS.md new file mode 100644 index 0000000..01913f0 --- /dev/null +++ b/docs/STATIC_ANALYSIS.md @@ -0,0 +1,42 @@ +# Static Analysis and Code Quality + +This project uses PHPStan for static analysis and PHPCS for code style checking. + +## PHPStan (Static Analysis) + +We use PHPStan level 9 for strict type checking. + +### Run Locally + +```bash +make stan +``` + +### Configuration + +See `phpstan.neon` for configuration. + +## Code Style (PHPCS) + +We follow PSR-12 coding standards. + +### Check Code Style + +```bash +make sniff +``` + +### Fix Code Style + +```bash +make cs +``` + +## CI Integration + +The CI pipeline runs: +1. Unit tests (PHPUnit) +2. Static analysis (PHPStan) +3. Code style check (PHPCS) + +All checks must pass before merging. From 9ac442e30f576c6bffc6e7b8877d86379a4adeda Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 25 Mar 2026 12:34:17 +0800 Subject: [PATCH 2/2] docs: add CI update instructions for Issue #43 --- docs/CI_UPDATE_REQUIRED.md | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 docs/CI_UPDATE_REQUIRED.md diff --git a/docs/CI_UPDATE_REQUIRED.md b/docs/CI_UPDATE_REQUIRED.md new file mode 100644 index 0000000..dcfb112 --- /dev/null +++ b/docs/CI_UPDATE_REQUIRED.md @@ -0,0 +1,82 @@ +# Required CI Update for Issue #43 + +To complete Issue #43, the following CI workflow changes are needed: + +## Add to `.github/workflows/ci.yml` + +```yaml + static-analysis: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: gmp + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist + + - name: PHPStan + run: make stan + + code-style: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: gmp + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist + + - name: Code Style (PHPCS) + run: make sniff +``` + +## Current Makefile Commands + +- `make stan` - Run PHPStan level 9 +- `make sniff` - Check code style (PSR-12) +- `make cs` - Fix code style + +## PHPStan Configuration + +Already configured in `phpstan.neon`: +```yaml +parameters: + level: 9 + paths: + - src + - tests +```