| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Sonata Project package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * (c) Thomas Rabaix <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace Sonata\TranslationBundle\Block; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Sonata\BlockBundle\Block\BlockContextInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sonata\BlockBundle\Block\Service\AbstractBlockService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Symfony\Component\HttpFoundation\Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Symfony\Component\OptionsResolver\OptionsResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @author Nicolas Bastien <[email protected]> | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | class LocaleSwitcherBlockService extends AbstractBlockService | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      * @var bool | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     private $showCountryFlags; | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         ?string $name = null,  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         EngineInterface $templating = null,  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         ?bool $showCountryFlags = false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         parent::__construct($name, $templating); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->showCountryFlags = $showCountryFlags; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |      * NEXT_MAJOR: remove this method. | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      * @deprecated since 3.x, will be removed in 4.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function setDefaultSettings(OptionsResolverInterface $resolver) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $this->configureSettings($resolver); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function configureSettings(OptionsResolver $resolver) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $resolver->setDefaults( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                 'admin' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 'object' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                 'template' => '@SonataTranslation/Block/block_locale_switcher.html.twig', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 'locale_switcher_route' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 'locale_switcher_route_parameters' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 'locale_switcher_show_country_flags' => $this->showCountryFlags, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function execute(BlockContextInterface $blockContext, Response $response = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         return $this->renderPrivateResponse($blockContext->getTemplate(), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             'block_context' => $blockContext, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             'block' => $blockContext->getBlock(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         ], $response); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: