These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * This file is part of the StfalconApiBundle. |
||
4 | * |
||
5 | * (c) Stfalcon LLC <stfalcon.com> |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | */ |
||
10 | |||
11 | declare(strict_types=1); |
||
12 | |||
13 | namespace StfalconStudio\ApiBundle\DependencyInjection; |
||
14 | |||
15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
16 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
17 | |||
18 | /** |
||
19 | * Configuration. |
||
20 | */ |
||
21 | class Configuration implements ConfigurationInterface |
||
22 | { |
||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function getConfigTreeBuilder(): TreeBuilder |
||
27 | { |
||
28 | $treeBuilder = new TreeBuilder('stfalcon_api'); |
||
29 | |||
30 | $treeBuilder->getRootNode() |
||
0 ignored issues
–
show
|
|||
31 | ->children() |
||
32 | ->scalarNode('json_schema_dir')->defaultValue('%kernel.project_dir%/Json/Schema/')->cannotBeEmpty()->end() |
||
33 | ->end() |
||
34 | ; |
||
35 | |||
36 | return $treeBuilder; |
||
37 | } |
||
38 | } |
||
39 |
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: