File tree 24 files changed +42
-42
lines changed
tests/Rule/data/DeadMethodRule
24 files changed +42
-42
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ public function __construct()
15
15
}
16
16
17
17
public function method1 (string $ foo ): void {} // error: Unused DeadMap\ArrayMapTest::method1
18
- public function method2 (): void {}
19
- public function method3 (): void {}
20
- public function method4 (): void {}
21
- public static function method5 (): void {}
18
+ public function method2 (): void {} // error: Unused DeadMap\ArrayMapTest::method2
19
+ public function method3 (): void {} // error: Unused DeadMap\ArrayMapTest::method3
20
+ public function method4 (): void {} // error: Unused DeadMap\ArrayMapTest::method4
21
+ public static function method5 (): void {} // error: Unused DeadMap\ArrayMapTest::method5
22
22
public static function method6 (): void {} // error: Unused DeadMap\ArrayMapTest::method6
23
23
}
24
24
@@ -28,7 +28,7 @@ public function method2(): void {}
28
28
public function method3 (): void {}
29
29
public function method4 (): void {}
30
30
public static function method5 (): void {} // should be reported (https://github.com/phpstan/phpstan-src/pull/3372)
31
- public static function method6 (): void {} // error: Unused DeadMap\Child::method6
31
+ public static function method6 (): void {}
32
32
33
33
}
34
34
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ abstract class TestParent {
62
62
63
63
use TestTrait;
64
64
65
- public function __construct () // error: Unused DeadBasic\TestParent::__construct
65
+ public function __construct ()
66
66
{
67
67
}
68
68
@@ -72,7 +72,7 @@ public function parentMethodUsed(TestChild $child): void
72
72
$ this ->traitMethodUsed ();
73
73
}
74
74
75
- public function overwrittenParentMethodUsedByChild (): void // error: Unused DeadBasic\TestParent::overwrittenParentMethodUsedByChild
75
+ public function overwrittenParentMethodUsedByChild (): void
76
76
{
77
77
78
78
}
@@ -85,7 +85,7 @@ public function parentMethodUnused(): void // error: Unused DeadBasic\TestParen
85
85
86
86
trait TestTrait {
87
87
88
- public function __construct () // error: Unused DeadBasic\TestTrait::__construct
88
+ public function __construct ()
89
89
{
90
90
}
91
91
@@ -94,7 +94,7 @@ public function traitMethodUsed(): void
94
94
95
95
}
96
96
97
- public function traitMethodUnused (): void // error: Unused DeadBasic\TestTrait::traitMethodUnused
97
+ public function traitMethodUnused (): void
98
98
{
99
99
100
100
}
Original file line number Diff line number Diff line change 4
4
5
5
class ClassWithMethod {
6
6
7
- public static function someMethod (): void {}
7
+ public static function someMethod (): void {} // error: Unused ClassStringCall\ClassWithMethod::someMethod
8
8
}
9
9
10
10
/**
Original file line number Diff line number Diff line change 4
4
5
5
interface MyInterface
6
6
{
7
- public function __construct (); // error: Unused CtorInterface\MyInterface::__construct
7
+ public function __construct ();
8
8
}
9
9
10
10
class Child1 implements MyInterface
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function __construct()
11
11
12
12
class Child1 extends ParentClass
13
13
{
14
- public function __construct () // error: Unused Ctor\Child1::__construct
14
+ public function __construct ()
15
15
{
16
16
}
17
17
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class B extends A
20
20
/**
21
21
* @inheritDoc
22
22
*/
23
- public function __construct () // error: Unused DeadParent\B::__construct
23
+ public function __construct ()
24
24
{
25
25
parent ::__construct ();
26
26
}
Original file line number Diff line number Diff line change 4
4
5
5
class Test {
6
6
7
- public static function a (): void {}
8
- public static function b (): void {}
7
+ public static function a (): void {} // error: Unused DynamicMethod\Test::a
8
+ public static function b (): void {} // error: Unused DynamicMethod\Test::b
9
9
10
- public function c (): void {}
11
- public function d (): void {}
10
+ public function c (): void {} // error: Unused DynamicMethod\Test::c
11
+ public function d (): void {} // error: Unused DynamicMethod\Test::d
12
12
}
13
13
14
14
/**
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ public function __construct()
9
9
{
10
10
}
11
11
12
- public function someUnused (): void
12
+ public function someUnused (): void // error: Unused DeadEntrypoint\Entrypoint::someUnused
13
13
{
14
14
Dead::usedMethod ();
15
15
}
Original file line number Diff line number Diff line change 4
4
5
5
interface FooInterface
6
6
{
7
- public function foo (): void ; // error: Unused DeadIndirect\FooInterface::foo
7
+ public function foo (): void ;
8
8
}
9
9
10
10
abstract class FooAbstract
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public function second(): self {
12
12
return $ this ;
13
13
}
14
14
15
- public static function secondStatic (): self {
15
+ public static function secondStatic (): self { // error: Unused Nullsafe\A::secondStatic
16
16
return new self ();
17
17
}
18
18
}
Original file line number Diff line number Diff line change 4
4
5
5
interface Interface1
6
6
{
7
- public function foo (): void ; // error: Unused DeadOver1\Interface1::foo
7
+ public function foo (): void ;
8
8
}
9
9
10
10
interface Interface2
11
11
{
12
- public function foo (): void ; // error: Unused DeadOver1\Interface2::foo
12
+ public function foo (): void ;
13
13
}
14
14
15
15
abstract class AbstractClass implements Interface1, Interface2
Original file line number Diff line number Diff line change 4
4
5
5
interface Interface1
6
6
{
7
- public function foo (): void ; // error: Unused DeadOver2\Interface1::foo
7
+ public function foo (): void ;
8
8
}
9
9
10
10
interface Interface2
11
11
{
12
- public function foo (): void ; // error: Unused DeadOver2\Interface2::foo
12
+ public function foo (): void ;
13
13
}
14
14
15
15
abstract class AbstractClass implements Interface1, Interface2
16
16
{
17
- public abstract function foo (): void ; // error: Unused DeadOver2\AbstractClass::foo
17
+ public abstract function foo (): void ;
18
18
}
19
19
20
20
class Child1 extends AbstractClass
@@ -24,7 +24,7 @@ public function foo(): void {}
24
24
25
25
class Child2 extends AbstractClass
26
26
{
27
- public function foo (): void {} // error: Unused DeadOver2\Child2::foo
27
+ public function foo (): void {}
28
28
}
29
29
30
30
function testIt (Child1 $ child1 ): void
Original file line number Diff line number Diff line change 4
4
5
5
interface Interface1
6
6
{
7
- public function foo (): void ; // error: Unused DeadOver3\Interface1::foo
7
+ public function foo (): void ;
8
8
}
9
9
10
10
interface Interface2
11
11
{
12
- public function foo (): void ; // error: Unused DeadOver3\Interface2::foo
12
+ public function foo (): void ;
13
13
}
14
14
15
15
abstract class AbstractClass implements Interface1, Interface2
16
16
{
17
- public abstract function foo (): void ; // error: Unused DeadOver3\AbstractClass::foo
17
+ public abstract function foo (): void ;
18
18
}
19
19
20
20
class Child1 extends AbstractClass
21
21
{
22
- public function foo (): void {} // error: Unused DeadOver3\Child1::foo
22
+ public function foo (): void {}
23
23
}
24
24
25
25
class Child2 extends AbstractClass
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ public function foo(): void;
9
9
10
10
interface Interface2
11
11
{
12
- public function foo (): void ; // error: Unused DeadOver4\Interface2::foo
12
+ public function foo (): void ;
13
13
}
14
14
15
15
abstract class AbstractClass implements Interface1, Interface2
Original file line number Diff line number Diff line change 4
4
5
5
interface Interface1
6
6
{
7
- public function foo (): void ; // error: Unused DeadOver5\Interface1::foo
7
+ public function foo (): void ;
8
8
}
9
9
10
10
interface Interface2
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public function foo(): void {
19
19
20
20
class Child2 extends AbstractClass
21
21
{
22
- public function foo (): void {} // error: Unused ParentCall1\Child2::foo
22
+ public function foo (): void {}
23
23
}
24
24
25
25
function testIt (Child1 $ child1 ): void
Original file line number Diff line number Diff line change 4
4
5
5
abstract class AbstractClass
6
6
{
7
- public function foo (): void {} // error: Unused ParentCall2\AbstractClass::foo
7
+ public function foo (): void {}
8
8
}
9
9
10
10
class Child1 extends AbstractClass
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function __construct()
11
11
12
12
class AbstractClass extends RootClass
13
13
{
14
- public function __construct () // error: Unused ParentCall4\AbstractClass::__construct
14
+ public function __construct ()
15
15
{
16
16
}
17
17
}
Original file line number Diff line number Diff line change 5
5
trait Trait1 {
6
6
7
7
public static function used (): void {}
8
- public static function unused (): void {} // error: Unused DeadTrait1\Trait1::unused
8
+ public static function unused (): void {}
9
9
}
10
10
11
11
class User1
Original file line number Diff line number Diff line change 5
5
trait MyTrait1 {
6
6
7
7
public function used (): void {}
8
- public function unused (): void {} // error: Unused DeadTrait3\MyTrait1::unused
8
+ public function unused (): void {}
9
9
}
10
10
11
11
interface TraitInterface
12
12
{
13
- public function used (): void ; // error: Unused DeadTrait3\TraitInterface::used
13
+ public function used (): void ;
14
14
}
15
15
16
16
class MyUser1 implements TraitInterface
Original file line number Diff line number Diff line change 4
4
5
5
trait MyTrait1 {
6
6
7
- public function __construct () // error: Unused DeadTrait4\MyTrait1::__construct
7
+ public function __construct ()
8
8
{
9
9
}
10
10
}
Original file line number Diff line number Diff line change 5
5
trait MyTrait1 {
6
6
7
7
// because all children override this method, it is unused
8
- public function used (): void {} // error: Unused DeadTrait5\MyTrait1::used
8
+ public function used (): void {}
9
9
}
10
10
11
11
interface TraitInterface
Original file line number Diff line number Diff line change 3
3
namespace DeadTrait7 ;
4
4
5
5
trait HelloWorld {
6
- public function sayHello () { // error: Unused DeadTrait7\HelloWorld::sayHello
6
+ public function sayHello () {
7
7
echo 'Hello World! ' ;
8
8
}
9
9
}
Original file line number Diff line number Diff line change 3
3
namespace DeadTrait8 ;
4
4
5
5
trait A {
6
- public function smallTalk () { // error: Unused DeadTrait8\A::smallTalk
6
+ public function smallTalk () {
7
7
echo 'a ' ;
8
8
}
9
9
public function bigTalk () {
You can’t perform that action at this time.
0 commit comments