| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace BitWasp\Bitcoin\Serializer\Transaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use BitWasp\Bitcoin\Script\Script; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use BitWasp\Bitcoin\Serializer\Types; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use BitWasp\Bitcoin\Transaction\TransactionInput; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use BitWasp\Bitcoin\Transaction\TransactionInputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use BitWasp\Buffertools\Buffer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use BitWasp\Buffertools\BufferInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use BitWasp\Buffertools\Parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 | 2692 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 2692 |  |      * TransactionInputSerializer constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 2692 |  |      * @param OutPointSerializerInterface $outPointSerializer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 2692 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     public function __construct(OutPointSerializerInterface $outPointSerializer) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->outpointSerializer = $outPointSerializer; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->varstring = Types::varstring(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 2692 |  |         $this->uint32le = Types::uint32le(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 2692 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 2692 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 2692 |  |      * @param TransactionInputInterface $input | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 2692 |  |      * @return BufferInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function serialize(TransactionInputInterface $input) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return new Buffer( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             $this->outpointSerializer->serialize($input->getOutPoint())->getBinary() . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             $this->varstring->write($input->getScript()->getBuffer()) . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 2602 |  |             $this->uint32le->write($input->getSequence()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 2602 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 2602 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 2602 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 2602 |  |      * @param Parser $parser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 2602 |  |      * @return TransactionInput | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1301 |  |      * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 | 1301 |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     public function fromParser(Parser $parser) | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         return new TransactionInput( | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |             $this->outpointSerializer->fromParser($parser), | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |             new Script($this->varstring->read($parser)), | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |             $this->uint32le->read($parser) | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 | 198 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 198 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param BufferInterface|string $string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @return TransactionInput | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function parse($string) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 198 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         return $this->fromParser(new Parser($string)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 198 |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 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.