Req #41856 [Com]: support for anonymous classes
Edit report at https://bugs.php.net/bug.php?id=41856edit=1 ID: 41856 Comment by: antoniocs at gmail dot com Reported by:mbaynton at gmail dot com Summary:support for anonymous classes Status: Open Type: Feature/Change Request Package:Feature/Change Request PHP Version:5.2.3 Block user comment: N Private report: N New Comment: Would be nice to have this in Php 5.4 (or a latter version) Previous Comments: [2011-05-25 19:02:47] urkle at outoforder dot cc David, I do not believe you are understanding the request here. I believe this is more what is being requested. class Base { private $name; public function __construct($name) { $this-name = $name; } public function test() { return $this-name; } } $obj = new class extends Base { public function test() { return ''.$this-name.''; } }; echo $obj-test(); Basically similar to that of anonymous functions introduced in PHP 5.3 [2010-09-26 19:41:30] david dot o dot greenberg at gmail dot com The benefits of anonymous classes are twofold: a) efficiency of code b) efficiency of use of resources consider: $Div = new DivElement($InnerHTML = 'hello'); $Div-display(); versus: (new DivElement( $InnerHTML = 'hello'))-display(); Lines of unnecessary code are saved, plus memory is allocated more efficiently. This is especially useful for objects that merely appear for a single purpose and then vanish. [2010-05-07 02:10:11] jevon at jevon dot org Another request for anonymous classes. Without support for anonymous classes, it can sometimes be necessary to create hundreds of named, and rarely used, classes. Anonymous classes are often used for quick instances that are created and destroyed quickly, so a performance hit is reasonable. [2008-11-11 06:24:37] igorsf at yahoo dot com +1 [2007-06-29 19:12:50] mbaynton at gmail dot com Description: Just voicing my opinion that it would be nice to be able to create anonymous inner classes as in Java. Or put another way, I wish something like the reproduce code would work. This looks much better than creating and naming a global class that has some trivial purpose, like the one in the example. Reproduce code: --- if(! is_object($this-movie)) { $this-movie = new __Object() { public function __call($name, $args) { return false; } }; } -- Edit this bug report at https://bugs.php.net/bug.php?id=41856edit=1
#46177 [NEW]: Require is triggering autoload function
From: Antoniocs at gmail dot com Operating system: windows XP sp3 PHP version: 5.2.6 PHP Bug Type: Dynamic loading Bug description: Require is triggering autoload function Description: Require triggers __autoload Reproduce code: --- File teste.php ?php class teste extends acs_activerecord { public function __construct() { parent::__construct(); } } ? File other.php require(teste.php); This will trigger my autoload function (which is declared and included, but not shown here), which will try to load the file where the acs_activerecord is Expected result: I would expect it not to trigger the autoload function. The autoload function should be triggered when I instantiate the class teste Actual result: -- I have xdedub and the cachegrind shows the autoload function being called when the file teste.php is required http://img142.imageshack.us/img142/2047/loadproblemug6.jpg Here is a link to the image of the cachegrind file.I have placed a little arrow indicating the file -- Edit bug report at http://bugs.php.net/?id=46177edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46177r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46177r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46177r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46177r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46177r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46177r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=46177r=needscript Try newer version:http://bugs.php.net/fix.php?id=46177r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46177r=support Expected behavior:http://bugs.php.net/fix.php?id=46177r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46177r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46177r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46177r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46177r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46177r=dst IIS Stability:http://bugs.php.net/fix.php?id=46177r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46177r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46177r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46177r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=46177r=mysqlcfg
#41232 [Fbk-Opn]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com -Status: Feedback +Status: Open Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: I set all the code you would need in the paste site. Just run the teste_parser.php file and it will call the rest Previous Comments: [2007-04-30 13:22:18] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. [2007-04-29 23:14:08] Antoniocs at gmail dot com Description: I am trying to use output control functions to replace text with processed pages. So I am using eval on a callback function Reproduce code: --- //page_parser.php file (small class to parse pages and replace with something set by me) URL: http://privatepaste.com/9818gOaFnI //teste_parser.php file (file that calls the class to use it to replace a string that I set with the contents of a php file) URL: http://privatepaste.com/32658Bx95B //teste_parser_2.php file (file that contains the php code to be processed by eval. Later this will replace the string set by me URL: http://privatepaste.com/0c1Ev1CTKA Expected result: The teste() method from the class bla to show it's echo (which is a simple Hello) Actual result: -- Nothing appears. The page is blank. All because I call a class method. -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [Fbk-Opn]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com -Status: Feedback +Status: Open Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: Here are the source files: http://www.antoniocs.org/eval_test.rar Unpack, and run teste_parser.php Previous Comments: [2007-04-30 16:05:05] [EMAIL PROTECTED] Please provide a SHORT but complete reproduce case in ONE short script. I believe HTML or several scripts are not required for this. Thank you. [2007-04-30 14:44:01] Antoniocs at gmail dot com I set all the code you would need in the paste site. Just run the teste_parser.php file and it will call the rest [2007-04-30 13:22:18] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. [2007-04-29 23:14:08] Antoniocs at gmail dot com Description: I am trying to use output control functions to replace text with processed pages. So I am using eval on a callback function Reproduce code: --- //page_parser.php file (small class to parse pages and replace with something set by me) URL: http://privatepaste.com/9818gOaFnI //teste_parser.php file (file that calls the class to use it to replace a string that I set with the contents of a php file) URL: http://privatepaste.com/32658Bx95B //teste_parser_2.php file (file that contains the php code to be processed by eval. Later this will replace the string set by me URL: http://privatepaste.com/0c1Ev1CTKA Expected result: The teste() method from the class bla to show it's echo (which is a simple Hello) Actual result: -- Nothing appears. The page is blank. All because I call a class method. -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [Fbk-Opn]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com -Status: Feedback +Status: Open Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: Uncomment the line!! I can't put them all together because this is suppose to work like this. The page appears blank when I call the method Change //$blas-teste(); To $blas-teste(); Previous Comments: [2007-04-30 22:00:43] [EMAIL PROTECTED] It's commented out (and I get the output I pasted earlier). I'm asking you again: please provide a SHORT but compete reproduce script. Take these scripts, merge them into the one script and remove everything not necessary to reproduce the problem. That'll help you to find your bugs in the code. Also please try to execute it in console and look into the error log. The I see an empty screen thing is completely useless. [2007-04-30 16:46:50] Antoniocs at gmail dot com I commented the $blas-teste(); If you remove the comments from that line you will get a blank page [2007-04-30 16:43:31] [EMAIL PROTECTED] html head /head body Hey!! Tudo bem??br br OLASbr Notice: Use of undefined constant TESTE - assumed 'TESTE' in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 3 TESTE iojdsfoijdoidsdbrbr1177951395 Notice: Undefined variable: BLA in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 12 Hello hello /body /html [2007-04-30 16:06:43] Antoniocs at gmail dot com Here are the source files: http://www.antoniocs.org/eval_test.rar Unpack, and run teste_parser.php [2007-04-30 16:05:05] [EMAIL PROTECTED] Please provide a SHORT but complete reproduce case in ONE short script. I believe HTML or several scripts are not required for this. Thank you. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41232 -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [Bgs-Opn]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com -Status: Bogus +Status: Open Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: The code is fine!! The way in which I call it is what is breaking up the code. But that shouldn't happen!! The $bla-teste() method is causing the script to somehow screw up, but there is nothing wrong in the class Previous Comments: [2007-04-30 22:12:18] [EMAIL PROTECTED] Debug your code. The code you're trying to eval() in the output handler is wrong. [2007-04-30 22:04:22] Antoniocs at gmail dot com Uncomment the line!! I can't put them all together because this is suppose to work like this. The page appears blank when I call the method Change //$blas-teste(); To $blas-teste(); [2007-04-30 22:00:43] [EMAIL PROTECTED] It's commented out (and I get the output I pasted earlier). I'm asking you again: please provide a SHORT but compete reproduce script. Take these scripts, merge them into the one script and remove everything not necessary to reproduce the problem. That'll help you to find your bugs in the code. Also please try to execute it in console and look into the error log. The I see an empty screen thing is completely useless. [2007-04-30 16:46:50] Antoniocs at gmail dot com I commented the $blas-teste(); If you remove the comments from that line you will get a blank page [2007-04-30 16:43:31] [EMAIL PROTECTED] html head /head body Hey!! Tudo bem??br br OLASbr Notice: Use of undefined constant TESTE - assumed 'TESTE' in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 3 TESTE iojdsfoijdoidsdbrbr1177951395 Notice: Undefined variable: BLA in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 12 Hello hello /body /html The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41232 -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [Bgs]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com Status: Bogus Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: This is not bogus!! Go here and see the script running http://www.antoniocs.org/eval_test/ http://www.antoniocs.org/eval_test/eval_test.rar -- download the code here When you run the code you will only get the html tag which is before ob_start. Eval screws up everything Previous Comments: [2007-04-30 22:32:34] [EMAIL PROTECTED] As long as you're unable to provide a short reproduce code, it's obvious that the problem is in your code. Please keep this report marked as bogus, thank you. [2007-04-30 22:28:11] Antoniocs at gmail dot com The code is fine!! The way in which I call it is what is breaking up the code. But that shouldn't happen!! The $bla-teste() method is causing the script to somehow screw up, but there is nothing wrong in the class [2007-04-30 22:12:18] [EMAIL PROTECTED] Debug your code. The code you're trying to eval() in the output handler is wrong. [2007-04-30 22:04:22] Antoniocs at gmail dot com Uncomment the line!! I can't put them all together because this is suppose to work like this. The page appears blank when I call the method Change //$blas-teste(); To $blas-teste(); [2007-04-30 22:00:43] [EMAIL PROTECTED] It's commented out (and I get the output I pasted earlier). I'm asking you again: please provide a SHORT but compete reproduce script. Take these scripts, merge them into the one script and remove everything not necessary to reproduce the problem. That'll help you to find your bugs in the code. Also please try to execute it in console and look into the error log. The I see an empty screen thing is completely useless. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41232 -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [Fbk-Opn]: Eval failing on calls to class methods
ID: 41232 User updated by: Antoniocs at gmail dot com Reported By: Antoniocs at gmail dot com -Status: Feedback +Status: Open Bug Type: Output Control Operating System: Windows XP sp2 PHP Version: 5.2.1 New Comment: I commented the $blas-teste(); If you remove the comments from that line you will get a blank page Previous Comments: [2007-04-30 16:43:31] [EMAIL PROTECTED] html head /head body Hey!! Tudo bem??br br OLASbr Notice: Use of undefined constant TESTE - assumed 'TESTE' in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 3 TESTE iojdsfoijdoidsdbrbr1177951395 Notice: Undefined variable: BLA in /tmp/eval_test/page_parser.php(27) : eval()'d code on line 12 Hello hello /body /html [2007-04-30 16:06:43] Antoniocs at gmail dot com Here are the source files: http://www.antoniocs.org/eval_test.rar Unpack, and run teste_parser.php [2007-04-30 16:05:05] [EMAIL PROTECTED] Please provide a SHORT but complete reproduce case in ONE short script. I believe HTML or several scripts are not required for this. Thank you. [2007-04-30 14:44:01] Antoniocs at gmail dot com I set all the code you would need in the paste site. Just run the teste_parser.php file and it will call the rest [2007-04-30 13:22:18] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with ?php and ends with ?, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41232 -- Edit this bug report at http://bugs.php.net/?id=41232edit=1
#41232 [NEW]: Eval failing on calls to class methods
From: Antoniocs at gmail dot com Operating system: Windows XP sp2 PHP version: 5.2.1 PHP Bug Type: Output Control Bug description: Eval failing on calls to class methods Description: I am trying to use output control functions to replace text with processed pages. So I am using eval on a callback function Reproduce code: --- //page_parser.php file (small class to parse pages and replace with something set by me) URL: http://privatepaste.com/9818gOaFnI //teste_parser.php file (file that calls the class to use it to replace a string that I set with the contents of a php file) URL: http://privatepaste.com/32658Bx95B //teste_parser_2.php file (file that contains the php code to be processed by eval. Later this will replace the string set by me URL: http://privatepaste.com/0c1Ev1CTKA Expected result: The teste() method from the class bla to show it's echo (which is a simple Hello) Actual result: -- Nothing appears. The page is blank. All because I call a class method. -- Edit bug report at http://bugs.php.net/?id=41232edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41232r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41232r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41232r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41232r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41232r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41232r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=41232r=needscript Try newer version:http://bugs.php.net/fix.php?id=41232r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41232r=support Expected behavior:http://bugs.php.net/fix.php?id=41232r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41232r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41232r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41232r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41232r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41232r=dst IIS Stability:http://bugs.php.net/fix.php?id=41232r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41232r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41232r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41232r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=41232r=mysqlcfg