1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ORM\Mapping; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Types\Type; |
8
|
|
|
use Doctrine\ORM\Reflection\ReflectionService; |
9
|
|
|
|
10
|
|
|
class FieldMetadata extends LocalColumnMetadata implements Property |
11
|
|
|
{ |
12
|
|
|
/** @var ComponentMetadata */ |
13
|
|
|
protected $declaringClass; |
14
|
|
|
|
15
|
|
|
/** @var \ReflectionProperty */ |
16
|
|
|
protected $reflection; |
17
|
|
|
|
18
|
|
|
/** @var string */ |
19
|
|
|
protected $name; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $columnName |
23
|
|
|
* @param Type $type |
24
|
|
|
* |
25
|
|
|
* @todo Leverage this implementation instead of default, simple constructor |
26
|
|
|
*/ |
27
|
|
|
/*public function __construct(string $name, string $columnName, Type $type) |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
parent::__construct($columnName, $type); |
30
|
|
|
|
31
|
|
|
$this->name = $name; |
32
|
|
|
}*/ |
33
|
|
|
|
34
|
408 |
|
public function __construct(string $name) |
35
|
|
|
{ |
36
|
408 |
|
$this->name = $name; |
37
|
408 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
800 |
|
public function getDeclaringClass() : ComponentMetadata |
43
|
|
|
{ |
44
|
800 |
|
return $this->declaringClass; |
45
|
|
|
} |
46
|
|
|
|
47
|
407 |
|
public function setDeclaringClass(ComponentMetadata $declaringClass) : void |
48
|
|
|
{ |
49
|
407 |
|
$this->declaringClass = $declaringClass; |
50
|
407 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
888 |
|
public function getName() : string |
56
|
|
|
{ |
57
|
888 |
|
return $this->name; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
1055 |
|
public function setValue($object, $value) : void |
64
|
|
|
{ |
65
|
1055 |
|
$this->reflection->setValue($object, $value); |
66
|
1055 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
1065 |
|
public function getValue($object) |
72
|
|
|
{ |
73
|
1065 |
|
return $this->reflection->getValue($object); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
public function isAssociation() : bool |
80
|
|
|
{ |
81
|
|
|
return false; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function isField() : bool |
88
|
|
|
{ |
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
1978 |
|
public function setReflectionProperty(\ReflectionProperty $reflectionProperty) : void |
96
|
|
|
{ |
97
|
1978 |
|
$this->reflection = $reflectionProperty; |
98
|
1978 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
1623 |
|
public function wakeupReflection(ReflectionService $reflectionService) : void |
104
|
|
|
{ |
105
|
1623 |
|
$this->setReflectionProperty( |
106
|
1623 |
|
$reflectionService->getAccessibleProperty($this->declaringClass->getClassName(), $this->name) |
107
|
|
|
); |
108
|
1623 |
|
} |
109
|
|
|
} |
110
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.