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 |
||
136 | public function testProcessOnUnmatchableEditProtectionToRemoveAnnotation() { |
||
137 | |||
138 | $semanticData = $this->semanticDataFactory->newEmptySemanticData( |
||
139 | $this->dataItemFactory->newDIWikiPage( __METHOD__, NS_SPECIAL ) |
||
140 | ); |
||
141 | |||
142 | $dataItem = $this->dataItemFactory->newDIBoolean( true ); |
||
143 | $dataItem->setOption( EditProtectedPropertyAnnotator::SYSTEM_ANNOTATION, true ); |
||
|
|||
144 | |||
145 | $semanticData->addPropertyObjectValue( |
||
146 | $this->dataItemFactory->newDIProperty( '_EDIP' ), |
||
147 | $dataItem |
||
148 | ); |
||
149 | |||
150 | $parserOutput = $this->getMockBuilder( '\ParserOutput' ) |
||
151 | ->disableOriginalConstructor() |
||
152 | ->getMock(); |
||
153 | |||
154 | $parserOutput->expects( $this->once() ) |
||
155 | ->method( 'getExtensionData' ) |
||
156 | ->will( $this->returnValue( $semanticData ) ); |
||
157 | |||
158 | $title = $this->getMockBuilder( '\Title' ) |
||
159 | ->disableOriginalConstructor() |
||
160 | ->getMock(); |
||
161 | |||
162 | $title->expects( $this->any() ) |
||
163 | ->method( 'getDBKey' ) |
||
164 | ->will( $this->returnValue( 'Foo' ) ); |
||
165 | |||
166 | $title->expects( $this->any() ) |
||
167 | ->method( 'getNamespace' ) |
||
168 | ->will( $this->returnValue( NS_SPECIAL ) ); |
||
169 | |||
170 | $editInfoProvider = $this->getMockBuilder( '\SMW\MediaWiki\EditInfoProvider' ) |
||
171 | ->disableOriginalConstructor() |
||
172 | ->getMock(); |
||
173 | |||
174 | $editInfoProvider->expects( $this->once() ) |
||
175 | ->method( 'getOutput' ) |
||
176 | ->will( $this->returnValue( $parserOutput ) ); |
||
177 | |||
178 | $instance = new ArticleProtectComplete( |
||
179 | $title, |
||
180 | $editInfoProvider |
||
181 | ); |
||
182 | |||
183 | $instance->setLogger( $this->spyLogger ); |
||
184 | $instance->setEditProtectionRight( 'Foo2' ); |
||
185 | |||
186 | $protections = array( 'edit' => 'Foo' ); |
||
187 | $reason = ''; |
||
188 | |||
189 | $instance->process( $protections, $reason ); |
||
190 | |||
191 | $this->assertContains( |
||
192 | 'ArticleProtectComplete removeProperty `Is edit protected`', |
||
193 | $this->spyLogger->getMessagesAsString() |
||
194 | ); |
||
195 | } |
||
196 | |||
198 |
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: