| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| 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 |
||
| 29 | public function testVisit() |
||
| 30 | { |
||
| 31 | $visitor = $this->getVisitor(); |
||
| 32 | $generator = $this->getGenerator(); |
||
| 33 | |||
| 34 | $generator->startDocument(null); |
||
| 35 | |||
| 36 | $UserGroupRefList = new UserGroupRefList( |
||
| 37 | array( |
||
| 38 | new RestUserGroup( |
||
| 39 | new UserGroup(), |
||
| 40 | $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType'), |
||
| 41 | new ContentInfo(), |
||
| 42 | new Location( |
||
| 43 | array( |
||
| 44 | 'pathString' => '/1/5/14', |
||
| 45 | 'path' => array(1, 5, 14), |
||
| 46 | ) |
||
| 47 | ), |
||
| 48 | array() |
||
| 49 | ), |
||
| 50 | new RestUserGroup( |
||
| 51 | new UserGroup(), |
||
| 52 | $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType'), |
||
| 53 | new ContentInfo(), |
||
| 54 | new Location( |
||
| 55 | array( |
||
| 56 | 'pathString' => '/1/5/13', |
||
| 57 | 'path' => array(1, 5, 13), |
||
| 58 | ) |
||
| 59 | ), |
||
| 60 | array() |
||
| 61 | ), |
||
| 62 | ), |
||
| 63 | '/some/path', |
||
| 64 | 14 |
||
| 65 | ); |
||
| 66 | |||
| 67 | $this->setVisitValueObjectExpectations([ |
||
| 68 | new ResourceRouteReference('ezpublish_rest_loadUserGroup', ['groupPath' => '1/5/14']), |
||
|
|
|||
| 69 | new ResourceRouteReference('ezpublish_rest_unassignUserFromUserGroup', ['userId' => $UserGroupRefList->userId, 'groupPath' => 14]), |
||
| 70 | new ResourceRouteReference('ezpublish_rest_loadUserGroup', ['groupPath' => '1/5/13']), |
||
| 71 | new ResourceRouteReference('ezpublish_rest_unassignUserFromUserGroup', ['userId' => $UserGroupRefList->userId, 'groupPath' => 13]), |
||
| 72 | ]); |
||
| 73 | |||
| 74 | $visitor->visit( |
||
| 75 | $this->getVisitorMock(), |
||
| 76 | $generator, |
||
| 77 | $UserGroupRefList |
||
| 78 | ); |
||
| 79 | |||
| 80 | $result = $generator->endDocument(null); |
||
| 81 | |||
| 82 | $this->assertNotNull($result); |
||
| 83 | |||
| 84 | $dom = new \DOMDocument(); |
||
| 85 | $dom->loadXml($result); |
||
| 86 | |||
| 87 | return $dom; |
||
| 88 | } |
||
| 89 | |||
| 150 |
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: