| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of the SmartGecko(c) business platform. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace Governor\Bundle\GovernorBundle\DependencyInjection\Compiler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Governor\Framework\Annotations\CommandHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Symfony\Component\DependencyInjection\Reference; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Symfony\Component\DependencyInjection\ContainerBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Governor\Framework\CommandHandling\Handlers\AnnotatedAggregateCommandHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Governor\Framework\Common\Annotation\MethodMessageHandlerInspector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class AggregateCommandHandlerPass extends AbstractHandlerPass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * @param ContainerBuilder $container | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 23 | 11 |  |     public function process(ContainerBuilder $container) | 
            
                                                        
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 25 | 11 |  |         $aggregates = $container->getParameter('governor.aggregates'); | 
            
                                                        
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 27 | 11 |  |         foreach ($aggregates as $name => $parameters) { | 
            
                                                        
            
                                    
            
            
                | 28 | 11 |  |             if (!$parameters['handler']) { | 
            
                                                        
            
                                    
            
            
                | 29 | 11 |  |                 continue; | 
            
                                                        
            
                                    
            
            
                | 30 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 32 | 11 |  |             $bus = $container->findDefinition( | 
            
                                                        
            
                                    
            
            
                | 33 | 11 |  |                 sprintf( | 
            
                                                        
            
                                    
            
            
                | 34 | 11 |  |                     "governor.command_bus.%s", | 
            
                                                        
            
                                    
            
            
                | 35 | 11 |  |                     isset($parameters['command_bus']) ? $parameters['command_bus'] | 
            
                                                        
            
                                    
            
            
                | 36 | 11 |  |                         : 'default' | 
            
                                                        
            
                                    
            
            
                | 37 | 11 |  |                 ) | 
            
                                                        
            
                                    
            
            
                | 38 | 11 |  |             ); | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 40 | 11 |  |             $inspector = new MethodMessageHandlerInspector( | 
            
                                                        
            
                                    
            
            
                | 41 | 11 |  |                 $container->get('governor.annotation_reader_factory'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 42 | 11 |  |                 new \ReflectionClass($parameters['class']), | 
            
                                                        
            
                                    
            
            
                | 43 |  |  |                 CommandHandler::class | 
            
                                                        
            
                                    
            
            
                | 44 | 11 |  |             ); | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 46 | 11 |  |             foreach ($inspector->getHandlerDefinitions() as $handlerDefinition) { | 
            
                                                        
            
                                    
            
            
                | 47 | 11 |  |                 $handlerId = $this->getHandlerIdentifier("governor.aggregate_command_handler"); | 
            
                                                        
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 49 | 11 |  |                 $container->register($handlerId, AnnotatedAggregateCommandHandler::class) | 
            
                                                        
            
                                    
            
            
                | 50 | 11 |  |                     ->addArgument($parameters['class']) | 
            
                                                        
            
                                    
            
            
                | 51 | 11 |  |                     ->addArgument($handlerDefinition->getMethod()->name) | 
            
                                                        
            
                                    
            
            
                | 52 | 11 |  |                     ->addArgument(new Reference('governor.parameter_resolver_factory')) | 
            
                                                        
            
                                    
            
            
                | 53 | 11 |  |                     ->addArgument(new Reference(sprintf('%s.repository', $name))) | 
            
                                                        
            
                                    
            
            
                | 54 | 11 |  |                     ->addArgument(new Reference('governor.command_target_resolver')) | 
            
                                                        
            
                                    
            
            
                | 55 | 11 |  |                     ->addArgument(new Reference('governor.annotation_reader_factory')) | 
            
                                                        
            
                                    
            
            
                | 56 | 11 |  |                     ->setPublic(true) | 
            
                                                        
            
                                    
            
            
                | 57 | 11 |  |                     ->setLazy(true); | 
            
                                                        
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 59 | 11 |  |                 $bus->addMethodCall( | 
            
                                                        
            
                                    
            
            
                | 60 | 11 |  |                     'subscribe', | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |                     [ | 
            
                                                        
            
                                    
            
            
                | 62 | 11 |  |                         $handlerDefinition->getPayloadType(), | 
            
                                                        
            
                                    
            
            
                | 63 | 11 |  |                         new Reference($handlerId) | 
            
                                                        
            
                                    
            
            
                | 64 | 11 |  |                     ] | 
            
                                                        
            
                                    
            
            
                | 65 | 11 |  |                 ); | 
            
                                                        
            
                                    
            
            
                | 66 | 11 |  |             } | 
            
                                                        
            
                                    
            
            
                | 67 | 11 |  |         } | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 69 |  |  | } | 
            
                        
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: