Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic/UselessOverridingMethod: improve code coverage #250

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

class FooBar {
public function __construct($a, $b) {
parent::__construct($a, $b);
}
}

class BarFoo {
public function __construct($a, $b) {
parent::__construct($a, 'XML', $b);
}
}

class Foo {
public function export($a, $b = null) {
return parent::export($a, $b);
}
}

class Bar {
public function export($a, $b = null) {
return parent::export($a);
}

public function ignoreNoParent($a, $b) {
return $a + $b;
}

public function differentParentMethod($a, $b) {
return parent::anotherMethod($a, $b);
}

public function methodCallWithExpression($a, $b) {
return parent::methodCallWithExpression(($a + $b), ($b));
}

public function uselessMethodCallWithExpression($a, $b) {
return parent::uselessMethodCallWithExpression(($a), ($b));
}

public function contentAfterCallingParent() {
parent::contentAfterCallingParent();

return 1;
}

public function ignoreNoParentVoidMethod($a, $b) {
$c = $a + $b;
}

public function modifiesParentReturnValue($a, $b) {
return parent::modifiesParentReturnValue($a, $b) + $b;
}

public function uselessMethodCallTrailingComma($a) {
return parent::uselessMethodCallTrailingComma($a,);
}

public function differentParameterOrder($a, $b) {
return parent::differentParameterOrder($b, $a);
}

public function sameNumberDifferentParameters($a, $b) {
return parent::sameNumberDifferentParameters($this->prop[$a], $this->{$b});
}
}

abstract class AbstractFoo {
abstract public function sniffShouldBailEarly();
}

interface InterfaceFoo {
public function sniffShouldBailEarly();
}

trait TraitFoo {
abstract public function sniffShouldBailEarly();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// Intentional parse error (missing opening bracket). Testing that the sniff is *not* triggered
// in this case.

class FooBar {
public function __construct()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// Intentional parse error (missing double colon after parent keyword). Testing that the sniff is *not* triggered
// in this case.

class FooBar {
public function __construct() {
parent
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// Intentional parse error (missing parent method opening parenthesis).
// Testing that the sniff is *not* triggered in this case.

class FooBar {
public function __construct() {
parent::__construct
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// Intentional parse error (missing semicolon).
// Testing that the sniff is *not* triggered in this case.

class FooBar {
public function __construct() {
parent::__construct()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ public function getErrorList()
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getWarningList()
public function getWarningList($testFile='')
{
return [
4 => 1,
16 => 1,
];
switch ($testFile) {
case 'UselessOverridingMethodUnitTest.1.inc':
return [
4 => 1,
16 => 1,
38 => 1,
56 => 1,
];
default:
return [];
}

}//end getWarningList()

Expand Down
Loading