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

  • Loige at Mar 26, 2010 at 10:15 am
    Edit report at http://pear.php.net/bugs/bug.php?id=17204&edit=1

    ID: 17204
    Comment by: loige@hotmail.com
    Reported By: f dot napoleoni at gmail 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
    Roadmap Versions:
    New Comment:

    I forgot to say that happens to me on Windows with php 5.3.0


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

    [2010-03-26 11:02:36] loige

    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-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

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

Related Discussions

Discussion Navigation
viewthread | post
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