Skip to content

Commit 5da9fe9

Browse files
muglugmarcj
authored andcommitted
Fix issues found by static analysis (php-pm#321)
1 parent 38683a7 commit 5da9fe9

File tree

11 files changed

+28
-22
lines changed

11 files changed

+28
-22
lines changed

src/Commands/ConfigCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
3737
$newContent = json_encode($config, JSON_PRETTY_PRINT);
3838
if (file_exists($configPath) && $newContent === file_get_contents($configPath)) {
3939
$output->writeln(sprintf('No changes to %s file.', realpath($configPath)));
40-
return;
40+
return null;
4141
}
4242

4343
file_put_contents($configPath, $newContent);
4444
$output->writeln(sprintf('<info>%s file written.</info>', realpath($configPath)));
45+
46+
return null;
4547
}
4648
}

src/Commands/StartCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4747
$handler->setPopulateServer($config['populate-server-var']);
4848
$handler->setStaticDirectory($config['static-directory']);
4949
$handler->run();
50+
51+
return null;
5052
}
5153
}

src/Commands/StatusCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
3838
$handler->getStatus(function ($status) use ($output) {
3939
$output->writeln($this->parseStatus($status));
4040
});
41+
42+
return null;
4143
}
4244

4345
/**

src/Commands/StopCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4040
$handler->stopProcessManager(function ($status) use ($output) {
4141
$output->writeln('Requested process manager to stop.');
4242
});
43+
44+
return null;
4345
}
4446
}

src/ProcessClient.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public function __construct()
2323

2424
protected function request($command, $options, $callback)
2525
{
26-
$data['cmd'] = $command;
27-
$data['options'] = $options;
26+
$data = [
27+
'cmd' => $command,
28+
'options' => $options
29+
];
2830

2931
$connector = new UnixConnector($this->loop);
3032
$unixSocket = $this->getControllerSocketPath(false);

src/ProcessCommunicationTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait ProcessCommunicationTrait
2020
* Parses a received message. Redirects to the appropriate `command*` method.
2121
*
2222
* @param ConnectionInterface $conn
23-
* @param array $data
23+
* @param string $data
2424
*
2525
* @throws \Exception when invalid 'cmd' in $data.
2626
*/

src/ProcessManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ class ProcessManager
6363
protected $maxRequests = 2000;
6464

6565
/**
66-
* @var array
66+
* @var SlavePool
6767
*/
68-
protected $slaves = [];
68+
protected $slaves;
6969

7070
/**
7171
* @var string
@@ -305,7 +305,7 @@ public function setAppEnv($appenv)
305305
}
306306

307307
/**
308-
* @return string
308+
* @return ?string
309309
*/
310310
public function getAppEnv()
311311
{

src/ProcessSlave.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ProcessSlave
110110
*/
111111
protected $config;
112112

113-
public function __construct($socketpath, $bridgeName = null, $appBootstrap, array $config = [])
113+
public function __construct($socketpath, $bridgeName, $appBootstrap, array $config = [])
114114
{
115115
$this->setSocketPath($socketpath);
116116

@@ -246,7 +246,7 @@ protected function getBridge()
246246
protected function bootstrap($appBootstrap, $appenv, $debug)
247247
{
248248
if ($bridge = $this->getBridge()) {
249-
$bridge->bootstrap($appBootstrap, $appenv, $debug, $this->loop);
249+
$bridge->bootstrap($appBootstrap, $appenv, $debug);
250250
$this->sendMessage($this->controller, 'ready');
251251
}
252252
}

src/RequestHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class RequestHandler
5353
private $redirectionTries = 0;
5454
private $incomingBuffer = '';
5555

56+
/**
57+
* @var ?float
58+
*/
59+
private $start;
60+
5661
public function __construct(LoopInterface $loop, OutputInterface $output, SlavePool $slaves)
5762
{
5863
$this->loop = $loop;
@@ -89,7 +94,7 @@ public function handleData($data)
8994
$this->incomingBuffer .= $data;
9095

9196
if ($this->connection && $this->isHeaderEnd($this->incomingBuffer)) {
92-
$remoteAddress = $this->incoming->getRemoteAddress();
97+
$remoteAddress = (string) $this->incoming->getRemoteAddress();
9398
$headersToReplace = [
9499
'X-PHP-PM-Remote-IP' => trim(parse_url($remoteAddress, PHP_URL_HOST), '[]'),
95100
'X-PHP-PM-Remote-Port' => trim(parse_url($remoteAddress, PHP_URL_PORT), '[]')
@@ -127,7 +132,7 @@ public function getNextSlave()
127132
/**
128133
* Slave available handler
129134
*
130-
* @param array $slave available slave instance
135+
* @param Slave $slave available slave instance
131136
*/
132137
public function slaveAvailable(Slave $slave)
133138
{

src/Slave.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,6 @@ public function getPort()
163163
return $this->port;
164164
}
165165

166-
/**
167-
* Get slave socket path
168-
*
169-
* @return string slave socket path
170-
*/
171-
public function getSocketPath()
172-
{
173-
return $this->socketPath;
174-
}
175-
176166
/**
177167
* Get slave incoming connection
178168
*

0 commit comments

Comments
 (0)