| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| 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 |
||
| 73 | public function testSnaksOrderDeserialization() { |
||
| 74 | $snaksDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
| 75 | $snaksDeserializerMock->expects( $this->any() ) |
||
| 76 | ->method( 'deserialize' ) |
||
| 77 | ->with( $this->equalTo( [ |
||
| 78 | 'P24' => [ |
||
| 79 | [ |
||
| 80 | 'snaktype' => 'novalue', |
||
| 81 | 'property' => 'P24' |
||
| 82 | ] |
||
| 83 | ], |
||
| 84 | 'P42' => [ |
||
| 85 | [ |
||
| 86 | 'snaktype' => 'somevalue', |
||
| 87 | 'property' => 'P42' |
||
| 88 | ], |
||
| 89 | [ |
||
| 90 | 'snaktype' => 'novalue', |
||
| 91 | 'property' => 'P42' |
||
| 92 | ] |
||
| 93 | ] |
||
| 94 | ] |
||
| 95 | ) ) |
||
| 96 | ->will( $this->returnValue( new SnakList( [ |
||
| 97 | new PropertyNoValueSnak( new PropertyId( 'P24' ) ), |
||
| 98 | new PropertySomeValueSnak( new PropertyId( 'P42' ) ), |
||
| 99 | new PropertyNoValueSnak( new PropertyId( 'P42' ) ) |
||
| 100 | ] ) ) ); |
||
| 101 | |||
| 102 | $referenceDeserializer = new ReferenceDeserializer( $snaksDeserializerMock ); |
||
| 103 | |||
| 104 | $reference = new Reference( new SnakList( [ |
||
| 105 | new PropertySomeValueSnak( new PropertyId( 'P42' ) ), |
||
| 106 | new PropertyNoValueSnak( new PropertyId( 'P42' ) ), |
||
| 107 | new PropertyNoValueSnak( new PropertyId( 'P24' ) ) |
||
| 108 | ] ) ); |
||
| 109 | |||
| 110 | $serialization = [ |
||
| 111 | 'hash' => '20726a1e99eab73834c0f4a25f3c5c2561993e6e', |
||
| 112 | 'snaks' => [ |
||
| 113 | 'P24' => [ |
||
| 114 | [ |
||
| 115 | 'snaktype' => 'novalue', |
||
| 116 | 'property' => 'P24' |
||
| 117 | ] |
||
| 118 | ], |
||
| 119 | 'P42' => [ |
||
| 120 | [ |
||
| 121 | 'snaktype' => 'somevalue', |
||
| 122 | 'property' => 'P42' |
||
| 123 | ], |
||
| 124 | [ |
||
| 125 | 'snaktype' => 'novalue', |
||
| 126 | 'property' => 'P42' |
||
| 127 | ] |
||
| 128 | ] |
||
| 129 | ], |
||
| 130 | 'snaks-order' => [ |
||
| 131 | 'P42', |
||
| 132 | 'P24' |
||
| 133 | ] |
||
| 134 | ]; |
||
| 135 | |||
| 136 | $this->assertTrue( $reference->equals( $referenceDeserializer->deserialize( $serialization ) ) ); |
||
| 137 | } |
||
| 138 | |||
| 166 |
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: