| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 55 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 27 | public function testIssue()  | 
            ||
| 28 |     { | 
            ||
| 29 | $mockDriver = $this->createMock(MappingDriver::class);  | 
            ||
| 30 | $mockMetadata = $this->createMock(ClassMetadata::class);  | 
            ||
| 31 | $entityManager = $this->createMock(EntityManagerInterface::class);  | 
            ||
| 32 | |||
| 33 | /* @var $metadataFactory \Doctrine\ORM\Mapping\ClassMetadataFactory|\PHPUnit_Framework_MockObject_MockObject */  | 
            ||
| 34 | $metadataFactory = $this->getMockBuilder(ClassMetadataFactory::class)  | 
            ||
| 35 | ->setMethods(['doLoadMetadata', 'wakeupReflection'])  | 
            ||
| 36 | ->getMock();  | 
            ||
| 37 | |||
| 38 | $configuration = $this->getMockBuilder(Configuration::class)  | 
            ||
| 39 | ->setMethods(['getMetadataDriverImpl'])  | 
            ||
| 40 | ->getMock();  | 
            ||
| 41 | |||
| 42 | $connection = $this->createMock(Connection::class);  | 
            ||
| 43 | |||
| 44 | $configuration  | 
            ||
| 45 | ->expects($this->any())  | 
            ||
| 46 |             ->method('getMetadataDriverImpl') | 
            ||
| 47 | ->will($this->returnValue($mockDriver));  | 
            ||
| 48 | |||
| 49 | $mockMetadata  | 
            ||
| 50 | ->expects($this->any())  | 
            ||
| 51 |             ->method('getDeclaredPropertiesIterator') | 
            ||
| 52 | ->will($this->returnValue(new \ArrayIterator([])));  | 
            ||
| 53 | |||
| 54 | $entityManager  | 
            ||
| 55 | ->expects($this->any())  | 
            ||
| 56 |             ->method('getConfiguration') | 
            ||
| 57 | ->will($this->returnValue($configuration));  | 
            ||
| 58 | |||
| 59 | $entityManager  | 
            ||
| 60 | ->expects($this->any())  | 
            ||
| 61 |             ->method('getConnection') | 
            ||
| 62 | ->will($this->returnValue($connection));  | 
            ||
| 63 | |||
| 64 | $entityManager  | 
            ||
| 65 | ->expects($this->any())  | 
            ||
| 66 |             ->method('getEventManager') | 
            ||
| 67 | ->will($this->returnValue($this->createMock(EventManager::class)));  | 
            ||
| 68 | |||
| 69 | $metadataFactory  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 70 | ->expects($this->any())  | 
            ||
| 71 |             ->method('doLoadMetadata') | 
            ||
| 72 | ->will($this->returnValue($mockMetadata));  | 
            ||
| 73 | |||
| 74 | $metadataFactory  | 
            ||
| 75 | ->expects($this->never())  | 
            ||
| 76 |             ->method('wakeupReflection'); | 
            ||
| 77 | |||
| 78 | $metadataFactory->setEntityManager($entityManager);  | 
            ||
| 79 | |||
| 80 | self::assertSame($mockMetadata, $metadataFactory->getMetadataFor(DDC2359Foo::class));  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 90 | 
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: