diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 9e74c9b7..a8cac54c 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -22,6 +22,11 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Set COMPOSER_ROOT_VERSION environment variable + uses: ergebnis/composer-root-version-action@0.2.0 + with: + branch: master + - name: PHPStan uses: docker://oskarstark/phpstan-ga env: @@ -37,8 +42,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Allow cyclic dependency between block-bundle and admin-bundle - run: sed --in-place "s/\"dev-master\":/\"dev-${GITHUB_SHA}\":/" composer.json + - name: Set COMPOSER_ROOT_VERSION environment variable + uses: ergebnis/composer-root-version-action@0.2.0 + with: + branch: master - name: Psalm uses: docker://vimeo/psalm-github-actions diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 49d323dd..522b5654 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -81,8 +81,10 @@ jobs: if: matrix.variant != 'normal' run: composer require ${{ matrix.variant }} --no-update - - name: Allow cyclic dependency between block-bundle and admin-bundle - run: sed --in-place "s/\"dev-master\":/\"dev-${GITHUB_SHA}\":/" composer.json + - name: Set COMPOSER_ROOT_VERSION environment variable + uses: ergebnis/composer-root-version-action@0.2.0 + with: + branch: master - name: Install Composer dependencies (lowest) if: matrix.dependencies == 'lowest' diff --git a/composer.json b/composer.json index 1be8ddd9..8818918c 100644 --- a/composer.json +++ b/composer.json @@ -49,10 +49,12 @@ "knplabs/knp-menu": "^3.1", "knplabs/knp-menu-bundle": "^3.0", "matthiasnoback/symfony-dependency-injection-test": "^4.1", + "psalm/plugin-symfony": "^1.4", "sonata-project/admin-bundle": "^3.28", "symfony/debug": "^4.4", - "symfony/phpunit-bridge": "^5.1.1", - "symfony/stopwatch": "^4.4 || ^5.1" + "symfony/phpunit-bridge": "^5.1.4", + "symfony/stopwatch": "^4.4 || ^5.1", + "vimeo/psalm": "^3.13.1" }, "suggest": { "knplabs/knp-menu-bundle": "In order to use MenuBlockService." diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..f21263d0 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,15 @@ +parameters: + level: 0 + + paths: + - src + + bootstrapFiles: + - vendor/autoload.php + + excludes_analyse: + - src/Annotation/Block.php + - src/Meta/Metadata.php + - src/Meta/MetadataInterface.php + - src/Test/AbstractBlockServiceTestCase.php + - src/Test/BlockServiceTestCase.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..f68e3c1c --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,62 @@ + + + + + MetadataProcessorInterface + + + + + $blockContext + + + + + $context + + + + + $formMapper + + + + + $formMapper + + + + + $formMapper + + + + + $formMapper + + + + + $formMapper + + + + + $banana + + + + + CoreMetadataInterface + + + + + + + + + BlockServiceTestCase + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..d43e3432 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/Block/Service/CustomBlockServiceTest.php b/tests/Block/Service/CustomBlockServiceTest.php index 812e4ced..6a438b98 100644 --- a/tests/Block/Service/CustomBlockServiceTest.php +++ b/tests/Block/Service/CustomBlockServiceTest.php @@ -15,21 +15,24 @@ use Sonata\BlockBundle\Block\Service\AbstractBlockService; use Sonata\BlockBundle\Test\BlockServiceTestCase; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; /** * @author Javier Spagnoletti */ final class CustomBlockServiceTest extends BlockServiceTestCase { + use ExpectDeprecationTrait; + /** * NEXT_MAJOR: Remove this test. * * @group legacy - * - * @expectedDeprecation Passing string as argument 1 to Sonata\BlockBundle\Block\Service\AbstractBlockService@anonymous::__construct() is deprecated since sonata-project/block-bundle 3.16 and will throw a \TypeError as of 4.0. You must pass an instance of Twig\Environment instead. */ public function testArgumentDeprecation() { + $this->expectDeprecation('Passing string as argument 1 to Sonata\BlockBundle\Block\Service\AbstractBlockService@anonymous::__construct() is deprecated since sonata-project/block-bundle 3.16 and will throw a \TypeError as of 4.0. You must pass an instance of Twig\Environment instead.'); + new class('block') extends AbstractBlockService { }; }