Issues (138)

src/Renderer/DisplayGroup.php (6 issues)

1
<?php
2
3
class Nip_Form_Renderer_DisplayGroup
4
{
5
    /**
6
     * @var Nip_Form_DisplayGroup
7
     */
8
    protected $_group;
9
10
11
    /**
12
     * @return Nip_Form_Renderer_DisplayGroup
13
     */
14
    public function setGroup(Nip_Form_DisplayGroup $group)
15
    {
16
        $this->_group = $group;
17
        return $this;
18
    }
19
20
    /**
21
     * @return Nip_Form_Renderer_DisplayGroup|null
22
     */
23
    public function getGroup()
24
    {
25
        return $this->_group;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->_group returns the type Nip_Form_DisplayGroup which is incompatible with the documented return type Nip_Form_Renderer_DisplayGroup|null.
Loading history...
26
    }
27
28
    public function render()
29
    {
30
        $return = '<fieldset' . $this->renderAttributes() . '>';
31
        $return .= '<legend>' . $this->getGroup()->getLegend() . '</legend>';
0 ignored issues
show
The method getLegend() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        $return .= '<legend>' . $this->getGroup()->/** @scrutinizer ignore-call */ getLegend() . '</legend>';

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
33
        if (count($this->getGroup())) {
0 ignored issues
show
$this->getGroup() of type Nip_Form_Renderer_DisplayGroup|null is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        if (count(/** @scrutinizer ignore-type */ $this->getGroup())) {
Loading history...
34
            $renderer = clone $this->getGroup()->getForm()->getRenderer();
0 ignored issues
show
The method getForm() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
            $renderer = clone $this->getGroup()->/** @scrutinizer ignore-call */ getForm()->getRenderer();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
            $renderer->setElements($this->getGroup()->toArray());
0 ignored issues
show
The method toArray() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $renderer->setElements($this->getGroup()->/** @scrutinizer ignore-call */ toArray());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
            $return .= $renderer->renderElements();
37
        }
38
        $return .= '</fieldset>';
39
        return $return;
40
    }
41
42
    public function renderAttributes($overrides = array())
43
    {
44
        $attribs = $this->getGroup()->getAttribs();
0 ignored issues
show
The method getAttribs() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        $attribs = $this->getGroup()->/** @scrutinizer ignore-call */ getAttribs();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $elementAttribs = $this->getElementAttribs();
46
        $return = '';
47
        foreach ($attribs as $name => $value) {
48
            if (strpos($name, 'data-') === 0 || in_array($name, $elementAttribs)) {
49
                if (in_array($name, array_keys($overrides))) {
50
                    $value = $overrides[$name];
51
                }
52
                $return .= ' ' . $name . '="' . $value . '"';
53
            }
54
        }
55
        return $return;
56
    }
57
58
    public function getElementAttribs()
59
    {
60
        return ['id', 'style', 'class'];
61
    }
62
}
63