Skip to content

Commit 96d1a65

Browse files
committed
Optimizing PHP performance by using
fully-qualified function calls
1 parent 4c13abd commit 96d1a65

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

.php_cs.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"7.3.11","version":"2.16.3:v2.16.3#83baf823a33a1cbd5416c8626935cf3f843c10b0","indent":" ","lineEnding":"\n","rules":{"native_function_invocation":true},"hashes":{"src\/ClamAV\/ClamAV.php":1121041739,"src\/ClamAV\/Pipe.php":88767907,"src\/ClamAV\/Network.php":2672517394}}

src/ClamAV/ClamAV.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ private function sendCommand($command)
2424

2525
$socket = $this->getSocket();
2626

27-
socket_send($socket, $command, strlen($command), 0);
28-
socket_recv($socket, $return, self::CLAMAV_MAX, 0);
29-
socket_close($socket);
27+
\socket_send($socket, $command, \strlen($command), 0);
28+
\socket_recv($socket, $return, self::CLAMAV_MAX, 0);
29+
\socket_close($socket);
3030

3131
return $return;
3232
}
@@ -41,7 +41,7 @@ private function sendCommand($command)
4141
public function ping()
4242
{
4343
$return = $this->sendCommand('PING');
44-
return trim($return) === 'PONG';
44+
return \trim($return) === 'PONG';
4545
}
4646

4747
/**
@@ -51,7 +51,7 @@ public function ping()
5151
*/
5252
public function version()
5353
{
54-
return trim($this->sendCommand('VERSION'));
54+
return \trim($this->sendCommand('VERSION'));
5555
}
5656

5757
/**
@@ -85,10 +85,10 @@ public function fileScan(string $file)
8585
{
8686
$out = $this->sendCommand('SCAN ' . $file);
8787

88-
$out = explode(':', $out);
89-
$stats = end($out);
88+
$out = \explode(':', $out);
89+
$stats = \end($out);
9090

91-
$result = trim($stats);
91+
$result = \trim($stats);
9292

9393
return ($result === 'OK');
9494
}
@@ -104,9 +104,9 @@ public function continueScan(string $file)
104104
{
105105
$return = [];
106106

107-
foreach(explode("\n", trim($this->sendCommand('CONTSCAN ' . $file))) as $results ) {
108-
list($file, $stats) = explode(':', $results);
109-
array_push($return, [ 'file' => $file, 'stats' => trim($stats) ]);
107+
foreach(\explode("\n", \trim($this->sendCommand('CONTSCAN ' . $file))) as $results ) {
108+
list($file, $stats) = \explode(':', $results);
109+
\array_push($return, [ 'file' => $file, 'stats' => \trim($stats) ]);
110110
}
111111

112112
return $return;

src/ClamAV/Network.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function __construct(string $host = self::CLAMAV_HOST, int $port = self::
3737
*/
3838
protected function getSocket()
3939
{
40-
$socket = @socket_create(AF_INET, SOCK_STREAM, 0);
41-
$status = @socket_connect($socket, $this->host, $this->port);
40+
$socket = @\socket_create(AF_INET, SOCK_STREAM, 0);
41+
$status = @\socket_connect($socket, $this->host, $this->port);
4242

4343
if(!$status) {
4444
throw new \Exception('Unable to connect to ClamAV server');

src/ClamAV/Pipe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function __construct(string $pip = self::CLAMAV_HOST)
2929
*/
3030
protected function getSocket()
3131
{
32-
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
33-
socket_connect($socket, $this->pip);
32+
$socket = \socket_create(AF_UNIX, SOCK_STREAM, 0);
33+
\socket_connect($socket, $this->pip);
3434
return $socket;
3535
}
3636
}

0 commit comments

Comments
 (0)