Closed wriver4 closed 11 years ago
Is this being thrown as an error? I am not able to reproduce it on my machine. That line runs fine for me.
What version of PHP are you using?
Yes it is being thrown as an error and the first line above is the excerpt from php-error and in the log file. I tried on xampp php version 5.3.5 and linux 5.3.22.
fat fingered the close
Your code is different to the current version. It has some modifications, such as the 'ini_set', the 'if ($self->throwErrors)', and on ErrorException it is missing a slash.
It should be '\ErrorException', rather than 'ErrorException'. That could be the issue, if it's aliasing the wrong namespace. So the fix, would probably be to just add the slash back in. You could also try the current version from GitHub.
As something else to try, put this in a PHP file on it's own, and then run it:
<?php
$ex1 = new ErrorException( "test message", E_ERROR, 0, __FILE__, __LINE__ );
$ex2 = new \ErrorException( "test message", E_ERROR, 0, __FILE__, __LINE__ );
print_r( $ex1 );
echo '<br>';
print_r( $ex2 );
It should give no errors, and instead print out both exception objects. I just want to confirm if ErrorException can be made, on your setup.
I've tried both your code and panrafal's code and it errors at the same line. I will download and retry both on both machines but here is the results of the above code in both environments.I also thought it was a namespace issue and tried prefixing ErrorException with a slash but ended with the same result. xampp php 5.35 ErrorException Object ( [message:protected] => test message [string:Exception:private] => [code:protected] => 1 [file:protected] => C:\xampp\my\class\error_exception.php [line:protected] => 2 [trace:Exception:private] => Array ( ) [previous:Exception:private] => [severity:protected] => 0 ) ErrorException Object ( [message:protected] => test message [string:Exception:private] => [code:protected] => 1 [file:protected] => C:\xampp\my\class\error_exception.php [line:protected] => 3 [trace:Exception:private] => Array ( ) [previous:Exception:private] => [severity:protected] => 0 ) linux 5.3.22 ErrorException Object ( [message:protected] => test message [string:Exception:private] => [code:protected] => 1 [file:protected] => /home5/recomme3/public_html/arblog/error_exception.php [line:protected] => 2 [trace:Exception:private] => Array ( ) [previous:Exception:private] => [severity:protected] => 0 ) ErrorException Object ( [message:protected] => test message [string:Exception:private] => [code:protected] => 1 [file:protected] => /home5/recomme3/public_html/arblog/error_exception.php [line:protected] => 3 [trace:Exception:private] => Array ( ) [previous:Exception:private] => [severity:protected] => 0 )
Well now I cannot recreate the error in either environment. Instead of zip downloading the master branch I used git clone. And yes they both were after your last commit. So, I am not sure what happened other than I have wasted your time. Sorry about that. And will git clone from now on. And wasted a bunch of my time. Thanks for the feedback and be well!
Np on the false alarm. Maybe you got the zip from a PHP-Error fork without realizing.
Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]]) /** set_error_handler( function( $code, $message, $file, $line, $context ) use ( $self, &$catchSurpressedErrors ) { if ($self->isOn()) { @ini_set('html_errors', false); if (error_reporting() !== 0 || $catchSurpressedErrors) { offending line ----> $ex = new ErrorException($message, $code, $code, $file, $line); if ($self->throwErrors) { throw $ex; } else { $self->reportException($ex); } } } else { return false; } }, $this->defaultErrorReportingOn ); /** At this point I am not seeing the correct solution, ie code blind. Some help would be good. thanks