| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Tests\Nyholm\Psr7\Factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Nyholm\Psr7\Factory\HttplugFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Psr\Http\Message\StreamInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Psr\Http\Message\UriInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class HttplugFactoryTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 14 |  | View Code Duplication |     public function testCreateRequest() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         $factory = new HttplugFactory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $r = $factory->createRequest('POST', 'https://nyholm.tech', ['Content-Type' => 'text/html'], 'foobar', '2.0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $this->assertEquals('POST', $r->getMethod()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $this->assertEquals('https://nyholm.tech', $r->getUri()->__toString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->assertEquals('2.0', $r->getProtocolVersion()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $this->assertEquals('foobar', $r->getBody()->__toString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $headers = $r->getHeaders(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->assertCount(2, $headers); // Including HOST | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->assertArrayHasKey('Content-Type', $headers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->assertEquals('text/html', $headers['Content-Type'][0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 30 |  | View Code Duplication |     public function testCreateResponse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $factory = new HttplugFactory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $r = $factory->createResponse(217, 'Perfect', ['Content-Type' => 'text/html'], 'foobar', '2.0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->assertEquals(217, $r->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->assertEquals('Perfect', $r->getReasonPhrase()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->assertEquals('2.0', $r->getProtocolVersion()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->assertEquals('foobar', $r->getBody()->__toString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $headers = $r->getHeaders(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->assertCount(1, $headers); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->assertArrayHasKey('Content-Type', $headers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->assertEquals('text/html', $headers['Content-Type'][0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     public function testCreateStream() | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         $factory = new HttplugFactory(); | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         $stream = $factory->createStream('foobar'); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         $this->assertInstanceOf(StreamInterface::class, $stream); | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         $this->assertEquals('foobar', $stream->__toString()); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     public function testCreateUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $factory = new HttplugFactory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $uri = $factory->createUri('https://nyholm.tech/foo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertInstanceOf(UriInterface::class, $uri); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertEquals('https://nyholm.tech/foo', $uri->__toString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: