1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Spiral Framework. |
4
|
|
|
* |
5
|
|
|
* @license MIT |
6
|
|
|
* @author Anton Titov (Wolfy-J) |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Spiral\Http\Bootloaders; |
10
|
|
|
|
11
|
|
|
use Psr\Container\ContainerInterface; |
12
|
|
|
use Psr\Http\Message\ResponseFactoryInterface; |
13
|
|
|
use Spiral\Boot\KernelInterface; |
14
|
|
|
use Spiral\Core\Bootloaders\Bootloader; |
15
|
|
|
use Spiral\Core\Core; |
16
|
|
|
use Spiral\Core\CoreInterface; |
17
|
|
|
use Spiral\Http\Configs\HttpConfig; |
18
|
|
|
use Spiral\Http\HttpCore; |
19
|
|
|
use Spiral\Http\HttpDispatcher; |
20
|
|
|
use Spiral\Http\Pipeline; |
21
|
|
|
use Spiral\Router\Router; |
22
|
|
|
use Spiral\Router\RouterInterface; |
23
|
|
|
use Zend\HttpHandlerRunner\Emitter\EmitterInterface; |
24
|
|
|
use Zend\HttpHandlerRunner\Emitter\SapiEmitter; |
25
|
|
|
|
26
|
|
|
class HttpBootloader extends Bootloader |
27
|
|
|
{ |
28
|
|
|
const BOOT = true; |
29
|
|
|
|
30
|
|
|
const SINGLETONS = [ |
31
|
|
|
EmitterInterface::class => SapiEmitter::class, |
32
|
|
|
ResponseFactoryInterface::class => HttpCore::class, |
33
|
|
|
CoreInterface::class => Core::class, |
34
|
|
|
HttpCore::class => [self::class, 'core'], |
35
|
|
|
RouterInterface::class => [self::class, 'router'] |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param KernelInterface $kernel |
40
|
|
|
* @param HttpDispatcher $http |
41
|
|
|
*/ |
42
|
|
|
public function boot(KernelInterface $kernel, HttpDispatcher $http) |
43
|
|
|
{ |
44
|
|
|
$kernel->addDispatcher($http); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param HttpConfig $config |
49
|
|
|
* @param ContainerInterface $container |
50
|
|
|
* @param RouterInterface $router |
51
|
|
|
* @param Pipeline $pipeline |
52
|
|
|
* @return HttpCore |
53
|
|
|
*/ |
54
|
|
|
protected function core( |
55
|
|
|
HttpConfig $config, |
56
|
|
|
ContainerInterface $container, |
57
|
|
|
RouterInterface $router, |
58
|
|
|
Pipeline $pipeline |
59
|
|
|
): HttpCore { |
60
|
|
|
$core = new HttpCore($config, $pipeline, $container); |
61
|
|
|
$core->setHandler($router); |
|
|
|
|
62
|
|
|
|
63
|
|
|
return $core; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param HttpConfig $config |
68
|
|
|
* @param ContainerInterface $container |
69
|
|
|
* @return RouterInterface |
70
|
|
|
*/ |
71
|
|
|
protected function router( |
72
|
|
|
HttpConfig $config, |
73
|
|
|
ContainerInterface $container |
74
|
|
|
): RouterInterface { |
75
|
|
|
return new Router($config->basePath(), $container); |
76
|
|
|
} |
77
|
|
|
} |
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: