diff --git a/.bc-exclude.php b/.bc-exclude.php new file mode 100644 index 000000000..5e15ac79a --- /dev/null +++ b/.bc-exclude.php @@ -0,0 +1,13 @@ + [ + '**/src/DevOps/**', + ], + 'errors' => [ + // vendor false positive + \preg_quote('An enum expression Monolog\Level::Debug is not supported in class Monolog\Handler\AbstractHandler'), + // Storefront package is not installed + \preg_quote('"Shopware\Storefront\Framework\Cookie\CookieProviderInterface" could not be found in the located source'), + ], +]; diff --git a/.github/actions/setup-paypal/action.yml b/.github/actions/setup-paypal/action.yml index 31d94ccf4..39a562881 100644 --- a/.github/actions/setup-paypal/action.yml +++ b/.github/actions/setup-paypal/action.yml @@ -123,7 +123,7 @@ runs: fi echo "deps=$(echo $DEPS | jq -c .)" >> "$GITHUB_OUTPUT" echo "repos=$(echo $REPOS | jq -c .)" >> "$GITHUB_OUTPUT" - - uses: shopware/github-actions/setup-extension@main + - uses: shopware/github-actions/setup-extension@b1d0a9fddcf38cd550f328ea00e1beb7536fa494 with: extensionName: ${{ github.event.repository.name }} mysqlVersion: ${{ inputs.mysql-version }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8814d1894..1176b4711 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -65,6 +65,26 @@ jobs: - name: Run ecs run: composer -d custom/plugins/${{ github.event.repository.name }} run ecs + bc-check: + runs-on: ubuntu-latest + steps: + - name: Checkout SwagPayPal + uses: actions/checkout@v4 + with: + path: custom/plugins/${{ github.event.repository.name }} + + - name: Setup SwagPayPal + uses: ./custom/plugins/SwagPayPal/.github/actions/setup-paypal + + - name: Fetch SwagPayPal + working-directory: custom/plugins/${{ github.event.repository.name }} + run: git fetch --unshallow origin + + - name: Run bc-check + working-directory: custom/plugins/${{ github.event.repository.name }} + if: github.event_name == 'pull_request' && !contains(github.base_ref, '/feature/') + run: composer bc-check -- --format=github-actions --from="origin/${{ github.base_ref }}" + validate-openapi-typescript: runs-on: ubuntu-latest steps: diff --git a/composer.json b/composer.json index 368e40465..b33a9371b 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,6 @@ "require": { "shopware/core": "~6.5.5@dev" }, - "require-dev": { - "rector/rector": "^0.18.3" - }, "extra": { "shopware-plugin-class": "Swag\\PayPal\\SwagPayPal", "copyright": "(c) by shopware AG", @@ -69,6 +66,11 @@ "openapi:generate": [ "../../../bin/console swag:paypal:openapi:generate", "npm run openapi-types --prefix src/Resources/app/administration" + ], + "bc-check": [ + "php ../../../vendor-bin/roave-backward-compatibility-check/bin/verify-version.php", + "@putenv TMPDIR=./..", + "../../../vendor/bin/roave-backward-compatibility-check" ] }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 79f7c02ab..7d5064513 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -18,7 +18,6 @@ parameters: - tests excludePaths: - src/Resources - - src/DevOps/Rector bootstrapFiles: - tests/PHPStanBootstrap.php diff --git a/src/DevOps/Rector/ClassCheckoutPackageRector.php b/src/DevOps/Rector/ClassCheckoutPackageRector.php deleted file mode 100644 index 2daa0ba4b..000000000 --- a/src/DevOps/Rector/ClassCheckoutPackageRector.php +++ /dev/null @@ -1,76 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Swag\PayPal\DevOps\Rector; - -use PhpParser\Node; -use PhpParser\Node\AttributeGroup; -use PhpParser\Node\Stmt\ClassLike; -use Rector\Core\Rector\AbstractRector; -use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; -use Shopware\Core\Framework\Log\Package; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; - -#[Package('checkout')] -class ClassCheckoutPackageRector extends AbstractRector -{ - private const AREA_CHECKOUT = 'checkout'; - - public function __construct(private readonly PhpAttributeGroupFactory $phpAttributeGroupFactory) - { - } - - public function getNodeTypes(): array - { - return [ClassLike::class]; - } - - public function refactor(Node $node): ?Node - { - if (!$node instanceof ClassLike) { - return null; - } - - if ($this->hasPackageAnnotation($node)) { - return null; - } - - $node->attrGroups[] = $this->phpAttributeGroupFactory->createFromClassWithItems(Package::class, [self::AREA_CHECKOUT]); - - return $node; - } - - public function getRuleDefinition(): RuleDefinition - { - return new RuleDefinition( - 'Adds a #[Package(\'checkout\')] attribute to all php classes.', - [ - new CodeSample( - // code before - ' -class Foo{}', - - // code after - ' -#[Package(\'checkout\')] -class Foo{}' - ), - ] - ); - } - - private function hasPackageAnnotation(ClassLike $class): bool - { - $names = \array_map( - fn (AttributeGroup $group) => $group->attrs[0]->name->toString(), - $class->attrGroups - ); - - return \in_array(Package::class, $names, true) || \in_array('Package', $names, true); - } -}