| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Moip\Tests\Resource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Moip\Tests\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | class PaymentTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     //todo: credit card hash | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * MoipTest creating a credit card payment, passing all credit card data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     public function testCreditCardPCI() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         $this->mockHttpSession($this->body_order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $order = $this->createOrder()->create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         $this->mockHttpSession($this->body_cc_pay_pci); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $cc = '5555666677778884'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $payment = $order->payments()->setCreditCard(5, 2018, $cc, 123, $this->createCustomer())->execute(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->assertNotEmpty($payment->getFundingInstrument()->creditCard); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $first6 = $payment->getFundingInstrument()->creditCard->first6; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $last4 = $payment->getFundingInstrument()->creditCard->last4; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->assertEquals($first6, substr($cc, 0, 6)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->assertEquals($last4, substr($cc, -4)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * MoipTest creating a billet payment. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     public function testBillet() | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         $this->mockHttpSession($this->body_order); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $order = $this->createOrder()->create(); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         $this->mockHttpSession($this->body_billet_pay); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         $payment = $order->payments()->setBoleto(new \DateTime('today +1day'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             'http://dev.moip.com.br/images/logo-header-moip.png')->execute(); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         $this->assertNotEmpty($payment->getFundingInstrument()->boleto); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 41 |  | View Code Duplication |     public function testCreditCardPCIStore() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->mockHttpSession($this->body_order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $order = $this->createOrder()->create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $cc = '5555666677778884'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->mockHttpSession($this->body_cc_pay_pci_store); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $payment = $order->payments()->setCreditCard(5, 2018, $cc, 123, $this->createCustomer(), false)->execute(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->assertFalse($payment->getFundingInstrument()->creditCard->store); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->assertNotEmpty($payment->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 52 |  | View Code Duplication |     public function testShouldCreateEscrowPaymentWithCreditCard()  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->mockHttpSession($this->body_order); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $order = $this->createOrder()->create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $cc = '5555666677778884'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->mockHttpSession($this->body_cc_pay_pci_escrow); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $payment = $order->payments() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             ->setCreditCard(5, 2018, $cc, 123, $this->createCustomer(), false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             ->setEscrow('teste de descricao') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             ->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertEquals('teste de descricao', $payment->getEscrow()->description); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |  | 
            
                        
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: