Conditions | 2 |
Paths | 2 |
Total Lines | 57 |
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 |
||
35 | public function testRendererOutputsForReportWithContents() |
||
36 | { |
||
37 | $writer = new WriterStub(); |
||
38 | |||
39 | $violations = array( |
||
40 | $this->getRuleViolationMock('/bar.php', 1), |
||
41 | $this->getRuleViolationMock('/foo.php', 2), |
||
42 | $this->getRuleViolationMock('/foo.php', 3), |
||
43 | ); |
||
44 | |||
45 | $errors = array( |
||
46 | $this->getErrorMock(), |
||
47 | ); |
||
48 | |||
49 | $report = $this->getReportMock(0); |
||
50 | $report->expects($this->atLeastOnce()) |
||
|
|||
51 | ->method('getRuleViolations') |
||
52 | ->will($this->returnValue(new \ArrayIterator($violations))); |
||
53 | $report->expects($this->atLeastOnce()) |
||
54 | ->method('isEmpty') |
||
55 | ->will($this->returnValue(false)); |
||
56 | $report->expects($this->atLeastOnce()) |
||
57 | ->method('hasErrors') |
||
58 | ->will($this->returnValue(true)); |
||
59 | $report->expects($this->atLeastOnce()) |
||
60 | ->method('getErrors') |
||
61 | ->will($this->returnValue(new \ArrayIterator($errors))); |
||
62 | $report->expects($this->once()) |
||
63 | ->method('getElapsedTimeInMillis') |
||
64 | ->will($this->returnValue(200)); |
||
65 | |||
66 | $renderer = new AnsiRenderer(); |
||
67 | $renderer->setWriter($writer); |
||
68 | |||
69 | $renderer->start(); |
||
70 | $renderer->renderReport($report); |
||
71 | $renderer->end(); |
||
72 | |||
73 | $expectedChunks = [ |
||
74 | PHP_EOL . "FILE: /bar.php" . PHP_EOL . "--------------" . PHP_EOL, |
||
75 | " 1 | \e[31mVIOLATION\e[0m | Test description" . PHP_EOL, |
||
76 | PHP_EOL . "FILE: /foo.php" . PHP_EOL . "--------------" . PHP_EOL, |
||
77 | " 2 | \e[31mVIOLATION\e[0m | Test description" . PHP_EOL, |
||
78 | " 3 | \e[31mVIOLATION\e[0m | Test description" . PHP_EOL, |
||
79 | PHP_EOL . "\e[33mERROR\e[0m while parsing /foo/baz.php" . PHP_EOL . "--------------------------------" . PHP_EOL, |
||
80 | "Error in file \"/foo/baz.php\"" . PHP_EOL, |
||
81 | PHP_EOL . "Found 3 violations and 1 error in 200ms" . PHP_EOL, |
||
82 | ]; |
||
83 | |||
84 | foreach($writer->getChunks() as $i => $chunk) { |
||
85 | $this->assertEquals( |
||
86 | $expectedChunks[$i], |
||
87 | $chunk, |
||
88 | sprintf('Chunk %s did not match expected string', $i) |
||
89 | ); |
||
90 | } |
||
91 | } |
||
92 | |||
140 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.