diff --git a/.github/workflows/downgraded_release.yaml b/.github/workflows/downgraded_release.yaml index 627fbbd4..e1cbb62d 100644 --- a/.github/workflows/downgraded_release.yaml +++ b/.github/workflows/downgraded_release.yaml @@ -2,9 +2,9 @@ name: Downgraded Release on: push: + branches: + - main tags: - # avoid infinite looping, skip tags that ends with ".72" - # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches - '*' jobs: @@ -12,52 +12,74 @@ jobs: runs-on: ubuntu-latest steps: - - uses: "actions/checkout@v3" + - uses: "actions/checkout@v5" with: - token: ${{ secrets.WORKFLOWS_TOKEN }} + token: ${{ secrets.WORKFLOWS_TOKEN || github.token }} - uses: "shivammathur/setup-php@v2" with: - php-version: 8.2 + php-version: 8.4 coverage: none - # invoke patches - run: composer install --ansi - # but no dev packages - - run: composer update --no-dev --ansi - - # get rector to "rector-local" directory, to avoid downgrading itself in the /vendor - - run: mkdir rector-local - - run: composer require rector/rector:^1.1 --working-dir rector-local --ansi + # downgrade /src to PHP 7.4 + - run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi + - run: vendor/bin/ecs check src --fix --ansi - # downgrade to PHP 7.4 - - run: rector-local/vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi + # clear the dev files, the vendor is not shipped as this is a phpstan extension + - run: rm -rf vendor tests ecs.php phpstan.neon phpunit.xml rector.php composer.lock .gitignore .editorconfig full-tool-build.sh - # clear the dev files - - run: rm -rf tests rector-local ecs.php phpstan.neon phpunit.xml .editorconfig + # remove the original .github, to fully override it with the target repository one below + - run: rm -rf .github - # copy PHP 7.2 composer + workflows + # copy PHP 7.4 composer + workflows - run: cp -r build/target-repository/. . - # clear the dev files - - run: rm -rf build full-tool-build.sh rector.php phpstan-for-tests.neon tests + # clear the build files + - run: rm -rf build + + # clone the remote repository, so we can commit on top of its history and push without --force + # inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml + - + uses: "actions/checkout@v5" + with: + repository: anywherephp/type-perfect + path: remote-repository + token: ${{ secrets.WORKFLOWS_TOKEN }} + + # remove remote files, to avoid piling up dead code in remote repository + - run: rm -rf remote-repository/src remote-repository/config remote-repository/.github + + # copy the downgraded code to the remote repository + - run: rsync -a --exclude .git --exclude remote-repository ./ remote-repository/ # setup git user - + working-directory: remote-repository run: | - git config user.email "action@github.com" - git config user.name "GitHub Action" - # publish to the same repository with a new tag - # see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/ + git config user.email "tomas@getrector.org" + git config user.name "rector-bot" + + # publish to remote repository without tag - - name: "Tag Downgraded Code" + name: "Push Downgraded Code - branch" + working-directory: remote-repository + if: "!startsWith(github.ref, 'refs/tags/')" run: | - # separate a "git add" to add untracked (new) files too git add --all - git commit -m "release PHP 7.4 downgraded" + git commit -m "Updated TypePerfect to commit ${{ github.event.after }}" + git push --quiet origin main - # force push tag, so there is only 1 version - git tag "${GITHUB_REF#refs/tags/}" --force - git push origin "${GITHUB_REF#refs/tags/}" --force + # publish to remote repository with tag + - + name: "Push Downgraded Code - tag" + working-directory: remote-repository + if: "startsWith(github.ref, 'refs/tags/')" + run: | + git add --all + git commit --allow-empty -m "TypePerfect ${GITHUB_REF#refs/tags/}" + git push --quiet origin main + git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}" + git push --quiet origin "${GITHUB_REF#refs/tags/}" diff --git a/build/target-repository/.github/FUNDING.yml b/build/target-repository/.github/FUNDING.yml deleted file mode 100644 index f797866a..00000000 --- a/build/target-repository/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms -github: tomasvotruba -custom: https://www.paypal.me/rectorphp diff --git a/build/target-repository/.github/workflows/auto_closer.yaml b/build/target-repository/.github/workflows/auto_closer.yaml new file mode 100644 index 00000000..06400c05 --- /dev/null +++ b/build/target-repository/.github/workflows/auto_closer.yaml @@ -0,0 +1,23 @@ +name: Auto Closer PR + +on: + pull_request_target: + types: [opened] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: superbrothers/close-pull-request@v3 + with: + # Optional. Post a issue comment just before closing a pull request. + comment: | + Hi, thank you for your contribution. + + Unfortunately, this repository is read-only. It's a build of the main repository. + + We'd like to kindly ask you to move the contribution there - https://github.com/rectorphp/type-perfect. + + We'll check it, review it and give you feed back right way. + + Thank you. diff --git a/build/target-repository/.github/workflows/standalone_install.yaml b/build/target-repository/.github/workflows/standalone_install.yaml deleted file mode 100644 index 7a27d0aa..00000000 --- a/build/target-repository/.github/workflows/standalone_install.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Standalone Install - -on: [pull_request, push] - -jobs: - standalone_install: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php_version: ['7.4', '8.0', '8.1'] - - steps: - # prepare empty composer.json that allows the phpstan extension plugin - - run: composer init --name just/for-test --quiet - - run: composer config --no-plugins allow-plugins.phpstan/extension-installer true - - - run: composer require phpstan/phpstan phpstan/extension-installer --dev - - run: composer require rector/type-perfect:dev-main --dev - - diff --git a/build/target-repository/README.md b/build/target-repository/README.md new file mode 100644 index 00000000..3fd7b37f --- /dev/null +++ b/build/target-repository/README.md @@ -0,0 +1,3 @@ +# Type Perfect - Anywhere version + +See original repository for more details: https://github.com/rectorphp/type-perfect diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index 163eaeba..8d106402 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -1,8 +1,8 @@ { - "name": "rector/type-perfect", + "name": "anywherephp/type-perfect", "type": "phpstan-extension", "description": "Next level type declaration checks", - "license": "MIT", + "license": "proprietary", "require": { "php": "^7.4|^8.0", "phpstan/phpstan": "^2.1.14", diff --git a/build/target-repository/phpstan-for-tests.neon b/build/target-repository/phpstan-for-tests.neon deleted file mode 100644 index 421c39ad..00000000 --- a/build/target-repository/phpstan-for-tests.neon +++ /dev/null @@ -1,9 +0,0 @@ -# this config is only for tests, it verifies all the rules are runnable -includes: - - vendor/rector/type-perfect/config/extension.neon - -parameters: - level: 4 - - ignoreErrors: - - '#Class method "getName\(\)" is never used#' diff --git a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php index 6835c5d5..8f7390b5 100644 --- a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php +++ b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php @@ -15,7 +15,7 @@ use Rector\TypePerfect\Printer\CollectorMetadataPrinter; /** - * @implements Collector + * @implements Collector */ final readonly class PublicClassMethodParamTypesCollector implements Collector { diff --git a/src/Collector/MethodCall/MethodCallArgTypesCollector.php b/src/Collector/MethodCall/MethodCallArgTypesCollector.php index 645acc2e..341d6bc6 100644 --- a/src/Collector/MethodCall/MethodCallArgTypesCollector.php +++ b/src/Collector/MethodCall/MethodCallArgTypesCollector.php @@ -16,7 +16,7 @@ use Rector\TypePerfect\ValueObject\MethodCallReference; /** - * @implements Collector|null> + * @implements Collector */ final readonly class MethodCallArgTypesCollector implements Collector {