diff --git a/src/NanoIPC.php b/src/NanoIPC.php index 18c7c24..72014c2 100644 --- a/src/NanoIPC.php +++ b/src/NanoIPC.php @@ -41,11 +41,11 @@ public function __construct(string $transport_type, array $parameters) // # Unix domain Socket if ($transport_type == 'unix_domain_socket') { - if (!isset($parameters['path_to_socket']) || !is_string($parameters['path_to_socket'])) { - throw new NanoIPCException("Invalid path to socket: " . $parameters['path_to_socket']); + if (!isset($params['path_to_socket']) || !is_string($params['path_to_socket'])) { + throw new NanoIPCException("Invalid path to socket: " . $params['path_to_socket']); } - $this->pathToSocket = $parameters['path_to_socket']; + $this->pathToSocket = $params['path_to_socket']; $this->transport = stream_socket_client( "unix://{$this->pathToSocket}", $this->errorCode, @@ -59,22 +59,22 @@ public function __construct(string $transport_type, array $parameters) // # TCP } elseif ($transport_type == 'TCP') { - if (!isset($parameters['hostname']) || !is_string($parameters['hostname'])) { - throw new NanoIPCException("Invalid hostname: " . $parameters['hostname']); + if (!isset($params['hostname']) || !is_string($params['hostname'])) { + throw new NanoIPCException("Invalid hostname: " . $params['hostname']); } - if (!isset($parameters['port']) || !is_int((int) $parameters['port'])) { - throw new NanoIPCException("Invalid port: " . $parameters['port']); + if (!isset($params['port']) || !is_int((int) $params['port'])) { + throw new NanoIPCException("Invalid port: " . $params['port']); } - if (strpos($parameters['hostname'], 'http://') === 0) { - $parameters['hostname'] = substr($parameters['hostname'], 7); + if (strpos($params['hostname'], 'http://') === 0) { + $params['hostname'] = substr($params['hostname'], 7); } - if (strpos($parameters['hostname'], 'https://') === 0) { - $parameters['hostname'] = substr($parameters['hostname'], 8); + if (strpos($params['hostname'], 'https://') === 0) { + $params['hostname'] = substr($params['hostname'], 8); } - $this->hostname = $parameters['hostname']; - $this->port = (int) $parameters['port']; + $this->hostname = $params['hostname']; + $this->port = (int) $params['port']; $this->transport = stream_socket_client( "tcp://{$this->hostname}:{$this->port}", $this->errorCode, diff --git a/src/NanoRPC.php b/src/NanoRPC.php index 6a46bdc..4e43d10 100644 --- a/src/NanoRPC.php +++ b/src/NanoRPC.php @@ -159,6 +159,8 @@ public function __call($method, array $params) // # Request + $arguments = []; + if (isset($params[0])) { foreach ($params[0] as $key => $value) { $arguments[$key] = $value;