1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\Persistence\Mapping; |
6
|
|
|
|
7
|
|
|
use Doctrine\Persistence\Mapping\StaticReflectionService; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use stdClass; |
10
|
|
|
use function count; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @group DCOM-93 |
14
|
|
|
*/ |
15
|
|
|
class StaticReflectionServiceTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
/** @var StaticReflectionService */ |
18
|
|
|
private $reflectionService; |
19
|
|
|
|
20
|
|
|
protected function setUp() : void |
21
|
|
|
{ |
22
|
|
|
$this->reflectionService = new StaticReflectionService(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testShortname() : void |
26
|
|
|
{ |
27
|
|
|
self::assertSame('StaticReflectionServiceTest', $this->reflectionService->getClassShortName(self::class)); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testClassNamespaceName() : void |
31
|
|
|
{ |
32
|
|
|
self::assertSame('', $this->reflectionService->getClassNamespace(stdClass::class)); |
33
|
|
|
self::assertSame(__NAMESPACE__, $this->reflectionService->getClassNamespace(self::class)); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testGetParentClasses() : void |
37
|
|
|
{ |
38
|
|
|
$classes = $this->reflectionService->getParentClasses(self::class); |
39
|
|
|
self::assertTrue(count($classes) === 0, 'The test class ' . self::class . ' should have no parents according to static reflection.'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testGetReflectionClass() : void |
43
|
|
|
{ |
44
|
|
|
$class = $this->reflectionService->getClass(self::class); |
|
|
|
|
45
|
|
|
self::assertNull($class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testGetMethods() : void |
49
|
|
|
{ |
50
|
|
|
self::assertTrue($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods')); |
51
|
|
|
self::assertTrue($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods2')); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testGetAccessibleProperty() : void |
55
|
|
|
{ |
56
|
|
|
$reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'reflectionService'); |
|
|
|
|
57
|
|
|
self::assertNull($reflProp); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.