1 | <?php |
||
13 | class TransactionInputSerializer |
||
14 | { |
||
15 | /** |
||
16 | * @var OutPointSerializer |
||
17 | */ |
||
18 | private $outpointSerializer; |
||
19 | |||
20 | /** |
||
21 | * @var \BitWasp\Buffertools\Types\VarString |
||
22 | */ |
||
23 | private $varstring; |
||
24 | |||
25 | /** |
||
26 | * @var \BitWasp\Buffertools\Types\Uint32 |
||
27 | */ |
||
28 | private $uint32le; |
||
29 | |||
30 | /** |
||
31 | * TransactionInputSerializer constructor. |
||
32 | * @param OutPointSerializerInterface $outPointSerializer |
||
33 | */ |
||
34 | 1336 | public function __construct(OutPointSerializerInterface $outPointSerializer) |
|
35 | { |
||
36 | 1336 | $this->outpointSerializer = $outPointSerializer; |
|
|
|||
37 | 1336 | $this->varstring = Types::varstring(); |
|
38 | 1336 | $this->uint32le = Types::uint32le(); |
|
39 | 1336 | } |
|
40 | |||
41 | /** |
||
42 | * @param TransactionInputInterface $input |
||
43 | * @return BufferInterface |
||
44 | */ |
||
45 | 1306 | public function serialize(TransactionInputInterface $input) |
|
46 | { |
||
47 | 1306 | return new Buffer( |
|
48 | 1306 | $this->outpointSerializer->serialize($input->getOutPoint())->getBinary() . |
|
49 | 1306 | $this->varstring->write($input->getScript()->getBuffer()) . |
|
50 | 1306 | $this->uint32le->write($input->getSequence()) |
|
51 | ); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param Parser $parser |
||
56 | * @return TransactionInput |
||
57 | * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange |
||
58 | */ |
||
59 | 66 | public function fromParser(Parser $parser) |
|
60 | { |
||
61 | 66 | return new TransactionInput( |
|
62 | 66 | $this->outpointSerializer->fromParser($parser), |
|
63 | 66 | new Script($this->varstring->read($parser)), |
|
64 | 66 | $this->uint32le->read($parser) |
|
65 | ); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param BufferInterface|string $string |
||
70 | * @return TransactionInput |
||
71 | * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange |
||
72 | */ |
||
73 | 4 | public function parse($string) |
|
77 | } |
||
78 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.