1 | <?php |
||
16 | class Block extends Serializable implements BlockInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var Math |
||
20 | */ |
||
21 | private $math; |
||
22 | |||
23 | /** |
||
24 | * @var BlockHeaderInterface |
||
25 | */ |
||
26 | private $header; |
||
27 | |||
28 | /** |
||
29 | * @var TransactionInterface[] |
||
30 | */ |
||
31 | private $transactions; |
||
32 | |||
33 | /** |
||
34 | * @var MerkleRoot |
||
35 | */ |
||
36 | private $merkleRoot; |
||
37 | |||
38 | /** |
||
39 | * Block constructor. |
||
40 | * @param Math $math |
||
41 | * @param BlockHeaderInterface $header |
||
42 | * @param TransactionInterface[] ...$transactions |
||
43 | */ |
||
44 | 18 | public function __construct(Math $math, BlockHeaderInterface $header, TransactionInterface ...$transactions) |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | * @see \BitWasp\Bitcoin\Block\BlockInterface::getHeader() |
||
54 | */ |
||
55 | 14 | public function getHeader(): BlockHeaderInterface |
|
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | * @see \BitWasp\Bitcoin\Block\BlockInterface::getMerkleRoot() |
||
63 | * @throws \BitWasp\Bitcoin\Exceptions\MerkleTreeEmpty |
||
64 | */ |
||
65 | 4 | public function getMerkleRoot(): BufferInterface |
|
73 | |||
74 | /** |
||
75 | * @see \BitWasp\Bitcoin\Block\BlockInterface::getTransactions() |
||
76 | * @return TransactionInterface[] |
||
77 | */ |
||
78 | 14 | public function getTransactions(): array |
|
82 | |||
83 | /** |
||
84 | * @see \BitWasp\Bitcoin\Block\BlockInterface::getTransaction() |
||
85 | * @param int $i |
||
86 | * @return TransactionInterface |
||
87 | */ |
||
88 | 2 | public function getTransaction(int $i): TransactionInterface |
|
89 | { |
||
90 | 2 | if (!array_key_exists($i, $this->transactions)) { |
|
91 | 1 | throw new \InvalidArgumentException("No transaction in the block with this index"); |
|
92 | } |
||
93 | |||
94 | 2 | return $this->transactions[$i]; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param BloomFilter $filter |
||
99 | * @return FilteredBlock |
||
100 | */ |
||
101 | 6 | public function filter(BloomFilter $filter): FilteredBlock |
|
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | * @see \BitWasp\Buffertools\SerializableInterface::getBuffer() |
||
119 | */ |
||
120 | 2 | public function getBuffer(): BufferInterface |
|
124 | } |
||
125 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..