ZF-11062: Unnecessary code

Description

At the beginning of "__construct" method, the $options parameter type is checked:


    if (null !== $options) {
        if (is_string($options)) {
            $this->setLayoutPath($options);
        } elseif (is_array($options)) {
            $this->setOptions($options);
        } elseif ($options instanceof Zend_Config) {
            $this->setConfig($options);
        } else {
            require_once 'Zend/Layout/Exception.php';
            throw new Zend_Layout_Exception('Invalid option provided to constructor');
        }
    }

Then, setOptions and setConfig do it again:


    public function setOptions($options)
    {
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        ...

    public function setConfig(Zend_Config $config)
    {
        $this->setOptions($config->toArray());
        ...

Comments

A typical use case:


$layout = new Zend_Layout();

$layout->setOptions($options); // A check is needed
$layout->setConfig($config); // A check is needed

The issue can be closed.

But not in the __construct method...

if (is_array($options) || ($options instanceof Zend_Config)) { $this->setOptions($options); }