[PHP-BUG] Bug #51555 [NEW]: Internal class reference resets the attribute

[email protected] ("sinisaculic at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             
Operating system: Windows 7
PHP version:      5.3SVN-2010-04-14 (snap)
Package:          Class/Object related
Bug Type:         Bug
Bug description:Internal class reference resets the attribute

Description:
------------
I know it is uncommon usage of reference but i have  a pretty complicated 
equation 
inside a function, and i referenced a value like $a &= %this->bla...
It is easier to write $a instead $this->a... in case you have a BIG
equation...

 And imagine my surprise when i saw that the value was not set... my guess
is 
that 
this code somehow screws the internal references....  Searched here and
nothing 
showed up for classes... just run the script it should  output the error...

don`t 
know about UNIX OP but i doubt it is different... 
here is how i get the error:

class a {
    
   public $t;
   function buga(){
       $this->t = 'buga';
   }
   function bla(){
       
       $b &=$this->t;
       echo $b;
   }
}
$a= new a;
$a->buga();
$a->bla(); //this outputs Notice: Undefined variable: b in C:\...\test.php
on 
line XX

I use Wamp Server package 2.0f latest version... Hope i was right about
it... if 
not, Sorry...

With respect Siniša Čulić at [email protected]

Test script:
---------------
class a {
    
   public $t;
   function buga(){
       $this->t = 'buga';
   }
   function bla(){
       
       $b &=$this->t;
       echo $b;
   }
}
$a= new a;
$a->buga();
$a->bla(); //this outputs Notice: Undefined variable: b in C:\...\test.php
on line XX

Expected result:
----------------
This should output just bla

Actual result:
--------------
But it outputs a notice... and no variable...
this outputs Notice: Undefined variable: b in C:\...\test.php on line XX

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51555&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51555&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51555&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51555&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51555&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51555&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51555&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51555&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51555&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51555&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51555&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51555&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51555&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51555&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51555&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51555&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51555&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51555&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51555&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51555&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51555&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51555&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.