| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| 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 |
||
| 26 | public function testVisit() |
||
| 27 | { |
||
| 28 | $visitor = $this->getVisitor(); |
||
| 29 | $generator = $this->getGenerator(); |
||
| 30 | |||
| 31 | $generator->startDocument(null); |
||
| 32 | |||
| 33 | $location = new RestLocation( |
||
| 34 | new Location( |
||
| 35 | array( |
||
| 36 | 'id' => 1, |
||
| 37 | 'priority' => 0, |
||
| 38 | 'hidden' => false, |
||
| 39 | 'invisible' => true, |
||
| 40 | 'remoteId' => 'remote-id', |
||
| 41 | 'parentLocationId' => null, |
||
| 42 | 'pathString' => '/1', |
||
| 43 | 'depth' => 3, |
||
| 44 | 'sortField' => Location::SORT_FIELD_PATH, |
||
| 45 | 'sortOrder' => Location::SORT_ORDER_ASC, |
||
| 46 | 'contentInfo' => new ContentInfo( |
||
| 47 | array( |
||
| 48 | 'id' => 42, |
||
| 49 | 'contentTypeId' => 4, |
||
| 50 | 'name' => 'A Node, long lost', |
||
| 51 | ) |
||
| 52 | ), |
||
| 53 | ) |
||
| 54 | ), |
||
| 55 | // Dummy value for ChildCount |
||
| 56 | 0 |
||
| 57 | ); |
||
| 58 | |||
| 59 | $this->addRouteExpectation( |
||
| 60 | 'ezpublish_rest_loadLocation', |
||
| 61 | array('locationPath' => '1'), |
||
| 62 | '/content/locations/1' |
||
| 63 | ); |
||
| 64 | |||
| 65 | $this->setVisitValueObjectExpectations([ |
||
| 66 | new ResourceRouteReference('ezpublish_rest_loadLocationChildren', array('locationPath' => '1')), |
||
|
|
|||
| 67 | new ResourceRouteReference('ezpublish_rest_loadContent', array('contentId' => $location->location->contentId)), |
||
| 68 | new ResourceRouteReference('ezpublish_rest_listLocationURLAliases', array('locationPath' => '1')), |
||
| 69 | new ResourceRouteReference('ezpublish_rest_loadContent', array('contentId' => $location->location->contentId), 'ContentInfo'), |
||
| 70 | $this->isInstanceOf('eZ\Publish\Core\REST\Server\Values\RestContent'), |
||
| 71 | ]); |
||
| 72 | |||
| 73 | $visitor->visit( |
||
| 74 | $this->getVisitorMock(), |
||
| 75 | $generator, |
||
| 76 | $location |
||
| 77 | ); |
||
| 78 | |||
| 79 | $result = $generator->endDocument(null); |
||
| 80 | |||
| 81 | $this->assertNotNull($result); |
||
| 82 | |||
| 83 | return $result; |
||
| 84 | } |
||
| 85 | |||
| 242 |
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: