ZF-11062: Unnecessary code

Issue Type: Improvement Created: 2011-02-10T09:17:08.000+0000 Last Updated: 2012-05-14T12:49:41.000+0000 Status: Closed Fix version(s): Reporter: Marcos Gil Fuertes (marcis) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Layout

Related issues: Attachments:


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

<pre class="highlight">
    if (null !== $options) {
        if (is_string($options)) {
        } elseif (is_array($options)) {
        } elseif ($options instanceof Zend_Config) {
        } else {
            require_once 'Zend/Layout/Exception.php';
            throw new Zend_Layout_Exception('Invalid option provided to constructor');

Then, setOptions and setConfig do it again:

<pre class="highlight">
    public function setOptions($options)
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();

    public function setConfig(Zend_Config $config)


Posted by Kai Uwe (kaiuwe) on 2011-02-10T09:36:42.000+0000

A typical use case:

<pre class="highlight">
$layout = new Zend_Layout();

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

The issue can be closed.

Posted by Marcos Gil Fuertes (marcis) on 2011-02-10T11:59:43.000+0000

But not in the __construct method...

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

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.