1 | <?php |
||
17 | class FastCGI extends AbstractAdapter |
||
18 | { |
||
19 | /** |
||
20 | * @var Client |
||
21 | */ |
||
22 | protected $client; |
||
23 | |||
24 | /** |
||
25 | * @var Array of patterns matching php socket files |
||
26 | */ |
||
27 | protected $possibleSocketFilePatterns = [ |
||
28 | '/var/run/php*.sock', |
||
29 | '/var/run/php/*.sock' |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $host; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $chroot; |
||
41 | |||
42 | /** |
||
43 | * @param string $host 127.0.0.1:9000 or /var/run/php5-fpm.sock |
||
44 | * @param string $chroot |
||
45 | */ |
||
46 | 10 | public function __construct($host = null, $chroot = null) |
|
47 | { |
||
48 | // try to guess where it is |
||
49 | 10 | if ($host === null) { |
|
50 | 8 | foreach ($this->possibleSocketFilePatterns as $possibleSocketFilePattern) { |
|
51 | 8 | $possibleSocketFile = current(glob($possibleSocketFilePattern)); |
|
52 | 8 | if (file_exists($possibleSocketFile)) { |
|
53 | $host = $possibleSocketFile; |
||
54 | break; |
||
55 | } |
||
56 | } |
||
57 | 8 | if ($host === null) { |
|
58 | 8 | $host = '127.0.0.1:9000'; |
|
59 | } |
||
60 | } |
||
61 | |||
62 | 10 | $this->host = $host; |
|
63 | |||
64 | 10 | if (false !== strpos($host, ':')) { |
|
65 | 9 | [$host, $port] = explode(':', $host); |
|
|
|||
66 | 9 | $this->client = new Client($host, $port); |
|
67 | } else { |
||
68 | // socket |
||
69 | 1 | $this->client = new Client('unix://' . $host, -1); |
|
70 | } |
||
71 | |||
72 | 10 | $this->client->setReadWriteTimeout(60 * 1000); |
|
73 | 10 | $this->client->setPersistentSocket(false); |
|
74 | 10 | $this->client->setKeepAlive(true); |
|
75 | |||
76 | 10 | if ($chroot !== null) { |
|
77 | 3 | $this->chroot = rtrim($chroot, '/'); |
|
78 | } |
||
79 | 10 | } |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 4 | protected function doRun(Code $code) |
|
99 | |||
100 | 4 | protected function request(Code $code) |
|
138 | |||
139 | /** |
||
140 | * @param string $file |
||
141 | * @return string |
||
142 | * @throws \RuntimeException |
||
143 | */ |
||
144 | 3 | protected function getScriptFileName($file) |
|
154 | } |
||
155 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.