Skip to content

Commit ee237b4

Browse files
committed
Generic/UnusedFunctionParameter: improve code coverage
1 parent 13de1c1 commit ee237b4

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,26 @@ class MagicMethodsWithParamsNotDictatedByPHPInChildClass extends SomeParent{
249249
$this->foo = $foo;
250250
}
251251
}
252+
253+
/**
254+
* Methods that throw an exception or return on the first line and are part
255+
* of a class that implements an interface should not trigger the sniff.
256+
*/
257+
class InterfaceMethodNotImplement implements SomeInterface {
258+
public function notImplemented($param) {
259+
throw new Exception('Not implemented.');
260+
}
261+
262+
public function notImplemented2($param) {
263+
return 'Not implemented.';
264+
}
265+
}
266+
267+
/**
268+
* Should trigger the sniff as this method is not part of an interface.
269+
*/
270+
class MethodThrowsException {
271+
public function throwsException($param) {
272+
throw new Exception();
273+
}
274+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// Intentional parse error (missing opening parenthesis). Testing that the sniff is *not* triggered
4+
// in this case.
5+
function syntaxError
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// Intentional parse error (missing opening bracket). Testing that the sniff is *not* triggered
4+
// in this case.
5+
function syntaxError()

src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function getWarningList($testFile='')
6565
232 => 2,
6666
244 => 2,
6767
248 => 2,
68+
271 => 1,
6869
];
6970

7071
default:

0 commit comments

Comments
 (0)