| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Go! AOP framework | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Copyright 2015, Lisachenko Alexander <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * This source file is subject to the license that is bundled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * with this source code in the file LICENSE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Go\Symfony\GoAopBundle\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Go\Aop\Features; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Go\Symfony\GoAopBundle\Kernel\AspectSymfonyKernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Symfony\Component\Config\Definition\Builder\TreeBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\Config\Definition\ConfigurationInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Symfony\Component\HttpKernel\Kernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | class Configuration implements ConfigurationInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     const CONFIGURATION_ROOT_NODE = 'go_aop'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * Generates the configuration tree builder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public function getConfigTreeBuilder() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $treeBuilder = new TreeBuilder(self::CONFIGURATION_ROOT_NODE); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $rootNode = $this->getRootNode($treeBuilder); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $features = (new \ReflectionClass('Go\Aop\Features'))->getConstants(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $rootNode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                 ->booleanNode('cache_warmer')->defaultTrue()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 ->booleanNode('doctrine_support')->defaultFalse()->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |                 ->arrayNode('options') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                     ->addDefaultsIfNotSet() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                     ->fixXmlConfig('feature', 'features') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                     ->fixXmlConfig('include_path', 'include_paths') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                     ->fixXmlConfig('exclude_path', 'exclude_paths') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                     ->children() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                         ->scalarNode('features') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                             ->beforeNormalization() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                                 ->ifArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                                 ->then(function ($v) use ($features) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                                     $featureMask = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                                     foreach ($v as $featureName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                                         $featureName = strtoupper($featureName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                                         if (!isset($features[$featureName])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                                             throw new InvalidConfigurationException("Uknown feature: {$featureName}"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                                         $featureMask |= $features[$featureName]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                                     return $featureMask; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                                 }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                             ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                             ->defaultValue(0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                         ->scalarNode('app_dir')->defaultValue('%kernel.root_dir%/../src')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                         ->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/aspect')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                         ->scalarNode('cache_file_mode')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                         ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                         ->scalarNode('container_class')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                         ->arrayNode('include_paths') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                             ->prototype('scalar')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                         ->arrayNode('exclude_paths') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                             ->prototype('scalar')->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                         ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                     ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ->end() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         return $treeBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @param TreeBuilder $treeBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @return ArrayNodeDefinition | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |     private function getRootNode(TreeBuilder $treeBuilder) | 
            
                                                        
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |         if (Kernel::VERSION_ID >= 40200) { | 
            
                                                        
            
                                    
            
            
                | 92 |  |  |             return $treeBuilder->getRootNode(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 93 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 95 |  |  |         return $treeBuilder->root(self::CONFIGURATION_ROOT_NODE); | 
            
                                                        
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 97 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 98 |  |  |  | 
            
                        
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.