1 | <?php |
||||
2 | |||||
3 | use Nip\Collections\Collection; |
||||
4 | use Nip\Form\AbstractForm; |
||||
5 | use Nip\Form\Elements\AbstractElement; |
||||
6 | |||||
7 | /** |
||||
8 | * Class Nip_Form_DisplayGroup |
||||
9 | */ |
||||
10 | class Nip_Form_DisplayGroup extends Collection |
||||
11 | { |
||||
12 | use \Nip\Form\Utility\HasAttributesTrait; |
||||
13 | |||||
14 | /** |
||||
15 | * @var Nip_Form |
||||
16 | */ |
||||
17 | protected $_form; |
||||
18 | |||||
19 | protected $renderer; |
||||
20 | |||||
21 | /** |
||||
22 | * @return Nip_Form|null |
||||
23 | */ |
||||
24 | public function getForm() |
||||
25 | { |
||||
26 | return $this->_form; |
||||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * @param AbstractForm $form |
||||
31 | * @return Nip_Form_DisplayGroup |
||||
32 | */ |
||||
33 | 1 | public function setForm(AbstractForm $form) |
|||
34 | { |
||||
35 | 1 | $this->_form = $form; |
|||
0 ignored issues
–
show
|
|||||
36 | |||||
37 | 1 | return $this; |
|||
38 | } |
||||
39 | |||||
40 | /** |
||||
41 | * @param AbstractElement $element |
||||
42 | * @return $this |
||||
43 | */ |
||||
44 | 1 | public function addElement(AbstractElement $element) |
|||
45 | { |
||||
46 | 1 | $this[$element->getUniqueId()] = $element; |
|||
47 | |||||
48 | 1 | return $this; |
|||
49 | } |
||||
50 | |||||
51 | /** |
||||
52 | * @param string $legend |
||||
53 | * @return Nip_Form_DisplayGroup |
||||
54 | */ |
||||
55 | 1 | public function setLegend($legend) |
|||
56 | { |
||||
57 | 1 | return $this->setAttrib('legend', (string)$legend); |
|||
58 | } |
||||
59 | |||||
60 | /** |
||||
61 | * @return mixed|null |
||||
62 | */ |
||||
63 | public function getLegend() |
||||
64 | { |
||||
65 | return $this->getAttrib('legend'); |
||||
66 | } |
||||
67 | |||||
68 | /** |
||||
69 | * @return mixed |
||||
70 | */ |
||||
71 | public function render() |
||||
72 | { |
||||
73 | return $this->getRenderer()->render(); |
||||
74 | } |
||||
75 | |||||
76 | /** |
||||
77 | * @return Nip_Form_Renderer_DisplayGroup |
||||
78 | */ |
||||
79 | public function getRenderer() |
||||
80 | { |
||||
81 | if (!$this->renderer) { |
||||
82 | $this->renderer = $this->getNewRenderer(); |
||||
83 | } |
||||
84 | |||||
85 | return $this->renderer; |
||||
86 | } |
||||
87 | |||||
88 | /** |
||||
89 | * @param string $type |
||||
90 | * @return Nip_Form_Renderer_DisplayGroup |
||||
91 | */ |
||||
92 | public function getNewRenderer($type = 'basic') |
||||
0 ignored issues
–
show
The parameter
$type is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
93 | { |
||||
94 | $name = 'Nip_Form_Renderer_DisplayGroup'; |
||||
95 | /** @var Nip_Form_Renderer_DisplayGroup $renderer */ |
||||
96 | $renderer = new $name(); |
||||
97 | $renderer->setGroup($this); |
||||
98 | |||||
99 | return $renderer; |
||||
100 | } |
||||
101 | } |
||||
102 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.