diff --git a/.github/workflows/add-strict-types.yml b/.github/workflows/add-strict-types.yml new file mode 100644 index 0000000000..60686ae606 --- /dev/null +++ b/.github/workflows/add-strict-types.yml @@ -0,0 +1,62 @@ +name: Add Strict Types + +on: + pull_request: + branches: + - trunk + +jobs: + add-strict-types: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Add strict types to new PHP files + id: add_strict_types + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git fetch origin +refs/heads/trunk:refs/remotes/origin/trunk --quiet + NEW_PHP_FILES=$(git diff --name-only refs/remotes/origin/trunk HEAD -- '*.php' | xargs -r grep -LE 'declare\( strict_types=1 \)' || true) + if [ -n "$NEW_PHP_FILES" ]; then + for file in $NEW_PHP_FILES; do + if grep -q '^