sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Symfony 5.2 Sonata Admin (dev-master) throwing an Exception during composer update due to missing iterable type hint #6971

Closed DavidGarciaCat closed 3 years ago

DavidGarciaCat commented 3 years ago

Environment

Sonata packages

$ composer show | grep sonata
sonata-project/admin-bundle              dev-master 06877d7
sonata-project/block-bundle              4.5.2
sonata-project/cache                     2.1.1
sonata-project/doctrine-extensions       1.12.0
sonata-project/doctrine-orm-admin-bundle dev-master 29aeea8
sonata-project/exporter                  2.6.1
sonata-project/form-extensions           1.9.0
sonata-project/twig-extensions           1.5.1

Symfony packages

$ composer show | grep 'symfony/*'
symfony/amqp-messenger                   v5.2.4
symfony/asset                            v5.2.4
symfony/browser-kit                      v5.2.4
symfony/cache                            v5.2.4
symfony/cache-contracts                  v2.2.0
symfony/config                           v5.2.4
symfony/console                          v5.2.5
symfony/css-selector                     v5.2.4
symfony/debug-bundle                     v5.2.4
symfony/dependency-injection             v5.2.5
symfony/deprecation-contracts            v2.2.0
symfony/doctrine-bridge                  v5.2.5
symfony/doctrine-messenger               v5.2.5
symfony/dom-crawler                      v5.2.4
symfony/dotenv                           v5.2.4
symfony/error-handler                    v5.2.4
symfony/event-dispatcher                 v5.2.4
symfony/event-dispatcher-contracts       v2.2.0
symfony/expression-language              v5.2.4
symfony/filesystem                       v5.2.4
symfony/finder                           v5.2.4
symfony/flex                             v1.12.2
symfony/form                             v5.2.5
symfony/framework-bundle                 v5.2.5
symfony/http-client-contracts            v2.3.1
symfony/http-foundation                  v5.2.4
symfony/http-kernel                      v5.2.5
symfony/intl                             v5.2.4
symfony/mailer                           v5.2.5
symfony/maker-bundle                     v1.30.2
symfony/messenger                        v5.2.5
symfony/mime                             v5.2.5
symfony/monolog-bridge                   v5.2.5
symfony/monolog-bundle                   v3.6.0
symfony/options-resolver                 v5.2.4
symfony/orm-pack                         v2.1.0
symfony/phpunit-bridge                   v5.2.4
symfony/polyfill-intl-grapheme           v1.22.1
symfony/polyfill-intl-icu                v1.22.1
symfony/polyfill-intl-idn                v1.22.1
symfony/polyfill-intl-normalizer         v1.22.1
symfony/polyfill-mbstring                v1.22.1
symfony/polyfill-php72                   v1.22.1
symfony/polyfill-php73                   v1.22.1
symfony/polyfill-php80                   v1.22.1
symfony/process                          v5.2.4
symfony/property-access                  v5.2.4
symfony/property-info                    v5.2.4
symfony/proxy-manager-bridge             v5.2.4
symfony/redis-messenger                  v5.2.4
symfony/routing                          v5.2.4
symfony/security-acl                     v3.1.1
symfony/security-bundle                  v5.2.5
symfony/security-core                    v5.2.5
symfony/security-csrf                    v5.2.4
symfony/security-guard                   v5.2.4
symfony/security-http                    v5.2.5
symfony/service-contracts                v2.2.0
symfony/stopwatch                        v5.2.4
symfony/string                           v5.2.4
symfony/templating                       v5.2.4
symfony/translation                      v5.2.5
symfony/translation-contracts            v2.3.0
symfony/twig-bridge                      v5.2.5
symfony/twig-bundle                      v5.2.4
symfony/validator                        v5.2.5
symfony/var-dumper                       v5.2.5
symfony/var-exporter                     v5.2.4
symfony/web-profiler-bundle              v5.2.4
symfony/yaml                             v5.2.5

PHP version

$ php -v
PHP 8.0.3 (cli) (built: Mar  4 2021 05:33:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

Subject

The following files implement (override) the public static function getExtendedTypes() method, which in the latest versions of Symfony seems to require the iterable type hint: public static function getExtendedTypes(): iterable

Minimal repository with the bug

Please check my notes above

Steps to reproduce

Just install the Symfony packages tagging ^5.2 and the latest version of Sonata Admin from the dev-master branch as there isn't yet a tagged version.

Expected results

Not getting an exception during the composer install or composer update commands :-)

Actual results

Exception referring the Sonata method must be implemented according to the extended Symfont class, which requires the iterable type hint.

franmomu commented 3 years ago

Hi @DavidGarciaCat, looks like you're using the latest changes of the stable branch instead of https://github.com/sonata-project/SonataAdminBundle/tree/master.

Based on:

sonata-project/admin-bundle              dev-master 06877d7
sonata-project/block-bundle              4.5.2
sonata-project/cache                     2.1.1
sonata-project/doctrine-extensions       1.12.0
sonata-project/doctrine-orm-admin-bundle dev-master 29aeea8
sonata-project/exporter                  2.6.1
sonata-project/form-extensions           1.9.0
sonata-project/twig-extensions           1.5.1

The commit of sonata-project/admin-bundle you're using is: https://github.com/sonata-project/SonataAdminBundle/commits/06877d7 and for sonata-project/doctrine-orm-admin-bundle: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/commit/29aeea8

So I guess there is something weird configured in your composer.json.

If you see for example this file has the return type declaration in master:

https://github.com/sonata-project/SonataAdminBundle/blob/8b6729bcad6cc864f5d08ef15f2e2be6ec5fba5a/src/Form/Extension/Field/Type/FormTypeFieldExtension.php#L166

DavidGarciaCat commented 3 years ago

I will take a look now and update the composer.json even setting another commit if needed.

DavidGarciaCat commented 3 years ago

It looks like the commit hash was wrong. After updating it and applying a few adjustments to some Admin classes, it seems to work. Thank you for your time!