Completed
Push — develop ( 659b85...e70242 )
by Mathias
57:23 queued 50:26
created

Select::setViewHelper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/**  */
11
namespace Core\Form\Element;
12
13
use Zend\Form\Element\Select as ZfSelect;
14
15
/**
16
 *
17
 *
18
 * @author Mathias Gelhausen <[email protected]>
19
 */
20
class Select extends ZfSelect implements ViewHelperProviderInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $helper = 'formSelect';
26
27
    /**
28
     * @param string|\Zend\View\Helper\HelperInterface $helper
29
     * @return $this|ViewHelperProviderInterface
30
     */
31
    public function setViewHelper($helper)
32
    {
33
        $this->helper = $helper;
0 ignored issues
show
Documentation Bug introduced by
It seems like $helper can also be of type object<Zend\View\Helper\HelperInterface>. However, the property $helper is declared as type string. Maybe add an additional type check?

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 mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
34
        return $this;
35
    }
36
37
    /**
38
     * @return string|\Zend\View\Helper\HelperInterface
39
     */
40
    public function getViewHelper()
41
    {
42
        return $this->helper;
43
    }
44
}
45