ID:               33355
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jr at terragate dot net
-Status:           Open
+Status:           Assigned
 Bug Type:         SPL related
 Operating System: Mac OS X 10.4.1
 PHP Version:      5CVS-2005-06-15 (dev)
-Assigned To:      
+Assigned To:      helly


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

[2005-06-15 17:14:00] jr at terragate dot net

Description:
------------
Currently SPL sets the error_handling to EH_THROW which will 
cause any E_WARNING or E_STRICT message to be thrown as 
exception regardless of error_reporting's settings.

This renders most code with compatibility in mind (e.g. 
PEAR) useless in SPL context since there is no way to ignore 
non fatal warnings.

At least E_STRICT messages shouldn't be thrown if it is 
disabled in error_reporting. 

But this might still be confusing. E_STRICT massages should 
be treated as compile time warnings (as in most other 
languages). They shouln't affect the control flow if not 
explicitly requested.

Generally the same applies to E_WARNING and E_USER_WARNING 
as long as there is no way to disable EH_THROW in user space 
php code.   

IMHO EH_THROW should be completly disabled or the error mode 
should be made controlable:

// ignore warnings from this wrapper
error_mode(EH_NORMAL);
$it = new DirectoryIterator('legacywrapper://path/');

// I want to stop on some warnings
error_mode(EH_THROW);
try {
  $it = new DirectoryIterator('legacywrapper://path/');
} catch(Exception $e) {
  // parse exception which might contain an E_WARNING 
message 
  // this is not really OO but it works
  ...
  if($criticalWarning) {
    // bail out
    throw new AMoreAppropriateException();
  } else { 
    // non critical warning trying again with EH_NORMAL
    // using normal php error/warning handling here
    ...
  }
}

As long as all warnings are thrown as 'Exception' the 
EH_THROW mode can't be used as different warnings cannot be 
easily distinguished.






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

error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);

class StreamWrapper
{
  public function dir_opendir($path, $options) {
    return !is_a(null, 'AKnownOrUnknownClass');
  }

  public function dir_readdir() {
    return array();
  }

}

stream_wrapper_register('test', 'StreamWrapper');


echo "Done\n";

?>


Expected result:
----------------
Output of "Done"

Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'is_a
(): Deprecated. Please use the instanceof operator' in /Users/
reith2/Projects/php/bug-new.php:8
Stack trace:
#0 /Users/reith2/Projects/php/bug-new.php(8): is_a(NULL, 
'AKnownOrUnknown...')
#1 /Users/reith2/Projects/php/bug-new.php(18): StreamWrapper-
>dir_opendir('test://path/', 4)
#2 /Users/reith2/Projects/php/bug-new.php(18): 
DirectoryIterator->__construct('test://path/')
#3 {main}



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


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

Reply via email to