Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace error_get_last() with a custom error handler #334

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions deprecated/Exceptions/ApcException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@

class ApcException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
public static function createFromPhpError(array $error = []): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ApacheException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ApacheException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ApacheException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ApcuException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ApcuException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ApcuException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ArrayException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ArrayException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ArrayException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/Bzip2Exception.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class Bzip2Exception extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{Bzip2Exception}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/CalendarException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class CalendarException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{CalendarException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ClassobjException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ClassobjException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ClassobjException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ComException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ComException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ComException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/CubridException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class CubridException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{CubridException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/DatetimeException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class DatetimeException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{DatetimeException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/DirException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class DirException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{DirException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/EioException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class EioException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{EioException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ErrorfuncException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ErrorfuncException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ErrorfuncException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/ExecException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class ExecException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{ExecException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/FileinfoException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class FileinfoException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{FileinfoException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/FilesystemException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class FilesystemException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{FilesystemException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
16 changes: 13 additions & 3 deletions generated/Exceptions/FilterException.php
Original file line number Diff line number Diff line change
@@ -3,9 +3,19 @@

class FilterException extends \ErrorException implements SafeExceptionInterface
{
public static function createFromPhpError(): self
/**
*
* @param array{type?: int, message?: string, file?: string, line?: int} $error
* @return \Safe\Exceptions\{FilterException}
*/
public static function createFromPhpError(array $error = null): self
{
$error = error_get_last();
return new self($error['message'] ?? 'An error occured', 0, $error['type'] ?? 1);
return new self(
$error['message'] ?? 'An error occured',
0,
$error['type'] ?? 1,
$error['file'] ?? __FILE__,
$error['line'] ?? __LINE__,
);
}
}
Loading
Oops, something went wrong.