Yes I agree with you that it may not necessarily be wrong which is why I
asked. The first example on my list was probably be the worst to show as it
was the most dubious, but the other ones when shown with more code look like
this -


        // does page have a href?
        if ($href = $page->getHref()) {
            $element = 'a';
            $attribs['href'] = $href;
            $attribs['target'] = $page->getTarget();
        } else {
            $element = 'span';
        }


or 


        if ($partial = $this->getPartial()) {
            return $this->renderPartial($container, $partial);
        } else {
            return $this->renderMenu($container);
        }


I can't really imagine the coding standards for Zend to allow variable
assignment in an IF statement.


Mark Wright-3 wrote:
> 
> I haven't looked into this component so I can't say if these are
> errors or not, but they aren't necessarily wrong depending on the
> intent.
> 
> if ($this->getUseTranslator() && $t = $this->getTranslator()) {
> 
> is the same as
> 
> $t = $this->getTranslator();
> if ($this->getUseTranslator() && $t) {
> 
> So whether or not it is wrong depends. Are we comparing $t to
> $this->getTranslator() or are we assigning  $this->getTranslator() to
> $t and checking if $t is true or not empty? Some people would argue
> that you should never assign a value to a variable inside an IF but it
> still works.
> 
> Anyways, take a deeper look at the code and see what exactly is going on.
> 
> 
> Mark
> 
> On Tue, Apr 14, 2009 at 3:41 PM, SirEdward <[email protected]>
> wrote:
> 
>> 3) I can't help but think there are a few errors in the code. I may be
>> totally wrong as I've only skimmed though, but I've come across bits like
>> this in Menu.php: Line #249
>>
>> if ($this->getUseTranslator() && $t = $this->getTranslator()) {
>>
>> Should it be
>>
>> if ($this->getUseTranslator() && $t == $this->getTranslator()) {
>>
>> #266
>>
>> if ($href = $page->getHref()) {
>>
>> or
>>
>> if ($href == $page->getHref()) {
>>
>> #346
>>
>> if (!$found = $this->findActive($container, $minDepth, $maxDepth)) {
>>
>> or
>>
>> if (!$found == $this->findActive($container, $minDepth, $maxDepth)) {
>>
>> #401
>>
>> if ($found = $this->findActive($container, $minDepth, $maxDepth)) {
>>
>> or if ($found == $this->findActive($container, $minDepth, $maxDepth)) {
>> #663
>>
>> if ($partial = $this->getPartial()) {
>>
>> be
>>
>> if ($partial == $this->getPartial()) {
>>
>> If I am right then Breadcrumbs.php (the only other page I've looked
>> through)
>> has similar possible errors.
>>
> 
> 
> 
> -- 
> Have fun or die trying - but try not to actually die.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Navigation-tp23048648p23057866.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to