Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/symfony-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
dependencies: [highest]
allowed-to-fail: [false]
symfony-require: ['']
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
52 changes: 25 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I strict on ^3.1.2 or keep it more flexible in ^3.0?

the problem detected was more related with symfony-cmf then page bundle.

"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"
},
Expand All @@ -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"
Expand Down
203 changes: 180 additions & 23 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,24 +1,181 @@
parameters:
ignoreErrors:
- # Disallow VariableMethodCallRule and VariablePropertyFetchRule
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I create another file to not mix with this one?

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\\<string, bool\\|string\\>\\|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\\<string, bool\\|string\\>\\|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\\<string, bool\\|string\\>\\|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\\<string, bool\\|string\\>\\|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<string, bool|string>|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<string, bool|string>|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<string, bool|string>|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<string, bool|string>|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.
Copy link
Contributor Author

@eerison eerison Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know if it could be related with phpstan/phpstan-symfony#322

like we are doing on https://github.com/sonata-project/SonataPageBundle/blob/4.x/phpstan-baseline.neon#L22

But I would prefer ignore those errors besides add workaround for code that never going to be used. like this getType as null.

we add checks to verify if it's null or not, But it is a field that should be filled, otherwise some places wont work, like phpstan says.

if this field is null, the code will break for sure.

My suggestion is, ignore those errors and create a issue to solve this mess, it will make our life easier.

and I remember it was painful for this PR: #1522

let me know what you think and I could open a issue.

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
Loading
Loading