1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace UsageFinder\Tests; |
||||||
6 | |||||||
7 | use InvalidArgumentException; |
||||||
8 | use UsageFinder\ClassMethodReference; |
||||||
9 | |||||||
10 | final class ClassMethodReferenceTest extends TestCase |
||||||
11 | { |
||||||
12 | public function testGetName() : void |
||||||
13 | { |
||||||
14 | self::assertSame( |
||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||||
15 | 'Doctrine\Common\Collections\Collection::slice', |
||||||
0 ignored issues
–
show
'Doctrine\Common\Collections\Collection::slice' of type string is incompatible with the type PHPUnit\Framework\T expected by parameter $expected of PHPUnit\Framework\Assert::assertSame() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
16 | (new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getName() |
||||||
17 | ); |
||||||
18 | } |
||||||
19 | |||||||
20 | public function testGetClassName() : void |
||||||
21 | { |
||||||
22 | self::assertSame( |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\Assert::assertSame() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
23 | 'Doctrine\Common\Collections\Collection', |
||||||
0 ignored issues
–
show
'Doctrine\Common\Collections\Collection' of type string is incompatible with the type PHPUnit\Framework\T expected by parameter $expected of PHPUnit\Framework\Assert::assertSame() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
24 | (new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getClassName() |
||||||
25 | ); |
||||||
26 | } |
||||||
27 | |||||||
28 | public function testGetMethodName() : void |
||||||
29 | { |
||||||
30 | self::assertSame( |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\Assert::assertSame() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
31 | 'slice', |
||||||
0 ignored issues
–
show
'slice' of type string is incompatible with the type PHPUnit\Framework\T expected by parameter $expected of PHPUnit\Framework\Assert::assertSame() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
32 | (new ClassMethodReference('Doctrine\Common\Collections\Collection::slice'))->getMethodName() |
||||||
33 | ); |
||||||
34 | } |
||||||
35 | |||||||
36 | /** |
||||||
37 | * @dataProvider provideForTestInvalidClassMethodReference |
||||||
38 | */ |
||||||
39 | public function testInvalidClassMethodReference(string $input, string $message) : void |
||||||
40 | { |
||||||
41 | self::expectException(InvalidArgumentException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
42 | self::expectExceptionMessage($message); |
||||||
0 ignored issues
–
show
The method
expectExceptionMessage() does not exist on UsageFinder\Tests\ClassMethodReferenceTest . Did you maybe mean expectException() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
43 | |||||||
44 | new ClassMethodReference($input); |
||||||
45 | } |
||||||
46 | |||||||
47 | /** |
||||||
48 | * @return array<int, array<int, string>> |
||||||
49 | */ |
||||||
50 | public function provideForTestInvalidClassMethodReference() : array |
||||||
51 | { |
||||||
52 | return [ |
||||||
53 | [ |
||||||
54 | '', |
||||||
55 | 'Invalid ClassMethodReference, empty string given. Format must be ClassName::methodName.', |
||||||
56 | ], |
||||||
57 | [ |
||||||
58 | 'Doctrine\Common\Collections\Collection::', |
||||||
59 | 'You must specify a method name to find. "Doctrine\Common\Collections\Collection::" given.', |
||||||
60 | ], |
||||||
61 | [ |
||||||
62 | 'Doctrine\Common\Collections\Collection:: ', |
||||||
63 | 'You must specify a method name to find. "Doctrine\Common\Collections\Collection:: " given.', |
||||||
64 | ], |
||||||
65 | [ |
||||||
66 | 'Doctrine\Common\Collections\Collection', |
||||||
67 | 'Invalid ClassMethodReference, "Doctrine\Common\Collections\Collection" given. Format must be ClassName::methodName.', |
||||||
68 | ], |
||||||
69 | ]; |
||||||
70 | } |
||||||
71 | } |
||||||
72 |