Re: [Template] Design issues

From: Date: Fri, 11 Jun 2004 19:08:07 +0000
Subject: Re: [Template] Design issues
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30521@lists.php.net to get a copy of this message
you'll have to refresh - i refactored it alredy :) Paul M Jones wrote:
Another pestering question; is this part in output() done?
        // make the data available
        // this still needs some thought:
        // flexy uses an object to get around the rather nasty
        // issue of having to run extract.
        // - how to flag this up ? - compiler.uses_t (assigned by the compiler.. backend)
               $t = isset($this->options['compiler.uses_t']) && !$this->data['object']) ? new StdClass : false;
               if ($this->data['variables']) {
            if ($t !== false;) {
                $t = (object) $this->data['variables'];
            }
            extract($this->data['variables']);
        }
               if ($this->data['byref']) {
            foreach(array_keys($this->data['byref']) as $_k) {
                $$_k = &$this->$this->data['byref'][$_k];
                if ($t !== false;) {
                    $t->$k = &$this->$this->data['byref'][$_k];
                }
            }
        }
               // make the object available as $t!
        if ($t === false && $this->data['object']) {
            $t = &$this->data['object']
        }
...Becuase it seems to me that $t gets set regardless of whether or not compiler_uses_t. It also looks like vars and refs get extracted regarless of using $t or not. Obviously I don't understand what's going on here. Anyway, a little cleanup makes it more readable for dummies.
        // make the data available
        // this still needs some thought:
        // flexy uses an object to get around the rather nasty
        // issue of having to run extract.
        // - how to flag this up ? - compiler.uses_t (assigned by the compiler.. backend)
               if (isset($this->options['compiler.uses_t']) && ! $this->data['object']) {
            $t = new StdClass;
        } else {
            $t = false;
        }
               if ($this->data['variables']) {
            if ($t) {
                $t = (object) $this->data['variables'];
            }
            extract($this->data['variables']);
        }
               if ($this->data['byref']) {
            foreach(array_keys($this->data['byref']) as $_k) {
                $$_k = &$this->$this->data['byref'][$_k];
                if ($t !== false;) {
                    $t->$k = &$this->$this->data['byref'][$_k];
                }
            }
        }
               // make the object available as $t!
        if (! $t && $this->data['object']) {
            $t = &$this->data['object']
        }


« previous php.pear.dev (#30521) next »