From:             zhalassy at loginet dot hu
Operating system: Irrelevant
PHP version:      5.2.12
PHP Bug Type:     Arrays related
Bug description:  === could be a bit smarter with arrays...

Description:
------------
At the moment, you can't do things like:

$GLOBALS === $GLOBALS;

or

$a = array('a' => &$a); $a === $a['a'];

both causes fatal error claiming too deep nesting level.

I find it rather strange that you can use references, but you can't test
if something is referencing the same thing or not...

It would be nice to have some ==== or is_same(&$a,&$b) function which
would just do a lookup in the symbol table and if the two variables
referencing the same thing it would return true, false otherwise.


Reproduce code:
---------------
$a = is_same($GLOBALS,$GLOBALS);

$x = array('x' => &$x);
$b = is_same($x, $x['x']);

$x1 = array('c' => &$x1);
$x2 = array('c' => &$x2); //same layout, but not the same variable;
$c = is_same($x1,$x2);

$y1 = "test";
$y2 = $y1; /* plain assignement, maybe same till y1 or y2 not changed, but
is_same() shouldn't get affected by optimization behaviour */
$d = is_same($y1,$y2);

$z1 = "test2";
$z2 = &$z1; //or $z2 =& $z1;
$e = is_same($z1,$z2);

Expected result:
----------------
$a === true;
$b === true;
$c === false;
$d === false;
$e === true;



Actual result:
--------------
No way to do this ATM (AFAIK). But please tell me if i didn't read the
documentation properly...

-- 
Edit bug report at http://bugs.php.net/?id=50739&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50739&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50739&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50739&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50739&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50739&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50739&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50739&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50739&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50739&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50739&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50739&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50739&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50739&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50739&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50739&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50739&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50739&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50739&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50739&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50739&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50739&r=mysqlcfg

Reply via email to