From bb6ae9ce7dfab6a1bb937bc5ec692c011cdb34c9 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Tue, 12 Sep 2023 23:56:25 +0800 Subject: [PATCH] Prevent adding PHPDoc types instead of native types PHPDoc types can sometimes be entirely expressed as PHP native types. It is better because it avoids code duplication and enables type runtime check. This will help us slowly migrate away from PHPDoc typing to PHP native typing. --- .github/workflows/main.yml | 17 +++++++++++++++++ bin/check-phpdoc-types | 29 +++++++++++++++++++++++++++++ bin/pre-commit | 6 ++++++ composer.json | 1 + 4 files changed, 53 insertions(+) create mode 100755 bin/check-phpdoc-types diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a37448c4..3690aef19 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,6 +61,23 @@ jobs: FAILURE_ACTION: "${{ matrix.experimental == true }}" run: vendor/bin/phpunit --verbose || $FAILURE_ACTION + phpdoc-types: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib + coverage: none + tools: cs2pr + + - name: Check PHPDoc types + run: ./bin/check-phpdoc-types + php-cs-fixer: runs-on: ubuntu-latest steps: diff --git a/bin/check-phpdoc-types b/bin/check-phpdoc-types new file mode 100755 index 000000000..43809f6b9 --- /dev/null +++ b/bin/check-phpdoc-types @@ -0,0 +1,29 @@ +#!/usr/bin/env php +