FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17204&edit=1

ID: 17204
Comment by: loige
Reported By: loige at hotmail dot com
Summary: Benchmark_Iterate::run trigger an error of type
E_NOTICE
Status: Open
Type: Feature/Change Request
Package: Benchmark
Operating System: Mac OS X 10.6.2
Package Version: 1.2.7
PHP Version: 5.2.6
New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2010-03-08 19:29:35] fnapoleoni

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

------------------------------------------------------------------------

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 26, '10 at 10:08a
activeMar 26, '10 at 10:15a
posts2
users2
websitepear.php.net

2 users in discussion

Loige: 1 post Loige: 1 post

People

Translate

site design / logo © 2022 Grokbase