ID:               42520
 User updated by:  konstantin at boyandin dot com
 Reported By:      konstantin at boyandin dot com
 Status:           Verified
 Bug Type:         Documentation problem
 Operating System: Windows XP
-PHP Version:      Irrelevant
+PHP Version:      5.2.4
 New Comment:

I have revised the reproducible code in accordance with the advice
given. Now it demonstrates that the function is called in pure PHP 5.2.4
installation.

<?php
set_error_handler("report_error");
$a = new B();
test($a);

class A {
    public function show() {
        print('Class A used');
    }
}

class B {
    public function show() {
        print('Class B used');
    }
}

function test(A $obj) {
    $obj->show();
}

function report_error($errno, $errstr) {
    echo "PHP error $errstr<br />";
}
?>


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

[2007-09-03 09:09:54] konstantin at boyandin dot com

I was using the Windows binary PHP 5.2.4 distribution.

Note: xdebug was installed when I found that behavior (no explicit
options for it set in php.ini). I will try the situation without xdebug
but with error handler set/unset.

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

[2007-09-03 08:20:51] [EMAIL PROTECTED]

[EMAIL PROTECTED]:~$ php
<?php
function err($errno, $errstr) {
 echo $errstr, "\n";
}
set_error_handler("err");
function typeHint(array $foo) {
 echo "I am inside the type hint with :", gettype($foo), "\n";
}

typeHint("string");

Argument 1 passed to typeHint() must be an array, string given, called
in /home/bjori/- on line 10 and defined
I am inside the type hint with :string


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

[2007-09-03 08:14:12] [EMAIL PROTECTED]

his example is missing the custom error handler catching the
E_RECOVERABLE_ERROR.

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

[2007-09-03 08:03:16] [EMAIL PROTECTED]

I'm only seeing the error, no output using PHP 5.2.4RC4-dev.

What version are you using that shows the 'A' or 'B' as well as the
error message?

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

[2007-09-02 14:24:01] konstantin at boyandin dot com

Description:
------------
Function with type hinting is executed nonetheless, even if type
mismatch exception occurs.

Reproduce code:
---------------
<?php
$a = new B();
test($a);

class A {
    public $name = 'A';
       
    public function show() {
        print($this->name);
    }
}

class B {
    public $name = 'B';
       
    public function show() {
        print($this->name);
    }
}

function test(A $obj) {
        $obj->show();
}
?>

Expected result:
----------------
Fatal error, nothing displayed 9save error info if output to the
browsers)

Actual result:
--------------
Function is called as if required type was correct *and* fatal error is
generated.


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


-- 
Edit this bug report at http://bugs.php.net/?id=42520&edit=1

Reply via email to