1 | <?php |
||
11 | class TreePath implements Buildable |
||
12 | { |
||
13 | const MACRO_METHOD = 'treePath'; |
||
14 | |||
15 | const DEFAULT_SEPARATOR = '|'; |
||
16 | |||
17 | /** |
||
18 | * @var ExtensibleClassMetadata |
||
19 | */ |
||
20 | protected $classMetadata; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $fieldName; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $separator = self::DEFAULT_SEPARATOR; |
||
31 | |||
32 | /** |
||
33 | * @var bool|null |
||
34 | */ |
||
35 | protected $appendId = null; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | protected $startsWithSeparator = false; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $endsWithSeparator = true; |
||
46 | |||
47 | /** |
||
48 | * @param ExtensibleClassMetadata $classMetadata |
||
49 | * @param string $fieldName |
||
50 | * @param string $separator |
||
51 | */ |
||
52 | 14 | public function __construct(ExtensibleClassMetadata $classMetadata, $fieldName, $separator = self::DEFAULT_SEPARATOR) |
|
53 | { |
||
54 | 14 | $this->classMetadata = $classMetadata; |
|
55 | 14 | $this->fieldName = $fieldName; |
|
56 | 14 | $this->separator = $separator; |
|
57 | 14 | } |
|
58 | |||
59 | /** |
||
60 | * Enable TreePath |
||
61 | */ |
||
62 | public static function enable() |
||
68 | |||
69 | /** |
||
70 | * @param string $separator |
||
71 | * |
||
72 | * @return TreePath |
||
73 | */ |
||
74 | 2 | public function separator($separator) |
|
75 | { |
||
76 | 2 | $this->separator = $separator; |
|
77 | |||
78 | 2 | return $this; |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param bool $shouldIt |
||
83 | * |
||
84 | * @return TreePath |
||
85 | */ |
||
86 | 2 | public function appendId($shouldIt = true) |
|
87 | { |
||
88 | 2 | $this->appendId = $shouldIt; |
|
89 | |||
90 | 2 | return $this; |
|
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param bool $doesIt |
||
95 | * |
||
96 | * @return TreePath |
||
97 | */ |
||
98 | 2 | public function startsWithSeparator($doesIt = true) |
|
104 | |||
105 | /** |
||
106 | * @param bool $doesIt |
||
107 | * |
||
108 | * @return TreePath |
||
109 | */ |
||
110 | 2 | public function endsWithSeparator($doesIt = true) |
|
116 | |||
117 | /** |
||
118 | * Execute the build process |
||
119 | */ |
||
120 | 12 | public function build() |
|
134 | |||
135 | /** |
||
136 | * Return the name of the actual extension. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 11 | protected function getExtensionName() |
|
144 | } |
||
145 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.