From:             
Operating system: 
PHP version:      5.4.0
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:trigger_error with custom line and file

Description:
------------
Wouldn't it be nice if the trigger_error function could be called with a
user-defined $errline and $errfile? Imagine you were writing an Abstract
Class and wanted to handle class errors internally. Theoretically, you
could retrieve the name of the current error handler by using the
set_error_handler function and then the restore_error_handler function.
Then, you could use call_user_func to trigger a user-defined error.
However, if no error handler has been defined previously, set_error_handler
will return null and the procedure would fail alltogether. On the other
hand, calling trigger_error will show the file and line where the
trigger_error function was called (which is very unuseful).

Test script:
---------------
// Get the current error handler
function void ( $errno, $errstr ) { }
$error_handler = set_error_handler ( "void" );
restore_error_handler();

// User-define error
$error_arguments = array ( $errno, $errstr, $errfile, $errline );

// Trigger error
call_user_func ( $error_handler, $error_arguments ); // This will only work
as long as an error handler has been previously set.

// Instead, the following function is proposed:
trigger_error ( string $error_msg, int $error_type = E_USER_NOTICE, string
$error_file, string $error_line );


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

Reply via email to