1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Tarantool Client package. |
5
|
|
|
* |
6
|
|
|
* (c) Eugene Leonovich <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Tarantool\Client\Packer; |
15
|
|
|
|
16
|
|
|
use Tarantool\Client\Keys; |
17
|
|
|
use Tarantool\Client\Request\Request; |
18
|
|
|
use Tarantool\Client\Response; |
19
|
|
|
|
20
|
|
|
final class PeclPacker implements Packer |
21
|
|
|
{ |
22
|
|
|
private $packer; |
23
|
|
|
private $unpacker; |
24
|
|
|
|
25
|
138 |
|
public function __construct(bool $phpOnly = true) |
26
|
|
|
{ |
27
|
138 |
|
$this->packer = new \MessagePack($phpOnly); |
28
|
138 |
|
$this->unpacker = new \MessagePackUnpacker($phpOnly); |
|
|
|
|
29
|
138 |
|
} |
30
|
|
|
|
31
|
114 |
|
public function pack(Request $request, int $sync) : string |
32
|
|
|
{ |
33
|
|
|
// @see https://github.com/msgpack/msgpack-php/issues/45 |
34
|
114 |
|
$packet = \pack('C*', 0x82, Keys::CODE, $request->getType(), Keys::SYNC). |
35
|
114 |
|
$this->packer->pack($sync). |
36
|
114 |
|
$this->packer->pack($request->getBody()); |
37
|
|
|
|
38
|
114 |
|
return PacketLength::pack(\strlen($packet)).$packet; |
39
|
|
|
} |
40
|
|
|
|
41
|
99 |
|
public function unpack(string $packet) : Response |
42
|
|
|
{ |
43
|
99 |
|
$this->unpacker->feed($packet); |
44
|
|
|
|
45
|
99 |
|
if (!$this->unpacker->execute()) { |
46
|
2 |
|
throw new \UnexpectedValueException('Unable to unpack response header.'); |
47
|
|
|
} |
48
|
97 |
|
$header = $this->unpacker->data(); |
49
|
|
|
|
50
|
97 |
|
if (!$this->unpacker->execute()) { |
51
|
1 |
|
throw new \UnexpectedValueException('Unable to unpack response body.'); |
52
|
|
|
} |
53
|
96 |
|
$body = $this->unpacker->data(); |
54
|
|
|
|
55
|
|
|
// with PHP_ONLY = true an empty array |
56
|
|
|
// will be unpacked to stdClass |
57
|
96 |
|
if ($body instanceof \stdClass) { |
58
|
9 |
|
$body = (array) $body; |
59
|
|
|
} |
60
|
|
|
|
61
|
96 |
|
return new Response($header, $body); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths