1 | <?php |
||
18 | class HttplugExtension extends Extension |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function load(array $configs, ContainerBuilder $container) |
||
58 | |||
59 | /** |
||
60 | * Configure client services. |
||
61 | * |
||
62 | * @param ContainerBuilder $container |
||
63 | * @param array $config |
||
64 | */ |
||
65 | private function configureClients(ContainerBuilder $container, array $config) |
||
66 | { |
||
67 | $first = isset($config['clients']['default']) ? 'default' : null; |
||
68 | foreach ($config['clients'] as $name => $arguments) { |
||
69 | if ($first === null) { |
||
70 | $first = $name; |
||
71 | } |
||
72 | |||
73 | if (isset($config['_inject_collector_plugin'])) { |
||
74 | array_unshift($arguments['plugins'], 'httplug.collector.history_plugin'); |
||
75 | } |
||
76 | |||
77 | $def = $container->register('httplug.client.'.$name, DummyClient::class); |
||
78 | |||
79 | if (empty($arguments['plugins'])) { |
||
80 | $def->setFactory([new Reference($arguments['factory']), 'createClient']) |
||
81 | ->addArgument($arguments['config']); |
||
82 | } else { |
||
83 | $def->setFactory('Http\HttplugBundle\ClientFactory\PluginClientFactory::createPluginClient') |
||
84 | ->addArgument(array_map(function ($id) { |
||
85 | return new Reference($id); |
||
86 | }, $arguments['plugins'])) |
||
87 | ->addArgument(new Reference($arguments['factory'])) |
||
88 | ->addArgument($arguments['config']); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | // Alias the first client to httplug.client.default |
||
93 | if ($first !== null) { |
||
94 | $container->setAlias('httplug.client.default', 'httplug.client.'.$first); |
||
95 | } elseif (isset($config['_inject_collector_plugin'])) { |
||
96 | // No client was configured. Make sure to inject history plugin to the auto discovery client. |
||
97 | $container->register('httplug.client', PluginClient::class) |
||
98 | ->addArgument(new Reference('httplug.client.default')) |
||
99 | ->addArgument([new Reference('httplug.collector.history_plugin')]); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @param ContainerBuilder $container |
||
105 | * @param array $config |
||
106 | */ |
||
107 | private function configurePlugins(ContainerBuilder $container, array $config) |
||
119 | |||
120 | /** |
||
121 | * @param string $name |
||
122 | * @param Definition $definition |
||
123 | * @param array $config |
||
124 | */ |
||
125 | private function configurePluginByName($name, Definition $definition, array $config) |
||
165 | } |
||
166 |
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: