Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.9

Request #17204 Benchmark_Iterate::run trigger an error of type E_NOTICE
Submitted: 2010-03-09 00:29 UTC
From: fnapoleoni Assigned: doconnor
Status: Closed Package: Benchmark (version 1.2.7)
PHP Version: 5.2.6 OS: Mac OS X 10.6.2
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 20 + 30 = ?

 
 [2010-03-09 00:29 UTC] fnapoleoni (Fabio Napoleoni)
Description: ------------ The interface used in Benchmark_Iterate::run is unclear and trigger an error of type E_NOTICE. Should be changed to accept a callback instead of current implementation. The change is pretty simple, I could make the change if the package is unmantained. Test script: --------------- require_once 'Benchmark/Iterate.php'; class A { public function run() { } } $r = new Benchmark_Iterate(); $r->run(2, 'A::run', 1); echo $r->getOutput(); Expected result: ---------------- The above code should not trigger the error: Notice: Array to string conversion in Benchmark/Iterate.php on line 104 Actual result: -------------- The code above trigger the error

Comments

 [2010-03-26 15:02 UTC] loige (Luciano Mammino)
I got this problem to. I think the problem is in the two following lines of the Iterate class: 99: if (strstr($function_name, '::')) { 104: if (strstr($function_name, '->')) { the function strstr needs A STRING as parameter, so if an array is passed it throws the E_NOTICE warning. Also if we pass a string containing "::", the line 100: $function_name = explode('::', $function_name); will convert the variable $function_name to an array and the problem arise again at line 104. I think this should be fixed with a check like the following: 99: if (is_string($function_name) && strstr($function_name, '::')) { 104: if (is_string($function_name) && strstr($function_name, '->')) { Let me now if someone could provide a fix to this
 [2010-03-26 15:10 UTC] loige (Luciano Mammino)
I forgot to say that happens to me on Windows with php 5.3.0
 [2010-05-06 01:45 UTC] augusto_hp (Augusto Pascutti)
I made a patch with the changes "loige" commented. I belive there won't be any problems with this changes. There is also some strict errors when calling non-static methods, but there is not much to be done with it without adding a lot of useless coding. So, let it be (I think).
 [2011-12-10 09:33 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Closed -Assigned To: +Assigned To: doconnor
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.