[PHP-BUG] Bug #76162 [NEW]: type-hint broken with custom error handling function

[email protected] ("joseaugustodearaujonascimento at gmail dot com") Thu, 29 Mar 2018 13:35:56 GMT
Newsgroups php.standards
Message-ID <[email protected]>
From:             joseaugustodearaujonascimento at gmail dot com
Operating system: Debian 9
PHP version:      5.6.34
Package:          PHP Language Specification
Bug Type:         Bug
Bug description:type-hint broken with custom error handling function

Description:
------------
This bug only affects PHP versions 5.6.x.

Test script:
---------------
<?php
class Event {
    public function setTime(\DateTime $time) {
       var_dump($time);
    }
}
function set_event_time(\DateTime $time) {
    var_dump($time);
}
function e_handler() {
    restore_error_handler();
}
set_error_handler('e_handler');

$e = new Event();
$e->setTime(false);

set_event_time(false);

Expected result:
----------------
Fatal error: Uncaught TypeError: Argument 1 passed to Event::setTime()
must be an instance of DateTime, boolean given, called in %s on line %d
and defined in %s:%d

Actual result:
--------------
bool(false)
bool(false)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=76162&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76162&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76162&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76162&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76162&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76162&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76162&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76162&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76162&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76162&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76162&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76162&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76162&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76162&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76162&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76162&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76162&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76162&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76162&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76162&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76162&r=mysqlcfg