| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 27 | public function getConfigTreeBuilder() | ||
| 28 |     { | ||
| 29 |         $treeBuilder = new TreeBuilder('swp_geo_ip'); | ||
| 30 | $treeBuilder->getRootNode() | ||
|  | |||
| 31 | ->children() | ||
| 32 |                 ->scalarNode('database_url') | ||
| 33 | ->cannotBeEmpty() | ||
| 34 |                     ->defaultValue('https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz') | ||
| 35 |                     ->info('GeoIP2 database URL') | ||
| 36 | ->end() | ||
| 37 |                 ->scalarNode('database_path') | ||
| 38 | ->cannotBeEmpty() | ||
| 39 |                     ->defaultValue('%kernel.cache_dir%/GeoLite2-City.mmdb') | ||
| 40 |                     ->info('Path to the downloaded GeoIP2 database') | ||
| 41 | ->end() | ||
| 42 | ->end(); | ||
| 43 | |||
| 44 | return $treeBuilder; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | 
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: