#40721 [NEW]: Overload Comparison Problem

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40721 [NEW]: Overload Comparison Problem

    From: rod at pu-gh dot com
    Operating system: Linux
    PHP version: 4.4.6
    PHP Bug Type: Scripting Engine problem
    Bug description: Overload Comparison Problem

    Description:
    ------------
    When overloading a class in php, and then comparing an overloaded property
    to the return value of a function call, the result is not what I expected.
    If comparing against string literals, or if the result of each is first
    assigned to a variable then it's fine.

    I tested this with latest CVS of PHP 4.4.7.

    Reproduce code:
    ---------------
    <?

    class Foo {
    function __get( $name, &$value ) {
    $value = 'foo';
    return true;
    }
    }
    overload( 'Foo' );

    class Bar {
    function foo() {
    return 'bar';
    }
    }

    $foo = new Foo();
    $bar = new Bar();

    echo 'Test: ' . ( $foo->bar == $bar->foo() ? 'BAD' : 'GOOD' ) . "\n";

    ?>

    Expected result:
    ----------------
    Expected (meaning the comparsion failed):

    Test: GOOD

    Actual result:
    --------------
    Actual (meaning the comparsion 'foo' == 'bar' succeeded):

    Test: BAD

    --
    Edit bug report at [url]http://bugs.php.net/?id=40721&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40721&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40721&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40721&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40721&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40721&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40721&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40721&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40721&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40721&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40721&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40721&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40721&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40721&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40721&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40721&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40721&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40721&r=mysqlcfg[/url]
    rod at pu-gh dot com Guest

  2. Similar Questions and Discussions

    1. PhP, Access/SQL, Data comparison problem. (I'm new to PhP)
      Hi All! I'm fairly new to PhP and basicly trying to learn right now. Now I have a problem - I have a fairly large collection of movies which people...
    2. a problem on overload
      I have a problem on overload, The following is my sample code, class A { draw() { ... //a lot of code } }
    3. Access SQL- Date comparison problem
      I use an Access-database where one column stores a date originating from this code: Indate = FormatDateTime(date(),vbgeneraldate) I then want...
    4. SqlDataAdapter Problem Overload
      This code: <%@ Page Language="vb" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.Odbc" %> <%@ import...
    5. Overload
      came across a doubt or better with something that I am not getting understand. I have a system rotating in a Supermarket, Fiscal Printer and it...
  3. #2

    Default #40721 [Opn->WFx]: Overload Comparison Problem

    ID: 40721
    Updated by: [email]tony2001@php.net[/email]
    Reported By: rod at pu-gh dot com
    -Status: Open
    +Status: Wont fix
    Bug Type: Scripting Engine problem
    Operating System: Linux
    PHP Version: 4.4.6
    New Comment:

    You'll have to upgrade to PHP5.


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

    [2007-03-05 03:00:52] rod at pu-gh dot com

    Description:
    ------------
    When overloading a class in php, and then comparing an overloaded
    property to the return value of a function call, the result is not what
    I expected. If comparing against string literals, or if the result of
    each is first assigned to a variable then it's fine.

    I tested this with latest CVS of PHP 4.4.7.

    Reproduce code:
    ---------------
    <?

    class Foo {
    function __get( $name, &$value ) {
    $value = 'foo';
    return true;
    }
    }
    overload( 'Foo' );

    class Bar {
    function foo() {
    return 'bar';
    }
    }

    $foo = new Foo();
    $bar = new Bar();

    echo 'Test: ' . ( $foo->bar == $bar->foo() ? 'BAD' : 'GOOD' ) . "\n";

    ?>

    Expected result:
    ----------------
    Expected (meaning the comparsion failed):

    Test: GOOD

    Actual result:
    --------------
    Actual (meaning the comparsion 'foo' == 'bar' succeeded):

    Test: BAD


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40721&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139