diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 35d8a782a..d7f403164 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,7 +29,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 @@ -53,7 +53,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2, composer-normalize:2 env: diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index f72cb3b9f..74d2d6969 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -29,7 +29,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 @@ -53,7 +53,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 diff --git a/.github/workflows/symfony-lint.yaml b/.github/workflows/symfony-lint.yaml index d8df070bf..ea791faf0 100644 --- a/.github/workflows/symfony-lint.yaml +++ b/.github/workflows/symfony-lint.yaml @@ -29,7 +29,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 @@ -53,7 +53,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 @@ -77,7 +77,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 @@ -101,7 +101,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c044a58b4..95770eae3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,6 +33,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' dependencies: [highest] allowed-to-fail: [false] symfony-require: [''] @@ -42,21 +43,21 @@ jobs: dependencies: lowest allowed-to-fail: false variant: normal - - php-version: '8.4' + - php-version: '8.5' dependencies: highest allowed-to-fail: false symfony-require: 6.4.* variant: symfony/symfony:"6.4.*" - - php-version: '8.4' + - php-version: '8.5' dependencies: highest allowed-to-fail: false - symfony-require: 7.1.* - variant: symfony/symfony:"7.1.*" - - php-version: '8.4' + symfony-require: 7.3.* + variant: symfony/symfony:"7.3.*" + - php-version: '8.5' dependencies: highest allowed-to-fail: false - symfony-require: 7.2.* - variant: symfony/symfony:"7.2.*" + symfony-require: 7.4.* + variant: symfony/symfony:"7.4.*" steps: - name: Checkout diff --git a/.gitignore b/.gitignore index 91fe593c7..3a4523118 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,8 @@ composer.lock phpunit.xml phpstan.neon /.phpunit.result.cache +tests/App/config/reference.php /docs/_build/ /drivers /tests/App/public/bundles -tests/App/config/reference.php npm-debug.log diff --git a/composer.json b/composer.json index 6a563a103..6ecf5da98 100644 --- a/composer.json +++ b/composer.json @@ -33,26 +33,26 @@ "sonata-project/seo-bundle": "^3.4", "sonata-project/twig-extensions": "^1.3 || ^2.0", "symfony-cmf/routing-bundle": "^2.1 || ^3.0", - "symfony/config": "^6.4 || ^7.1", - "symfony/console": "^6.4 || ^7.1", - "symfony/dependency-injection": "^6.4 || ^7.1", + "symfony/config": "^6.4 || ^7.3 || ^8.0", + "symfony/console": "^6.4 || ^7.3 || ^8.0", + "symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0", "symfony/deprecation-contracts": "^3.0.0", - "symfony/form": "^6.4 || ^7.1", - "symfony/framework-bundle": "^6.4 || ^7.1", - "symfony/http-foundation": "^6.4 || ^7.1", - "symfony/http-kernel": "^6.4 || ^7.1", - "symfony/intl": "^6.4 || ^7.1", - "symfony/options-resolver": "^6.4 || ^7.1", - "symfony/process": "^6.4 || ^7.1", - "symfony/property-access": "^6.4 || ^7.1", - "symfony/property-info": "^6.4 || ^7.1", - "symfony/routing": "^6.4 || ^7.1", - "symfony/runtime": "^6.4 || ^7.1", - "symfony/security-core": "^6.4 || ^7.1", - "symfony/security-http": "^6.4 || ^7.1", - "symfony/serializer": "^6.4 || ^7.1", - "symfony/string": "^6.4 || ^7.1", - "symfony/validator": "^6.4 || ^7.1", + "symfony/form": "^6.4 || ^7.3 || ^8.0", + "symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0", + "symfony/http-foundation": "^6.4 || ^7.3 || ^8.0", + "symfony/http-kernel": "^6.4 || ^7.3 || ^8.0", + "symfony/intl": "^6.4 || ^7.3 || ^8.0", + "symfony/options-resolver": "^6.4 || ^7.3 || ^8.0", + "symfony/process": "^6.4 || ^7.3 || ^8.0", + "symfony/property-access": "^6.4 || ^7.3 || ^8.0", + "symfony/property-info": "^6.4 || ^7.3 || ^8.0", + "symfony/routing": "^6.4 || ^7.3 || ^8.0", + "symfony/runtime": "^6.4 || ^7.3 || ^8.0", + "symfony/security-core": "^6.4 || ^7.3 || ^8.0", + "symfony/security-http": "^6.4 || ^7.3 || ^8.0", + "symfony/serializer": "^6.4 || ^7.3 || ^8.0", + "symfony/string": "^6.4 || ^7.3 || ^8.0", + "symfony/validator": "^6.4 || ^7.3 || ^8.0", "twig/string-extra": "^3.0", "twig/twig": "^3.0" }, @@ -71,17 +71,15 @@ "psalm/plugin-phpunit": "^0.19", "psalm/plugin-symfony": "^5.0", "rector/rector": "^1.1 || ^2.0", - "symfony/browser-kit": "^6.4 || ^7.1", - "symfony/css-selector": "^6.4 || ^7.1", - "symfony/filesystem": "^6.4 || ^7.1", - "symfony/panther": "^2.2", - "symfony/yaml": "^6.4 || ^7.1", - "vimeo/psalm": "^5.0 || ^6.10" + "symfony/browser-kit": "^6.4 || ^7.3 || ^8.0", + "symfony/css-selector": "^6.4 || ^7.3 || ^8.0", + "symfony/filesystem": "^6.4 || ^7.3 || ^8.0", + "symfony/panther": "^2.4", + "symfony/yaml": "^6.4 || ^7.3 || ^8.0" }, "conflict": { "doctrine/dbal": "<3.4", - "doctrine/orm": "<2.14", - "symfony/dom-crawler": ">7.4" + "doctrine/orm": "<2.14" }, "suggest": { "twig/extra-bundle": "Auto configures the Twig Intl extension" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index bdff63a9f..1a6d70180 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,24 +1,181 @@ parameters: - ignoreErrors: - - # Disallow VariableMethodCallRule and VariablePropertyFetchRule - message: '#^Variable (method call|property access)#' - path: . - - # https://github.com/phpstan/phpstan-strict-rules/issues/130 - message: '#^Call to static method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#' - path: tests/ - - # https://github.com/phpstan/phpstan-symfony/issues/322 - message: "#^Cannot call method getId\\(\\) on array\\\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\.$#" - count: 1 - path: src/Form/Type/PageSelectorType.php - - # https://github.com/phpstan/phpstan-symfony/issues/322 - message: "#^Only booleans are allowed in &&, array\\\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given on the right side\\.$#" - count: 1 - path: src/Form/Type/PageSelectorType.php - - # https://github.com/phpstan/phpstan-symfony/issues/322 - message: "#^Parameter \\#2 \\$currentPage of method Sonata\\\\PageBundle\\\\Form\\\\Type\\\\PageSelectorType\\:\\:childWalker\\(\\) expects Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|null, array\\\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given\\.$#" - count: 1 - path: src/Form/Type/PageSelectorType.php - - # https://github.com/phpstan/phpstan-symfony/issues/322 - message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given\\.$#" - count: 1 - path: src/Form/Type/PageSelectorType.php + ignoreErrors: + - + rawMessage: Possibly invalid array key type int|string|null. + identifier: offsetAccess.invalidOffset + count: 1 + path: src/Entity/BlockInteractor.php + + - + rawMessage: Variable method call on Sonata\PageBundle\Model\PageInterface. + identifier: method.dynamicName + count: 1 + path: src/Entity/PageManager.php + + - + rawMessage: 'Cannot call method getId() on array|Sonata\PageBundle\Model\PageInterface|Sonata\PageBundle\Model\SiteInterface.' + identifier: method.nonObject + count: 1 + path: src/Form/Type/PageSelectorType.php + + - + rawMessage: 'Only booleans are allowed in &&, array|Sonata\PageBundle\Model\PageInterface|Sonata\PageBundle\Model\SiteInterface|null given on the right side.' + identifier: booleanAnd.rightNotBoolean + count: 1 + path: src/Form/Type/PageSelectorType.php + + - + rawMessage: 'Parameter #2 $currentPage of method Sonata\PageBundle\Form\Type\PageSelectorType::childWalker() expects Sonata\PageBundle\Model\PageInterface|null, array|Sonata\PageBundle\Model\PageInterface|Sonata\PageBundle\Model\SiteInterface|null given.' + identifier: argument.type + count: 1 + path: src/Form/Type/PageSelectorType.php + + - + rawMessage: 'Parameter #2 ...$arrays of function array_merge expects array, array|Sonata\PageBundle\Model\PageInterface|Sonata\PageBundle\Model\SiteInterface|null given.' + identifier: argument.type + count: 1 + path: src/Form/Type/PageSelectorType.php + + - + rawMessage: Possibly invalid array key type string|null. + identifier: offsetAccess.invalidOffset + count: 2 + path: src/Page/PageServiceManager.php + + - + rawMessage: Access to constant BUILTIN_TYPE_BOOL on an unknown class Symfony\Component\PropertyInfo\Type. + identifier: class.notFound + count: 1 + path: src/Serializer/BlockTypeExtractor.php + + - + rawMessage: Access to constant BUILTIN_TYPE_INT on an unknown class Symfony\Component\PropertyInfo\Type. + identifier: class.notFound + count: 2 + path: src/Serializer/BlockTypeExtractor.php + + - + rawMessage: Access to constant BUILTIN_TYPE_STRING on an unknown class Symfony\Component\PropertyInfo\Type. + identifier: class.notFound + count: 3 + path: src/Serializer/BlockTypeExtractor.php + + - + rawMessage: Instantiated class Symfony\Component\PropertyInfo\Type not found. + identifier: class.notFound + count: 6 + path: src/Serializer/BlockTypeExtractor.php + + - + rawMessage: 'Method Sonata\PageBundle\Serializer\BlockTypeExtractor::getTypes() has invalid return type Symfony\Component\PropertyInfo\Type.' + identifier: class.notFound + count: 1 + path: src/Serializer/BlockTypeExtractor.php + + - + rawMessage: Access to constant BUILTIN_TYPE_OBJECT on an unknown class Symfony\Component\PropertyInfo\Type. + identifier: class.notFound + count: 5 + path: src/Serializer/InterfaceTypeExtractor.php + + - + rawMessage: Instantiated class Symfony\Component\PropertyInfo\Type not found. + identifier: class.notFound + count: 5 + path: src/Serializer/InterfaceTypeExtractor.php + + - + rawMessage: 'Method Sonata\PageBundle\Serializer\InterfaceTypeExtractor::getBlockType() has invalid return type Symfony\Component\PropertyInfo\Type.' + identifier: class.notFound + count: 1 + path: src/Serializer/InterfaceTypeExtractor.php + + - + rawMessage: 'Method Sonata\PageBundle\Serializer\InterfaceTypeExtractor::getPageType() has invalid return type Symfony\Component\PropertyInfo\Type.' + identifier: class.notFound + count: 1 + path: src/Serializer/InterfaceTypeExtractor.php + + - + rawMessage: 'Method Sonata\PageBundle\Serializer\InterfaceTypeExtractor::getTypes() has invalid return type Symfony\Component\PropertyInfo\Type.' + identifier: class.notFound + count: 1 + path: src/Serializer/InterfaceTypeExtractor.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Symfony\\Component\\HttpFoundation\\Response'' and Symfony\Component\HttpFoundation\Response will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Block/ContainerBlockServiceTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Symfony\\Component\\HttpFoundation\\Response'' and Symfony\Component\HttpFoundation\Response will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Block/PageListBlockServiceTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Sonata\\PageBundle\\Model\\PageInterface'' and Sonata\PageBundle\Model\PageInterface will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 4 + path: tests/CmsManager/CmsPageManagerTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with arguments ''Sonata\\PageBundle\\Model\\PageBlockInterface'', Sonata\PageBundle\Model\PageBlockInterface and ''should be a block'' will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/CmsManager/CmsPageManagerTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Functional/BasePantherTestCase.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Sonata\\PageBundle\\Model\\PageBlockInterface'' and Sonata\PageBundle\Model\PageBlockInterface will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Model/BlockInteractorTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Sonata\\PageBundle\\Model\\SnapshotPageProxyInterface'' and Sonata\PageBundle\Model\SnapshotPageProxy will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Model/SnapshotPageProxyTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with arguments ''Symfony\\Component\\HttpFoundation\\Response'', Symfony\Component\HttpFoundation\Response and ''Should return a…'' will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/Page/Service/BasePageServiceTest.php + + - + rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertInstanceOf() with ''Symfony\\Component\\HttpFoundation\\Request'' and Symfony\Component\HttpFoundation\Request will always evaluate to true.' + identifier: staticMethod.alreadyNarrowedType + count: 4 + path: tests/Request/RequestFactoryTest.php + + - + rawMessage: Variable method call on object. + identifier: method.dynamicName + count: 1 + path: tests/Site/HostPathSiteSelectorTest.php + + - + rawMessage: Variable property access on object. + identifier: property.dynamicName + count: 2 + path: tests/Site/HostPathSiteSelectorTest.php + + - + rawMessage: Variable method call on object. + identifier: method.dynamicName + count: 1 + path: tests/Site/HostSiteSelectorTest.php + + - + rawMessage: Variable property access on object. + identifier: property.dynamicName + count: 2 + path: tests/Site/HostSiteSelectorTest.php diff --git a/src/Resources/config/routing/exceptions.php b/src/Resources/config/routing/exceptions.php index 9776829e2..b9489698a 100644 --- a/src/Resources/config/routing/exceptions.php +++ b/src/Resources/config/routing/exceptions.php @@ -17,6 +17,7 @@ return static function (RoutingConfigurator $routes) { foreach (debug_backtrace() as $trace) { if (isset($trace['object'], $trace['args']) + && class_exists(XmlFileLoader::class) && $trace['object'] instanceof XmlFileLoader && $trace['args'][0] === __DIR__.'/exceptions.php' && $trace['args'][3] === __DIR__.'/exceptions.xml' diff --git a/src/Serializer/BlockTypeExtractor.php b/src/Serializer/BlockTypeExtractor.php index 49734ec05..afd921c67 100644 --- a/src/Serializer/BlockTypeExtractor.php +++ b/src/Serializer/BlockTypeExtractor.php @@ -40,6 +40,8 @@ public function __construct( * @param array $context * * @return LegacyType[]|null + * + * NEXT_MAJOR: Remove this method */ public function getTypes(string $class, string $property, array $context = []): ?array { diff --git a/src/Serializer/InterfaceTypeExtractor.php b/src/Serializer/InterfaceTypeExtractor.php index dec9b6027..412796363 100644 --- a/src/Serializer/InterfaceTypeExtractor.php +++ b/src/Serializer/InterfaceTypeExtractor.php @@ -38,6 +38,8 @@ public function __construct( * @param array $context * * @return LegacyType[]|null + * + * NEXT_MAJOR: Remove this method */ public function getTypes(string $class, string $property, array $context = []): ?array {