| 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\SeoBundle\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Symfony\Component\Config\Definition\Builder\TreeBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\Config\Definition\ConfigurationInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * This is the class that validates and merges configuration from your app/config files. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | final class Configuration implements ConfigurationInterface | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     public function getConfigTreeBuilder() | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $treeBuilder = new TreeBuilder('sonata_seo'); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $rootNode = $treeBuilder->getRootNode(); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         $rootNode | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             ->children() | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |                 ->scalarNode('encoding')->defaultValue('UTF-8')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |                 ->arrayNode('page') | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |                     ->addDefaultsIfNotSet() | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |                     ->children() | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |                         ->scalarNode('default')->defaultValue('sonata.seo.page.default')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |                         ->arrayNode('head') | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |                             ->normalizeKeys(false) | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |                             ->useAttributeAsKey('attribute') | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |                             ->prototype('scalar')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |                         ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |                         ->arrayNode('metas') | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |                             ->normalizeKeys(false) | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |                             ->useAttributeAsKey('element') | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |                             ->prototype('array') | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |                                 ->normalizeKeys(false) | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |                                 ->useAttributeAsKey('name') | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |                                 ->prototype('scalar')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |                             ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |                         ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |                         ->scalarNode('separator')->defaultValue(' - ')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |                         // NEXT_MAJOR: Make this field required | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |                         ->scalarNode('title')->defaultValue('Project name')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |                     ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |                 ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |                 ->arrayNode('sitemap') | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |                     ->addDefaultsIfNotSet() | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |                     ->children() | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |                         ->arrayNode('doctrine_orm') | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |                             ->prototype('variable')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |                         ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |                         ->arrayNode('services') | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |                             ->prototype('variable')->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |                         ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |                     ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |                 ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |             ->end() | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         ; | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         $this->addHttpClientSection($rootNode); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         return $treeBuilder; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     private function addHttpClientSection(ArrayNodeDefinition $node): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $node | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                 ->arrayNode('http') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                     ->addDefaultsIfNotSet() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                     ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                         ->scalarNode('client') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                             ->defaultNull() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                             ->info('Alias of the http client.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                         ->scalarNode('message_factory') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                             ->defaultNull() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                             ->info('Alias of the message factory.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                     ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             ->end(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 94 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 95 |  |  |  | 
            
                        
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.