1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: root |
5
|
|
|
* Date: 02.08.16 |
6
|
|
|
* Time: 0:46. |
7
|
|
|
*/ |
8
|
|
|
namespace samsonframework\container\definition; |
9
|
|
|
|
10
|
|
|
use samsonframework\container\definition\reference\ReferenceInterface; |
11
|
|
|
use samsonframework\container\exception\ReferenceNotImplementsException; |
12
|
|
|
use samsonframework\container\metadata\ClassMetadata; |
13
|
|
|
use samsonframework\container\metadata\PropertyMetadata; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class PropertyDefinition |
17
|
|
|
* |
18
|
|
|
* @package samsonframework\container\definition |
19
|
|
|
*/ |
20
|
|
|
class PropertyDefinition extends AbstractPropertyDefinition implements PropertyBuilderInterface |
21
|
|
|
{ |
22
|
|
|
/** @var string Property name */ |
23
|
|
|
protected $propertyName; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Define argument |
27
|
|
|
* |
28
|
|
|
* @param ReferenceInterface $dependency |
29
|
|
|
* @return PropertyDefinition |
30
|
|
|
*/ |
31
|
1 |
|
public function defineDependency(ReferenceInterface $dependency): PropertyDefinition |
32
|
|
|
{ |
33
|
1 |
|
$this->dependency = $dependency; |
34
|
|
|
|
35
|
1 |
|
return $this; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get property metadata |
40
|
|
|
* |
41
|
|
|
* @param ClassMetadata $classMetadata |
42
|
|
|
* @return PropertyMetadata |
43
|
|
|
* @throws ReferenceNotImplementsException |
44
|
|
|
*/ |
45
|
|
|
public function toPropertyMetadata(ClassMetadata $classMetadata): PropertyMetadata |
46
|
|
|
{ |
47
|
|
|
$propertyMetadata = new PropertyMetadata($classMetadata); |
48
|
|
|
$propertyMetadata->name = $this->getPropertyName(); |
49
|
|
|
$propertyMetadata->dependency = $this->resolveReference($this->getValue()); |
|
|
|
|
50
|
|
|
|
51
|
|
|
return $propertyMetadata; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getPropertyName(): string |
58
|
|
|
{ |
59
|
|
|
return $this->propertyName; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $propertyName |
64
|
|
|
* @return AbstractPropertyDefinition |
65
|
|
|
*/ |
66
|
2 |
|
public function setPropertyName(string $propertyName): AbstractPropertyDefinition |
67
|
|
|
{ |
68
|
2 |
|
$this->propertyName = $propertyName; |
69
|
|
|
|
70
|
2 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.