Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
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 | protected function buildDeserializer() { |
||
27 | $entityIdDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
28 | $entityIdDeserializerMock->expects( $this->any() ) |
||
29 | ->method( 'deserialize' ) |
||
30 | ->with( $this->equalTo( 'P42' ) ) |
||
31 | ->will( $this->returnValue( new PropertyId( 'P42' ) ) ); |
||
32 | |||
33 | $termListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
34 | $termListDeserializerMock->expects( $this->any() ) |
||
35 | ->method( 'deserialize' ) |
||
36 | ->with( $this->equalTo( [ |
||
37 | 'en' => [ |
||
38 | 'lang' => 'en', |
||
39 | 'value' => 'foo' |
||
40 | ] |
||
41 | ] ) ) |
||
42 | ->will( $this->returnValue( new TermList( [ new Term( 'en', 'foo' ) ] ) ) ); |
||
43 | |||
44 | $aliasGroupListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
45 | $aliasGroupListDeserializerMock->expects( $this->any() ) |
||
46 | ->method( 'deserialize' ) |
||
47 | ->with( $this->equalTo( [ |
||
48 | 'en' => [ |
||
49 | 'lang' => 'en', |
||
50 | 'values' => [ 'foo', 'bar' ] |
||
51 | ] |
||
52 | ] ) ) |
||
53 | ->will( $this->returnValue( |
||
54 | new AliasGroupList( [ new AliasGroup( 'en', [ 'foo', 'bar' ] ) ] ) ) |
||
55 | ); |
||
56 | |||
57 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
58 | $statement->setGuid( 'test' ); |
||
59 | |||
60 | $statementListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
61 | $statementListDeserializerMock->expects( $this->any() ) |
||
62 | ->method( 'deserialize' ) |
||
63 | ->with( $this->equalTo( [ |
||
64 | 'P42' => [ |
||
65 | [ |
||
66 | 'mainsnak' => [ |
||
67 | 'snaktype' => 'novalue', |
||
68 | 'property' => 'P42' |
||
69 | ], |
||
70 | 'type' => 'statement', |
||
71 | 'rank' => 'normal' |
||
72 | ] |
||
73 | ] |
||
74 | ] ) ) |
||
75 | ->will( $this->returnValue( new StatementList( [ $statement ] ) ) ); |
||
76 | |||
77 | return new PropertyDeserializer( |
||
78 | $entityIdDeserializerMock, |
||
|
|||
79 | $termListDeserializerMock, |
||
80 | $aliasGroupListDeserializerMock, |
||
81 | $statementListDeserializerMock |
||
82 | ); |
||
83 | } |
||
84 | |||
230 |
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: