1 | <?php |
||
2 | |||
3 | class Nip_Form_Element_RadioGroup extends Nip_Form_Element_Input_Group |
||
4 | { |
||
5 | protected $_type = 'radioGroup'; |
||
6 | |||
7 | /** |
||
8 | * @return Nip\Form\Elements\AbstractElement |
||
9 | */ |
||
10 | 3 | public function getNewElement() |
|
11 | { |
||
12 | 3 | $element = $this->getForm()->getNewElement('radio'); |
|
13 | 3 | $element->setName($this->getName()); |
|
0 ignored issues
–
show
|
|||
14 | |||
15 | 3 | return $element; |
|
16 | } |
||
17 | |||
18 | /** |
||
19 | * @param $value |
||
20 | * @return $this |
||
21 | */ |
||
22 | public function setValue($value) |
||
23 | { |
||
24 | $elements = $this->getElements(); |
||
25 | foreach ($elements as $element) { |
||
26 | if ($element->getValue() == $value) { |
||
27 | $element->setChecked(true); |
||
28 | break; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | return parent::setValue($value); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param $boolean |
||
37 | * @return Nip_Form_Element_RadioGroup |
||
38 | */ |
||
39 | 2 | public function autoSelectFirst($boolean = true) |
|
40 | { |
||
41 | 2 | return $this->setOption('autoSelectFirst', $boolean === true); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return bool |
||
46 | */ |
||
47 | 5 | public function isAutoSelectFirst() |
|
48 | { |
||
49 | 5 | if ($this->hasOption('autoSelectFirst') && $this->getOption('autoSelectFirst') == false) { |
|
0 ignored issues
–
show
Are you sure the usage of
$this->getOption('autoSelectFirst') targeting Nip\Form\Elements\AbstractElement::getOption() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
50 | 1 | return false; |
|
51 | } |
||
52 | |||
53 | 4 | return true; |
|
54 | } |
||
55 | } |
||
56 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.