SonataPageBundle: Declaration of SharedBlockBlockService::validateBlock must be compatible with AbstractAdminBlockService::validateBlock

#829 Declaration of SharedBlockBlockService::validateBlock must be compatible with AbstractAdminBlockService::validateBlock

Environment

Sonata packages

sonata-project/admin-bundle              3.63.0 3.70.1 The missing Symfony Admin Generator
sonata-project/block-bundle              3.20.0 3.20.0 Symfony SonataBlockBundle
sonata-project/cache                     1.1.1  2.0.1  Cache library
sonata-project/cache-bundle              2.4.2  3.2.1  This bundle provides caching services
sonata-project/classification-bundle     3.12.1 3.12.1 Symfony SonataClassificationBundle
sonata-project/core-bundle               3.20.0 3.20.0 Symfony SonataCoreBundle (abandoned)
sonata-project/datagrid-bundle           2.5.0  3.2.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.6.0  1.6.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.18.0 3.18.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.2.0  2.2.0  Lightweight Exporter library
sonata-project/form-extensions           0.1.2  1.4.0  Symfony form extensions
sonata-project/formatter-bundle          4.2.0  4.2.0  Symfony SonataFormatterBundle
sonata-project/intl-bundle               2.7.0  2.7.0  Symfony SonataIntlBundle
sonata-project/media-bundle              3.25.0 3.25.0 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.4.0  3.7.0  Symfony SonataNotificationBundle
sonata-project/page-bundle               3.17.3 3.17.3 This bundle provides a Site and Page management through container and block services
sonata-project/seo-bundle                2.10.0 2.10.0 Symfony SonataSeoBundle
sonata-project/translation-bundle        2.5.0  2.5.0  SonataTranslationBundle
sonata-project/twig-extensions           0.1.1  1.3.0  Sonata twig extensions
sonata-project/user-bundle               4.5.3  4.5.3  Symfony SonataUserBundle

Symfony packages

symfony/asset                      v4.4.10 v4.4.10 Symfony Asset Component
symfony/browser-kit                v4.4.10 v4.4.10 Symfony BrowserKit Component
symfony/cache                      v4.4.10 v4.4.10 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v1.1.7  v1.1.7  Generic abstractions related to caching
symfony/class-loader               v3.4.42 v3.4.42 Symfony ClassLoader Component
symfony/config                     v4.4.10 v4.4.10 Symfony Config Component
symfony/console                    v4.4.10 v4.4.10 Symfony Console Component
symfony/css-selector               v4.4.10 v4.4.10 Symfony CssSelector Component
symfony/debug                      v4.4.10 v4.4.10 Symfony Debug Component
symfony/debug-bundle               v4.4.10 v4.4.10 Symfony DebugBundle
symfony/dependency-injection       v4.4.10 v4.4.10 Symfony DependencyInjection Component
symfony/doctrine-bridge            v4.4.10 v4.4.10 Symfony Doctrine Bridge
symfony/dom-crawler                v4.4.10 v4.4.10 Symfony DomCrawler Component
symfony/dotenv                     v4.4.10 v4.4.10 Registers environment variables from a .env file
symfony/error-handler              v4.4.10 v4.4.10 Symfony ErrorHandler Component
symfony/event-dispatcher           v4.4.10 v4.4.10 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.7  v1.1.7  Generic abstractions related to dispatching event
symfony/expression-language        v4.4.10 v4.4.10 Symfony ExpressionLanguage Component
symfony/filesystem                 v4.4.10 v4.4.10 Symfony Filesystem Component
symfony/finder                     v4.4.10 v4.4.10 Symfony Finder Component
symfony/flex                       v1.8.4  v1.8.4  Composer plugin for Symfony
symfony/form                       v4.4.10 v4.4.10 Symfony Form Component
symfony/framework-bundle           v4.4.10 v4.4.10 Symfony FrameworkBundle
symfony/http-foundation            v4.4.10 v4.4.10 Symfony HttpFoundation Component
symfony/http-kernel                v4.4.10 v4.4.10 Symfony HttpKernel Component
symfony/inflector                  v4.4.10 v4.4.10 Symfony Inflector Component
symfony/intl                       v4.4.10 v4.4.10 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/lock                       v4.4.10 v4.4.10 Symfony Lock Component
symfony/mailchimp-mailer           v4.4.10 v4.4.10 Symfony Mailchimp Mailer Bridge
symfony/mailer                     v4.4.10 v4.4.10 Symfony Mailer Component
symfony/maker-bundle               v1.19.0 v1.19.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/messenger                  v4.4.10 v4.4.10 Symfony Messenger Component
symfony/mime                       v4.4.10 v4.4.10 A library to manipulate MIME messages
symfony/monolog-bridge             v4.4.10 v4.4.10 Symfony Monolog Bridge
symfony/monolog-bundle             v3.5.0  v3.5.0  Symfony MonologBundle
symfony/options-resolver           v4.4.10 v4.4.10 Symfony OptionsResolver Component
symfony/phpunit-bridge             v5.1.2  v5.1.2  Symfony PHPUnit Bridge
symfony/polyfill-ctype             v1.17.1 v1.17.1 Symfony polyfill for ctype functions
symfony/polyfill-iconv             v1.17.1 v1.17.1 Symfony polyfill for the Iconv extension
symfony/polyfill-intl-icu          v1.17.1 v1.17.1 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.17.1 v1.17.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring          v1.17.1 v1.17.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.17.0 v1.17.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.17.1 v1.17.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80             v1.17.1 v1.17.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/process                    v4.4.10 v4.4.10 Symfony Process Component
symfony/property-access            v4.4.10 v4.4.10 Symfony PropertyAccess Component
symfony/proxy-manager-bridge       v4.4.10 v4.4.10 Symfony ProxyManager Bridge
symfony/requirements-checker       v1.1.5  v1.1.5  Check Symfony requirements and give recommendations
symfony/routing                    v4.4.10 v4.4.10 Symfony Routing Component
symfony/security                   v4.4.10 v4.4.10 Symfony Security Component
symfony/security-acl               v3.0.4  v3.0.4  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v4.4.10 v4.4.10 Symfony SecurityBundle
symfony/serializer                 v4.4.10 v4.4.10 Symfony Serializer Component
symfony/service-contracts          v1.1.8  v1.1.8  Generic abstractions related to writing services
symfony/stopwatch                  v4.4.10 v4.4.10 Symfony Stopwatch Component
symfony/swiftmailer-bundle         v3.4.0  v3.4.0  Symfony SwiftmailerBundle
symfony/templating                 v4.4.10 v4.4.10 Symfony Templating Component
symfony/translation                v4.4.10 v4.4.10 Symfony Translation Component
symfony/translation-contracts      v1.1.7  v1.1.7  Generic abstractions related to translation
symfony/twig-bridge                v4.4.10 v4.4.10 Symfony Twig Bridge
symfony/twig-bundle                v4.4.10 v4.4.10 Symfony TwigBundle
symfony/validator                  v4.4.10 v4.4.10 Symfony Validator Component
symfony/var-dumper                 v4.4.10 v4.4.10 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.4.10 v4.4.10 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-profiler-bundle        v4.4.10 v4.4.10 Symfony WebProfilerBundle
symfony/webpack-encore-bundle      v1.7.3  v1.7.3  Integration with your Symfony app & Webpack Encore!
symfony/yaml                       v4.4.10 v4.4.10 Symfony Yaml Component

PHP version

PHP 7.3.16 (cli) (built: Mar 27 2020 17:33:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

Subject

Declaration of Sonata\PageBundle\Block\SharedBlockBlockService::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) must be compatible with Sonata\BlockBundle\Block\Service\AbstractAdminBlockService::validateBlock(Sonata\Form\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block)

Steps to reproduce

php bin/console

Expected results

Actual results

PHP Fatal error:  Declaration of Sonata\PageBundle\Block\SharedBlockBlockService::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) must be compatible with Sonata\BlockBundle\Block\Service\AbstractAdminBlockService::validateBlock(Sonata\Form\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) in /var/www/html/vendor/sonata-project/page-bundle/src/Block/SharedBlockBlockService.php on line 177
Symfony\Component\ErrorHandler\Error\FatalError^ {#9275
  -error: array:4 [
    "type" => 64
    "message" => "Declaration of Sonata\PageBundle\Block\SharedBlockBlockService::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) must be compatible with Sonata\BlockBundle\Block\Service\AbstractAdminBlockService::validateBlock(Sonata\Form\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block)"
    "file" => "/var/www/html/vendor/sonata-project/page-bundle/src/Block/SharedBlockBlockService.php"
    "line" => 177
  ]
  #message: "Compile Error: Declaration of Sonata\PageBundle\Block\SharedBlockBlockService::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) must be compatible with Sonata\BlockBundle\Block\Service\AbstractAdminBlockService::validateBlock(Sonata\Form\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block)"
  #code: 0
  #file: "./vendor/sonata-project/page-bundle/src/Block/SharedBlockBlockService.php"
  #line: 177
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

@tkAlexander @tonyellow Can you check this change by use "sonata-project/form-extensions": "0.x-dev as 0.1.3"? sonata-project/form-extensions@d8bc009

This should fix this error, if it work then @greg0ire can release it.

Isn’t this already release as 0.1.2 ? @wbloszyk

Can we close this issue ?

@wbloszyk I’m currently on Symfony 4.4.10 by folowing all your advices in this topic. I removed all references to the CoreBundle in my project and loaded the extensions in config/bundles.php by adding:

Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],
Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],

Everyhting works and the error from this issue has been resolved. I hope this topic will help other users trying to update their project.

I resolved all error regarding flash messages and forms by following the advices here: https://github.com/sonata-project/SonataAdminBundle/issues/6173

Thanks for all the great work! For now everyhing works like a charm.