Browse Source

couple bugs fixed in Client class

pull/33/head
Paul Rock 6 years ago
parent
commit
17522170e2
  1. 17
      src/Client.php

17
src/Client.php

@ -7,6 +7,7 @@ use RouterOS\Exceptions\ConfigException;
use RouterOS\Exceptions\QueryException;
use RouterOS\Helpers\ArrayHelper;
use RouterOS\Interfaces\QueryInterface;
use function array_keys;
use function array_shift;
use function chr;
@ -90,7 +91,7 @@ class Client implements Interfaces\ClientInterface
/**
* Send write query to RouterOS
*
* @param string|array|Query $query
* @param string|array|\RouterOS\Query $query
*
* @return \RouterOS\Client
* @throws \RouterOS\Exceptions\QueryException
@ -165,7 +166,7 @@ class Client implements Interfaces\ClientInterface
* Query helper
*
* @param array $item
* @param Query $query
* @param \RouterOS\Interfaces\QueryInterface $query
*
* @return \RouterOS\Query
* @throws \RouterOS\Exceptions\ClientException
@ -364,12 +365,12 @@ class Client implements Interfaces\ClientInterface
for ($j = $key + 1; $j <= $lines; $j++) {
// If we have lines after current one
if (isset($response[$j])) {
$this->preParseResponse($response[$j], $result, $matches, $j);
$this->preParseResponse($response[$j], $result, $matches);
}
}
break 2;
default:
$this->preParseResponse($value, $result, $matches);
$this->preParseResponse($value, $result, $matches, $i);
break;
}
}
@ -381,10 +382,10 @@ class Client implements Interfaces\ClientInterface
*
* @param string $value Value which should be parsed
* @param array $result Array with parsed response
* @param array $matches Matched words
* @param null|array $matches Matched words
* @param string|int $iterator Type of iterations or number of item
*/
private function preParseResponse(string $value, array &$result, array &$matches, $iterator = 'after'): void
private function preParseResponse(string $value, array &$result, ?array &$matches, $iterator = 'after'): void
{
$this->pregResponse($value, $matches);
if (isset($matches[1][0], $matches[2][0])) {
@ -396,9 +397,9 @@ class Client implements Interfaces\ClientInterface
* Parse result from RouterOS by regular expression
*
* @param string $value
* @param array $matches
* @param null|array $matches
*/
private function pregResponse(string $value, array &$matches): void
private function pregResponse(string $value, ?array &$matches): void
{
preg_match_all('/^[=|.](.*)=(.*)/', $value, $matches);
}

Loading…
Cancel
Save