1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Spiral Framework. |
5
|
|
|
* |
6
|
|
|
* @license MIT |
7
|
|
|
* @author Anton Titov (Wolfy-J) |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Spiral\Debug\StateCollector; |
13
|
|
|
|
14
|
|
|
use Psr\Container\ContainerInterface; |
15
|
|
|
use Spiral\Boot\DispatcherInterface; |
16
|
|
|
use Spiral\Boot\EnvironmentInterface; |
17
|
|
|
use Spiral\Debug\StateCollectorInterface; |
18
|
|
|
use Spiral\Debug\StateInterface; |
19
|
|
|
use Spiral\GRPC\GRPCDispatcher; |
20
|
|
|
use Spiral\Http\RrDispacher; |
21
|
|
|
use Spiral\Http\SapiDispatcher; |
22
|
|
|
use Spiral\Jobs\JobDispatcher; |
23
|
|
|
|
24
|
|
|
final class EnvironmentCollector implements StateCollectorInterface |
25
|
|
|
{ |
26
|
|
|
/** @var ContainerInterface */ |
27
|
|
|
private $container; |
28
|
|
|
|
29
|
|
|
/** @var EnvironmentInterface */ |
30
|
|
|
private $env; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param ContainerInterface $container |
34
|
|
|
* @param EnvironmentInterface $env |
35
|
|
|
*/ |
36
|
|
|
public function __construct(ContainerInterface $container, EnvironmentInterface $env) |
37
|
|
|
{ |
38
|
|
|
$this->container = $container; |
39
|
|
|
$this->env = $env; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function populate(StateInterface $state): void |
43
|
|
|
{ |
44
|
|
|
$state->setTag('php', phpversion()); |
45
|
|
|
|
46
|
|
|
if ($this->container->get(DispatcherInterface::class)) { |
47
|
|
|
switch (get_class($this->container->get(DispatcherInterface::class))) { |
48
|
|
|
case RrDispacher::class: |
49
|
|
|
$state->setTag('dispatcher', 'roadrunner'); |
50
|
|
|
break; |
51
|
|
|
case SapiDispatcher::class: |
52
|
|
|
$state->setTag('dispatcher', 'sapi'); |
53
|
|
|
break; |
54
|
|
|
case JobDispatcher::class: |
55
|
|
|
$state->setTag('dispatcher', 'jobs'); |
56
|
|
|
break; |
57
|
|
|
case GRPCDispatcher::class: |
58
|
|
|
$state->setTag('dispatcher', 'grpc'); |
59
|
|
|
break; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$state->setVariable('environment', $this->env->getAll()); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.