#50418 [NEW]: self in closures has no class scope
From: crashrox at gmail dot com Operating system: Linux PHP version: 5.3.1 PHP Bug Type: Class/Object related Bug description: self in closures has no class scope Description: A closure within a static method loses self scope. When you print __CLASS__ within a closure it claims to belong to the class. But yet you cant access anything from that class. Reproduce code: --- class Test { public function do_something() { $func = function() { echo 'I belong to: ' . __CLASS__; return self::do_something_else(); }; return $func(); } public static function do_something_else() { return 'I did something else'; } } echo Test::do_something(); Expected result: i belong to: Test i did something else Actual result: -- Test Fatal error: Cannot access self:: when no class scope is active in /home/jument/adam/jument/web/index.php on line 7 -- Edit bug report at http://bugs.php.net/?id=50418edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50418r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50418r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50418r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50418r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50418r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50418r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50418r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50418r=needscript Try newer version: http://bugs.php.net/fix.php?id=50418r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50418r=support Expected behavior: http://bugs.php.net/fix.php?id=50418r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50418r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50418r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50418r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50418r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=50418r=dst IIS Stability: http://bugs.php.net/fix.php?id=50418r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50418r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50418r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50418r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50418r=mysqlcfg
#44006 [NEW]: next function is not returning correctly
From: crashrox at gmail dot com Operating system: SunOS 5.10 Generic_127 PHP version: 5.2.5 PHP Bug Type: Arrays related Bug description: next function is not returning correctly Description: Next function is not returning a value when it should be. Tried code sample below on a linux and windows distro both running PHP 5.2.1 and received desired results. When tested on SunOS 5.10 and PHP 5.2.4 the undesired results appeared. Reproduce code: --- $array = array( 'key1' = array( 'sub1_key1', 'sub1_key2', 'sub1_key3', 'sub1_key4', ), 'key2' = array( 'sub2_key1', 'sub2_key2', 'sub2_key3', 'sub2_key4', ) ); foreach($array as $key = $sub_array) { foreach($sub_array as $sub_val) { echo $sub_val; if(next($sub_array)) echo ', '; } $next = next($array); if(is_array($next)) { echo ''; } print_r($next); } Expected result: sub1_key1, sub1_key2, sub1_key3, sub1_key4Array ( [0] = sub2_key1 [1] = sub2_key2 [2] = sub2_key3 [3] = sub2_key4 ) sub2_key1, sub2_key2, sub2_key3, sub2_key4 Actual result: -- sub1_key1, sub1_key2, sub1_key3, sub1_key4sub2_key1, sub2_key2, sub2_key3, sub2_key4 -- Edit bug report at http://bugs.php.net/?id=44006edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=44006r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44006r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44006r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44006r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44006r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44006r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44006r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=44006r=needscript Try newer version:http://bugs.php.net/fix.php?id=44006r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44006r=support Expected behavior:http://bugs.php.net/fix.php?id=44006r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44006r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44006r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44006r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=44006r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=44006r=dst IIS Stability:http://bugs.php.net/fix.php?id=44006r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44006r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44006r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44006r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=44006r=mysqlcfg
#43554 [NEW]: Calling a non static function staticaly causes local assignment
From: crashrox at gmail dot com Operating system: Tested on Solaris Windows PHP version: 5.2.5 PHP Bug Type: Class/Object related Bug description: Calling a non static function staticaly causes local assignment Description: You have two classes (Class1 and Class2). Class1 calls a non static Class2 function with a Class2 variable assignment, but without a return value. The value set in Class2 is somehow assigned to Class1. If the function was set to static or the class is instantiated the problem does not occur. See code example below for better explanation... Reproduce code: --- // UNEXPECTED RESULTS class Class1 { public function __construct() { Class2::dosomething(); } } class Class2 { private $somevar; public function dosomething() { $this-somevar = 'test'; } } $x = new Class1(); print_r($x); /* // WORKS CORRECTLY class Class1 { public function __construct() { $x = new Class2(); $x-dosomething(); } } class Class2 { private $somevar; public function dosomething() { $this-somevar = 'test'; } } $x = new Class1(); print_r($x); */ Expected result: Class1 Object ( ) Actual result: -- Class1 Object ( [somevar] = test ) -- Edit bug report at http://bugs.php.net/?id=43554edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43554r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43554r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43554r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43554r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43554r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43554r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43554r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=43554r=needscript Try newer version:http://bugs.php.net/fix.php?id=43554r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43554r=support Expected behavior:http://bugs.php.net/fix.php?id=43554r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43554r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43554r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43554r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43554r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43554r=dst IIS Stability:http://bugs.php.net/fix.php?id=43554r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43554r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43554r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43554r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=43554r=mysqlcfg
#43554 [Opn-Csd]: Calling a non static function staticaly causes local assignment
ID: 43554 User updated by: crashrox at gmail dot com Reported By: crashrox at gmail dot com -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: Tested on Solaris Windows PHP Version: 5.2.5 New Comment: This is apparently documented in the manual. Took some time to find it but seems to me it would still be a scope issue. Either way I'm wrong, so this is closed. Previous Comments: [2007-12-10 16:18:22] crashrox at gmail dot com Description: You have two classes (Class1 and Class2). Class1 calls a non static Class2 function with a Class2 variable assignment, but without a return value. The value set in Class2 is somehow assigned to Class1. If the function was set to static or the class is instantiated the problem does not occur. See code example below for better explanation... Reproduce code: --- // UNEXPECTED RESULTS class Class1 { public function __construct() { Class2::dosomething(); } } class Class2 { private $somevar; public function dosomething() { $this-somevar = 'test'; } } $x = new Class1(); print_r($x); /* // WORKS CORRECTLY class Class1 { public function __construct() { $x = new Class2(); $x-dosomething(); } } class Class2 { private $somevar; public function dosomething() { $this-somevar = 'test'; } } $x = new Class1(); print_r($x); */ Expected result: Class1 Object ( ) Actual result: -- Class1 Object ( [somevar] = test ) -- Edit this bug report at http://bugs.php.net/?id=43554edit=1