Skip to content

Commit 96c98c0

Browse files
committed
Generic/UselessOverridingMethod: improve code coverage
1 parent 5065b44 commit 96c98c0

6 files changed

+60
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,26 @@ class Bar {
2222
public function export($a, $b = null) {
2323
return parent::export($a);
2424
}
25+
26+
public function ignoreNoParent($a, $b) {
27+
return $a + $b;
28+
}
29+
30+
public function differentParentMethod($a, $b) {
31+
return parent::anotherMethod($a, $b);
32+
}
33+
34+
public function methodCallWithExpression($a, $b) {
35+
return parent::methodCallWithExpression(($a + $b), ($b));
36+
}
37+
38+
public function uselessMethodCallWithExpression($a, $b) {
39+
return parent::uselessMethodCallWithExpression(($a), ($b));
40+
}
41+
42+
public function contentAfterCallingParent() {
43+
parent::contentAfterCallingParent();
44+
45+
return 1;
46+
}
2547
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// Intentional parse error (missing opening bracket). Testing that the sniff is *not* triggered
4+
// in this case.
5+
6+
class FooBar {
7+
public function __construct()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Intentional parse error (missing double colon after parent keyword). Testing that the sniff is *not* triggered
4+
// in this case.
5+
6+
class FooBar {
7+
public function __construct() {
8+
parent
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Intentional parse error (missing parent method opening parenthesis).
4+
// Testing that the sniff is *not* triggered in this case.
5+
6+
class FooBar {
7+
public function __construct() {
8+
parent::__construct
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// Intentional parse error (missing semicolon).
4+
// Testing that the sniff is *not* triggered in this case.
5+
6+
class FooBar {
7+
public function __construct() {
8+
parent::__construct()
9+
}
10+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function getWarningList($testFile='')
5252
return [
5353
4 => 1,
5454
16 => 1,
55+
38 => 1,
5556
];
5657
default:
5758
return [];

0 commit comments

Comments
 (0)