diff --git a/deprecated/Exceptions/ApcException.php b/deprecated/Exceptions/ApcException.php index f344490d..d7bfc37d 100644 --- a/deprecated/Exceptions/ApcException.php +++ b/deprecated/Exceptions/ApcException.php @@ -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); } } diff --git a/generated/Exceptions/ApacheException.php b/generated/Exceptions/ApacheException.php index 5d69236f..568d5565 100644 --- a/generated/Exceptions/ApacheException.php +++ b/generated/Exceptions/ApacheException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ApcuException.php b/generated/Exceptions/ApcuException.php index a9fc893e..06fd59ea 100644 --- a/generated/Exceptions/ApcuException.php +++ b/generated/Exceptions/ApcuException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ArrayException.php b/generated/Exceptions/ArrayException.php index 154800c3..0f41b0ce 100644 --- a/generated/Exceptions/ArrayException.php +++ b/generated/Exceptions/ArrayException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/Bzip2Exception.php b/generated/Exceptions/Bzip2Exception.php index dd4ab83f..41f3ce01 100644 --- a/generated/Exceptions/Bzip2Exception.php +++ b/generated/Exceptions/Bzip2Exception.php @@ -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__, + ); } } diff --git a/generated/Exceptions/CalendarException.php b/generated/Exceptions/CalendarException.php index 66ba5884..fbe053ab 100644 --- a/generated/Exceptions/CalendarException.php +++ b/generated/Exceptions/CalendarException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ClassobjException.php b/generated/Exceptions/ClassobjException.php index 1c377b51..956e2df3 100644 --- a/generated/Exceptions/ClassobjException.php +++ b/generated/Exceptions/ClassobjException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ComException.php b/generated/Exceptions/ComException.php index 15421343..02efc29e 100644 --- a/generated/Exceptions/ComException.php +++ b/generated/Exceptions/ComException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/CubridException.php b/generated/Exceptions/CubridException.php index 853c8d25..14718cca 100644 --- a/generated/Exceptions/CubridException.php +++ b/generated/Exceptions/CubridException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/DatetimeException.php b/generated/Exceptions/DatetimeException.php index 63d5f938..57645afa 100644 --- a/generated/Exceptions/DatetimeException.php +++ b/generated/Exceptions/DatetimeException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/DirException.php b/generated/Exceptions/DirException.php index 100308e6..33c7d807 100644 --- a/generated/Exceptions/DirException.php +++ b/generated/Exceptions/DirException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/EioException.php b/generated/Exceptions/EioException.php index f4e121ab..b930b615 100644 --- a/generated/Exceptions/EioException.php +++ b/generated/Exceptions/EioException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ErrorfuncException.php b/generated/Exceptions/ErrorfuncException.php index bf412400..3f212926 100644 --- a/generated/Exceptions/ErrorfuncException.php +++ b/generated/Exceptions/ErrorfuncException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/ExecException.php b/generated/Exceptions/ExecException.php index f7c503c8..b9195b0f 100644 --- a/generated/Exceptions/ExecException.php +++ b/generated/Exceptions/ExecException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/FileinfoException.php b/generated/Exceptions/FileinfoException.php index b9e3abbe..15272329 100644 --- a/generated/Exceptions/FileinfoException.php +++ b/generated/Exceptions/FileinfoException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/FilesystemException.php b/generated/Exceptions/FilesystemException.php index 3c1c70e3..90945690 100644 --- a/generated/Exceptions/FilesystemException.php +++ b/generated/Exceptions/FilesystemException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/FilterException.php b/generated/Exceptions/FilterException.php index a2c1b5c8..d2fb5247 100644 --- a/generated/Exceptions/FilterException.php +++ b/generated/Exceptions/FilterException.php @@ -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__, + ); } } diff --git a/generated/Exceptions/FpmException.php b/generated/Exceptions/FpmException.php index 0017b4c2..7fa240be 100644 --- a/generated/Exceptions/FpmException.php +++ b/generated/Exceptions/FpmException.php @@ -3,9 +3,19 @@ class FpmException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{FpmException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/FtpException.php b/generated/Exceptions/FtpException.php index 0e2b7dde..4f08f264 100644 --- a/generated/Exceptions/FtpException.php +++ b/generated/Exceptions/FtpException.php @@ -3,9 +3,19 @@ class FtpException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{FtpException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/FunchandException.php b/generated/Exceptions/FunchandException.php index 1ee4a211..7f7514ff 100644 --- a/generated/Exceptions/FunchandException.php +++ b/generated/Exceptions/FunchandException.php @@ -3,9 +3,19 @@ class FunchandException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{FunchandException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/GettextException.php b/generated/Exceptions/GettextException.php index 0228ce23..986aae6d 100644 --- a/generated/Exceptions/GettextException.php +++ b/generated/Exceptions/GettextException.php @@ -3,9 +3,19 @@ class GettextException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{GettextException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/GmpException.php b/generated/Exceptions/GmpException.php index a13c11a6..fbc309f2 100644 --- a/generated/Exceptions/GmpException.php +++ b/generated/Exceptions/GmpException.php @@ -3,9 +3,19 @@ class GmpException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{GmpException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/GnupgException.php b/generated/Exceptions/GnupgException.php index cf3a1e74..47935ade 100644 --- a/generated/Exceptions/GnupgException.php +++ b/generated/Exceptions/GnupgException.php @@ -3,9 +3,19 @@ class GnupgException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{GnupgException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/HashException.php b/generated/Exceptions/HashException.php index 1dc09763..9e7fe1e1 100644 --- a/generated/Exceptions/HashException.php +++ b/generated/Exceptions/HashException.php @@ -3,9 +3,19 @@ class HashException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{HashException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/IbaseException.php b/generated/Exceptions/IbaseException.php index 0346ec3c..889ec150 100644 --- a/generated/Exceptions/IbaseException.php +++ b/generated/Exceptions/IbaseException.php @@ -3,9 +3,19 @@ class IbaseException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{IbaseException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/IbmDb2Exception.php b/generated/Exceptions/IbmDb2Exception.php index 4843f852..88ed019e 100644 --- a/generated/Exceptions/IbmDb2Exception.php +++ b/generated/Exceptions/IbmDb2Exception.php @@ -3,9 +3,19 @@ class IbmDb2Exception extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{IbmDb2Exception} + */ + 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__, + ); } } diff --git a/generated/Exceptions/IconvException.php b/generated/Exceptions/IconvException.php index 0dd16370..f4874300 100644 --- a/generated/Exceptions/IconvException.php +++ b/generated/Exceptions/IconvException.php @@ -3,9 +3,19 @@ class IconvException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{IconvException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ImageException.php b/generated/Exceptions/ImageException.php index c4988034..4f2041f7 100644 --- a/generated/Exceptions/ImageException.php +++ b/generated/Exceptions/ImageException.php @@ -3,9 +3,19 @@ class ImageException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ImageException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ImapException.php b/generated/Exceptions/ImapException.php index 6b6bbc7f..664e2c7f 100644 --- a/generated/Exceptions/ImapException.php +++ b/generated/Exceptions/ImapException.php @@ -3,9 +3,19 @@ class ImapException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ImapException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/InfoException.php b/generated/Exceptions/InfoException.php index 5221e1fd..44996c32 100644 --- a/generated/Exceptions/InfoException.php +++ b/generated/Exceptions/InfoException.php @@ -3,9 +3,19 @@ class InfoException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{InfoException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/InotifyException.php b/generated/Exceptions/InotifyException.php index 64048dca..975eac79 100644 --- a/generated/Exceptions/InotifyException.php +++ b/generated/Exceptions/InotifyException.php @@ -3,9 +3,19 @@ class InotifyException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{InotifyException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/LdapException.php b/generated/Exceptions/LdapException.php index 5c142cb0..3bb6b32c 100644 --- a/generated/Exceptions/LdapException.php +++ b/generated/Exceptions/LdapException.php @@ -3,9 +3,19 @@ class LdapException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{LdapException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/LibxmlException.php b/generated/Exceptions/LibxmlException.php index b2772da0..1f381c53 100644 --- a/generated/Exceptions/LibxmlException.php +++ b/generated/Exceptions/LibxmlException.php @@ -3,9 +3,19 @@ class LibxmlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{LibxmlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/LzfException.php b/generated/Exceptions/LzfException.php index 82352faa..ca6a19c4 100644 --- a/generated/Exceptions/LzfException.php +++ b/generated/Exceptions/LzfException.php @@ -3,9 +3,19 @@ class LzfException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{LzfException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/MailparseException.php b/generated/Exceptions/MailparseException.php index 1f3d7370..48c5c98c 100644 --- a/generated/Exceptions/MailparseException.php +++ b/generated/Exceptions/MailparseException.php @@ -3,9 +3,19 @@ class MailparseException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{MailparseException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/MbstringException.php b/generated/Exceptions/MbstringException.php index 2f7913a3..432e8405 100644 --- a/generated/Exceptions/MbstringException.php +++ b/generated/Exceptions/MbstringException.php @@ -3,9 +3,19 @@ class MbstringException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{MbstringException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/MiscException.php b/generated/Exceptions/MiscException.php index 2fd1475d..28c24004 100644 --- a/generated/Exceptions/MiscException.php +++ b/generated/Exceptions/MiscException.php @@ -3,9 +3,19 @@ class MiscException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{MiscException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/MysqlException.php b/generated/Exceptions/MysqlException.php index bd690438..96365d4b 100644 --- a/generated/Exceptions/MysqlException.php +++ b/generated/Exceptions/MysqlException.php @@ -3,9 +3,19 @@ class MysqlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{MysqlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/NetworkException.php b/generated/Exceptions/NetworkException.php index e740ca19..529d31be 100644 --- a/generated/Exceptions/NetworkException.php +++ b/generated/Exceptions/NetworkException.php @@ -3,9 +3,19 @@ class NetworkException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{NetworkException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/Oci8Exception.php b/generated/Exceptions/Oci8Exception.php index b1d93b21..23254f54 100644 --- a/generated/Exceptions/Oci8Exception.php +++ b/generated/Exceptions/Oci8Exception.php @@ -3,9 +3,19 @@ class Oci8Exception extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{Oci8Exception} + */ + 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__, + ); } } diff --git a/generated/Exceptions/OpcacheException.php b/generated/Exceptions/OpcacheException.php index 03309e77..2000bd17 100644 --- a/generated/Exceptions/OpcacheException.php +++ b/generated/Exceptions/OpcacheException.php @@ -3,9 +3,19 @@ class OpcacheException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{OpcacheException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/OutcontrolException.php b/generated/Exceptions/OutcontrolException.php index ffc91f7b..85f78be7 100644 --- a/generated/Exceptions/OutcontrolException.php +++ b/generated/Exceptions/OutcontrolException.php @@ -3,9 +3,19 @@ class OutcontrolException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{OutcontrolException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/PcntlException.php b/generated/Exceptions/PcntlException.php index 00d51f13..a0f910a0 100644 --- a/generated/Exceptions/PcntlException.php +++ b/generated/Exceptions/PcntlException.php @@ -3,9 +3,19 @@ class PcntlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{PcntlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/PgsqlException.php b/generated/Exceptions/PgsqlException.php index 5d264c2f..b7107593 100644 --- a/generated/Exceptions/PgsqlException.php +++ b/generated/Exceptions/PgsqlException.php @@ -3,9 +3,19 @@ class PgsqlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{PgsqlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/PosixException.php b/generated/Exceptions/PosixException.php index 3eec244c..baad92ec 100644 --- a/generated/Exceptions/PosixException.php +++ b/generated/Exceptions/PosixException.php @@ -3,9 +3,19 @@ class PosixException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{PosixException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/PsException.php b/generated/Exceptions/PsException.php index 7571ebf5..eaaa22c4 100644 --- a/generated/Exceptions/PsException.php +++ b/generated/Exceptions/PsException.php @@ -3,9 +3,19 @@ class PsException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{PsException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/PspellException.php b/generated/Exceptions/PspellException.php index 7645cc91..d4e95839 100644 --- a/generated/Exceptions/PspellException.php +++ b/generated/Exceptions/PspellException.php @@ -3,9 +3,19 @@ class PspellException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{PspellException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ReadlineException.php b/generated/Exceptions/ReadlineException.php index b6bb3708..bb8fb743 100644 --- a/generated/Exceptions/ReadlineException.php +++ b/generated/Exceptions/ReadlineException.php @@ -3,9 +3,19 @@ class ReadlineException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ReadlineException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/RpminfoException.php b/generated/Exceptions/RpminfoException.php index 7596451d..7ef6922c 100644 --- a/generated/Exceptions/RpminfoException.php +++ b/generated/Exceptions/RpminfoException.php @@ -3,9 +3,19 @@ class RpminfoException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{RpminfoException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/RrdException.php b/generated/Exceptions/RrdException.php index 45793e80..c0d3b836 100644 --- a/generated/Exceptions/RrdException.php +++ b/generated/Exceptions/RrdException.php @@ -3,9 +3,19 @@ class RrdException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{RrdException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SemException.php b/generated/Exceptions/SemException.php index dd97ea5f..cd9fbef8 100644 --- a/generated/Exceptions/SemException.php +++ b/generated/Exceptions/SemException.php @@ -3,9 +3,19 @@ class SemException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SemException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SessionException.php b/generated/Exceptions/SessionException.php index 9c1be797..a62d7f37 100644 --- a/generated/Exceptions/SessionException.php +++ b/generated/Exceptions/SessionException.php @@ -3,9 +3,19 @@ class SessionException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SessionException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ShmopException.php b/generated/Exceptions/ShmopException.php index 0673848a..14b4f5e9 100644 --- a/generated/Exceptions/ShmopException.php +++ b/generated/Exceptions/ShmopException.php @@ -3,9 +3,19 @@ class ShmopException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ShmopException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SocketsException.php b/generated/Exceptions/SocketsException.php index 172f5d78..535a7220 100644 --- a/generated/Exceptions/SocketsException.php +++ b/generated/Exceptions/SocketsException.php @@ -3,9 +3,19 @@ class SocketsException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SocketsException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SodiumException.php b/generated/Exceptions/SodiumException.php index f33ec049..a625514b 100644 --- a/generated/Exceptions/SodiumException.php +++ b/generated/Exceptions/SodiumException.php @@ -3,9 +3,19 @@ class SodiumException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SodiumException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SolrException.php b/generated/Exceptions/SolrException.php index 2431870f..301392c0 100644 --- a/generated/Exceptions/SolrException.php +++ b/generated/Exceptions/SolrException.php @@ -3,9 +3,19 @@ class SolrException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SolrException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SplException.php b/generated/Exceptions/SplException.php index cae8dbc2..db26de42 100644 --- a/generated/Exceptions/SplException.php +++ b/generated/Exceptions/SplException.php @@ -3,9 +3,19 @@ class SplException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SplException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SqlsrvException.php b/generated/Exceptions/SqlsrvException.php index 6015cd26..7005d3ba 100644 --- a/generated/Exceptions/SqlsrvException.php +++ b/generated/Exceptions/SqlsrvException.php @@ -3,9 +3,19 @@ class SqlsrvException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SqlsrvException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SsdeepException.php b/generated/Exceptions/SsdeepException.php index 20901794..a6f5f4bc 100644 --- a/generated/Exceptions/SsdeepException.php +++ b/generated/Exceptions/SsdeepException.php @@ -3,9 +3,19 @@ class SsdeepException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SsdeepException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/Ssh2Exception.php b/generated/Exceptions/Ssh2Exception.php index 72ca90fd..8f31c2b5 100644 --- a/generated/Exceptions/Ssh2Exception.php +++ b/generated/Exceptions/Ssh2Exception.php @@ -3,9 +3,19 @@ class Ssh2Exception extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{Ssh2Exception} + */ + 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__, + ); } } diff --git a/generated/Exceptions/StreamException.php b/generated/Exceptions/StreamException.php index 24624749..7ac665f3 100644 --- a/generated/Exceptions/StreamException.php +++ b/generated/Exceptions/StreamException.php @@ -3,9 +3,19 @@ class StreamException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{StreamException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/StringsException.php b/generated/Exceptions/StringsException.php index 9e7b356d..afc784b5 100644 --- a/generated/Exceptions/StringsException.php +++ b/generated/Exceptions/StringsException.php @@ -3,9 +3,19 @@ class StringsException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{StringsException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/SwooleException.php b/generated/Exceptions/SwooleException.php index 088c0de8..efd09159 100644 --- a/generated/Exceptions/SwooleException.php +++ b/generated/Exceptions/SwooleException.php @@ -3,9 +3,19 @@ class SwooleException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{SwooleException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/UodbcException.php b/generated/Exceptions/UodbcException.php index 92f94a52..8c7fdfce 100644 --- a/generated/Exceptions/UodbcException.php +++ b/generated/Exceptions/UodbcException.php @@ -3,9 +3,19 @@ class UodbcException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{UodbcException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/UopzException.php b/generated/Exceptions/UopzException.php index 16e1ab5d..1be328c4 100644 --- a/generated/Exceptions/UopzException.php +++ b/generated/Exceptions/UopzException.php @@ -3,9 +3,19 @@ class UopzException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{UopzException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/UrlException.php b/generated/Exceptions/UrlException.php index 77012501..ec04da35 100644 --- a/generated/Exceptions/UrlException.php +++ b/generated/Exceptions/UrlException.php @@ -3,9 +3,19 @@ class UrlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{UrlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/VarException.php b/generated/Exceptions/VarException.php index b2427c9f..c6c2b11a 100644 --- a/generated/Exceptions/VarException.php +++ b/generated/Exceptions/VarException.php @@ -3,9 +3,19 @@ class VarException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{VarException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/XdiffException.php b/generated/Exceptions/XdiffException.php index c6adcd57..50a1180a 100644 --- a/generated/Exceptions/XdiffException.php +++ b/generated/Exceptions/XdiffException.php @@ -3,9 +3,19 @@ class XdiffException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{XdiffException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/XmlException.php b/generated/Exceptions/XmlException.php index ebca08f3..8dd1b65a 100644 --- a/generated/Exceptions/XmlException.php +++ b/generated/Exceptions/XmlException.php @@ -3,9 +3,19 @@ class XmlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{XmlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/XmlrpcException.php b/generated/Exceptions/XmlrpcException.php index 70e12d67..a575b567 100644 --- a/generated/Exceptions/XmlrpcException.php +++ b/generated/Exceptions/XmlrpcException.php @@ -3,9 +3,19 @@ class XmlrpcException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{XmlrpcException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/YamlException.php b/generated/Exceptions/YamlException.php index f1c2e60a..5182c1c8 100644 --- a/generated/Exceptions/YamlException.php +++ b/generated/Exceptions/YamlException.php @@ -3,9 +3,19 @@ class YamlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{YamlException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/YazException.php b/generated/Exceptions/YazException.php index 22a174f5..03a27a03 100644 --- a/generated/Exceptions/YazException.php +++ b/generated/Exceptions/YazException.php @@ -3,9 +3,19 @@ class YazException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{YazException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ZipException.php b/generated/Exceptions/ZipException.php index fb6ba54f..fc986ff1 100644 --- a/generated/Exceptions/ZipException.php +++ b/generated/Exceptions/ZipException.php @@ -3,9 +3,19 @@ class ZipException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ZipException} + */ + 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__, + ); } } diff --git a/generated/Exceptions/ZlibException.php b/generated/Exceptions/ZlibException.php index 35f81b01..3b58042f 100644 --- a/generated/Exceptions/ZlibException.php +++ b/generated/Exceptions/ZlibException.php @@ -3,9 +3,19 @@ class ZlibException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\{ZlibException} + */ + 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__, + ); } } diff --git a/generated/apache.php b/generated/apache.php index 2bb3632a..a065ecb7 100644 --- a/generated/apache.php +++ b/generated/apache.php @@ -13,10 +13,21 @@ */ function apache_get_version(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_get_version(); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -34,10 +45,21 @@ function apache_get_version(): string */ function apache_getenv(string $variable, bool $walk_to_top = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_getenv($variable, $walk_to_top); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -82,10 +104,21 @@ function apache_getenv(string $variable, bool $walk_to_top = false): string */ function apache_lookup_uri(string $filename): object { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_lookup_uri($filename); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -101,10 +134,21 @@ function apache_lookup_uri(string $filename): object */ function apache_request_headers(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_request_headers(); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -120,10 +164,21 @@ function apache_request_headers(): array */ function apache_response_headers(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_response_headers(); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -142,10 +197,21 @@ function apache_response_headers(): array */ function apache_setenv(string $variable, string $value, bool $walk_to_top = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apache_setenv($variable, $value, $walk_to_top); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } } @@ -163,10 +229,21 @@ function apache_setenv(string $variable, string $value, bool $walk_to_top = fals */ function getallheaders(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getallheaders(); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } return $result; } @@ -191,9 +268,20 @@ function getallheaders(): array */ function virtual(string $uri): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \virtual($uri); + restore_error_handler(); + if ($result === false) { - throw ApacheException::createFromPhpError(); + throw ApacheException::createFromPhpError($error); } } diff --git a/generated/apcu.php b/generated/apcu.php index 733b2436..cf40fb06 100644 --- a/generated/apcu.php +++ b/generated/apcu.php @@ -16,10 +16,21 @@ */ function apcu_cache_info(bool $limited = false): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_cache_info($limited); + restore_error_handler(); + if ($result === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } return $result; } @@ -38,10 +49,21 @@ function apcu_cache_info(bool $limited = false): array */ function apcu_cas(string $key, int $old, int $new): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_cas($key, $old, $new); + restore_error_handler(); + if ($result === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } } @@ -60,10 +82,21 @@ function apcu_cas(string $key, int $old, int $new): void */ function apcu_dec(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_dec($key, $step, $success, $ttl); + restore_error_handler(); + if ($result === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } return $result; } @@ -83,10 +116,21 @@ function apcu_dec(string $key, int $step = 1, ?bool &$success = null, int $ttl = */ function apcu_inc(string $key, int $step = 1, ?bool &$success = null, int $ttl = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_inc($key, $step, $success, $ttl); + restore_error_handler(); + if ($result === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } return $result; } @@ -103,10 +147,21 @@ function apcu_inc(string $key, int $step = 1, ?bool &$success = null, int $ttl = */ function apcu_sma_info(bool $limited = false): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_sma_info($limited); + restore_error_handler(); + if ($result === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } return $result; } diff --git a/generated/array.php b/generated/array.php index f1fe2bde..c1372612 100644 --- a/generated/array.php +++ b/generated/array.php @@ -4,30 +4,6 @@ use Safe\Exceptions\ArrayException; -/** - * Creates an array by using the values from the - * keys array as keys and the values from the - * values array as the corresponding values. - * - * @param array $keys Array of keys to be used. Illegal values for key will be - * converted to string. - * @param array $values Array of values to be used - * @return array Returns the combined array, FALSE if the number of elements - * for each array isn't equal. - * @throws ArrayException - * - */ -function array_combine(array $keys, array $values): array -{ - error_clear_last(); - $result = \array_combine($keys, $values); - if ($result === false) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - /** * array_replace_recursive replaces the values of * array with the same values from all the following @@ -55,14 +31,25 @@ function array_combine(array $keys, array $values): array */ function array_replace_recursive(array $array, array ...$replacements): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($replacements !== []) { $result = \array_replace_recursive($array, ...$replacements); } else { $result = \array_replace_recursive($array); } + restore_error_handler(); + if ($result === null) { - throw ArrayException::createFromPhpError(); + throw ArrayException::createFromPhpError($error); } return $result; } @@ -90,14 +77,25 @@ function array_replace_recursive(array $array, array ...$replacements): array */ function array_replace(array $array, array ...$replacements): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($replacements !== []) { $result = \array_replace($array, ...$replacements); } else { $result = \array_replace($array); } + restore_error_handler(); + if ($result === null) { - throw ArrayException::createFromPhpError(); + throw ArrayException::createFromPhpError($error); } return $result; } @@ -127,14 +125,25 @@ function array_replace(array $array, array ...$replacements): array */ function array_walk_recursive(&$array, callable $callback, $arg = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($arg !== null) { $result = \array_walk_recursive($array, $callback, $arg); } else { $result = \array_walk_recursive($array, $callback); } + restore_error_handler(); + if ($result === false) { - throw ArrayException::createFromPhpError(); + throw ArrayException::createFromPhpError($error); } } @@ -150,9 +159,20 @@ function array_walk_recursive(&$array, callable $callback, $arg = null): void */ function shuffle(array &$array): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shuffle($array); + restore_error_handler(); + if ($result === false) { - throw ArrayException::createFromPhpError(); + throw ArrayException::createFromPhpError($error); } } diff --git a/generated/bzip2.php b/generated/bzip2.php index 8087c748..253a9801 100644 --- a/generated/bzip2.php +++ b/generated/bzip2.php @@ -14,10 +14,21 @@ */ function bzclose($bz): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \bzclose($bz); + restore_error_handler(); + if ($result === false) { - throw Bzip2Exception::createFromPhpError(); + throw Bzip2Exception::createFromPhpError($error); } } @@ -34,10 +45,21 @@ function bzclose($bz): void */ function bzflush($bz): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \bzflush($bz); + restore_error_handler(); + if ($result === false) { - throw Bzip2Exception::createFromPhpError(); + throw Bzip2Exception::createFromPhpError($error); } } @@ -59,10 +81,21 @@ function bzflush($bz): void */ function bzread($bz, int $length = 1024): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \bzread($bz, $length); + restore_error_handler(); + if ($result === false) { - throw Bzip2Exception::createFromPhpError(); + throw Bzip2Exception::createFromPhpError($error); } return $result; } @@ -84,14 +117,25 @@ function bzread($bz, int $length = 1024): string */ function bzwrite($bz, string $data, int $length = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \bzwrite($bz, $data, $length); } else { $result = \bzwrite($bz, $data); } + restore_error_handler(); + if ($result === false) { - throw Bzip2Exception::createFromPhpError(); + throw Bzip2Exception::createFromPhpError($error); } return $result; } diff --git a/generated/calendar.php b/generated/calendar.php index a5b03905..b4e2cc9a 100644 --- a/generated/calendar.php +++ b/generated/calendar.php @@ -17,14 +17,25 @@ */ function unixtojd(int $timestamp = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timestamp !== null) { $result = \unixtojd($timestamp); } else { $result = \unixtojd(); } + restore_error_handler(); + if ($result === false) { - throw CalendarException::createFromPhpError(); + throw CalendarException::createFromPhpError($error); } return $result; } diff --git a/generated/classobj.php b/generated/classobj.php index dd2535ae..2597a26a 100644 --- a/generated/classobj.php +++ b/generated/classobj.php @@ -17,9 +17,20 @@ */ function class_alias(string $class, string $alias, bool $autoload = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \class_alias($class, $alias, $autoload); + restore_error_handler(); + if ($result === false) { - throw ClassobjException::createFromPhpError(); + throw ClassobjException::createFromPhpError($error); } } diff --git a/generated/com.php b/generated/com.php index 68e058f2..6493f50e 100644 --- a/generated/com.php +++ b/generated/com.php @@ -16,10 +16,21 @@ */ function com_create_guid(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \com_create_guid(); + restore_error_handler(); + if ($result === false) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } return $result; } @@ -49,14 +60,25 @@ function com_create_guid(): string */ function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($sink_interface !== null) { $result = \com_event_sink($variant, $sink_object, $sink_interface); } else { $result = \com_event_sink($variant, $sink_object); } + restore_error_handler(); + if ($result === false) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } } @@ -115,10 +137,21 @@ function com_event_sink(object $variant, object $sink_object, $sink_interface = */ function com_load_typelib(string $typelib, bool $case_insensitive = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \com_load_typelib($typelib, $case_insensitive); + restore_error_handler(); + if ($result === false) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } } @@ -140,7 +173,16 @@ function com_load_typelib(string $typelib, bool $case_insensitive = true): void */ function com_print_typeinfo(object $variant, string $dispatch_interface = null, bool $display_sink = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($display_sink !== false) { $result = \com_print_typeinfo($variant, $dispatch_interface, $display_sink); } elseif ($dispatch_interface !== null) { @@ -148,8 +190,10 @@ function com_print_typeinfo(object $variant, string $dispatch_interface = null, } else { $result = \com_print_typeinfo($variant); } + restore_error_handler(); + if ($result === false) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } } @@ -166,10 +210,21 @@ function com_print_typeinfo(object $variant, string $dispatch_interface = null, */ function variant_date_to_timestamp(object $variant): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \variant_date_to_timestamp($variant); + restore_error_handler(); + if ($result === null) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } return $result; } @@ -187,10 +242,21 @@ function variant_date_to_timestamp(object $variant): int */ function variant_round($value, int $decimals) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \variant_round($value, $decimals); + restore_error_handler(); + if ($result === null) { - throw ComException::createFromPhpError(); + throw ComException::createFromPhpError($error); } return $result; } diff --git a/generated/cubrid.php b/generated/cubrid.php index 559bc973..782be346 100644 --- a/generated/cubrid.php +++ b/generated/cubrid.php @@ -126,14 +126,25 @@ */ function cubrid_bind($req_identifier, int $bind_index, $bind_value, string $bind_value_type = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($bind_value_type !== null) { $result = \cubrid_bind($req_identifier, $bind_index, $bind_value, $bind_value_type); } else { $result = \cubrid_bind($req_identifier, $bind_index, $bind_value); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -152,10 +163,21 @@ function cubrid_bind($req_identifier, int $bind_index, $bind_value, string $bind */ function cubrid_col_size($conn_identifier, string $oid, string $attr_name): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_col_size($conn_identifier, $oid, $attr_name); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -172,10 +194,21 @@ function cubrid_col_size($conn_identifier, string $oid, string $attr_name): int */ function cubrid_column_names($req_identifier): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_column_names($req_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -192,10 +225,21 @@ function cubrid_column_names($req_identifier): array */ function cubrid_column_types($req_identifier): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_column_types($req_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -219,10 +263,21 @@ function cubrid_column_types($req_identifier): array */ function cubrid_commit($conn_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_commit($conn_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -305,7 +360,16 @@ function cubrid_commit($conn_identifier): void */ function cubrid_connect_with_url(string $conn_url, string $userid = null, string $passwd = null, bool $new_link = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($new_link !== false) { $result = \cubrid_connect_with_url($conn_url, $userid, $passwd, $new_link); } elseif ($passwd !== null) { @@ -315,8 +379,10 @@ function cubrid_connect_with_url(string $conn_url, string $userid = null, string } else { $result = \cubrid_connect_with_url($conn_url); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -349,7 +415,16 @@ function cubrid_connect_with_url(string $conn_url, string $userid = null, string */ function cubrid_connect(string $host, int $port, string $dbname, string $userid = null, string $passwd = null, bool $new_link = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($new_link !== false) { $result = \cubrid_connect($host, $port, $dbname, $userid, $passwd, $new_link); } elseif ($passwd !== null) { @@ -359,8 +434,10 @@ function cubrid_connect(string $host, int $port, string $dbname, string $userid } else { $result = \cubrid_connect($host, $port, $dbname); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -380,10 +457,21 @@ function cubrid_connect(string $host, int $port, string $dbname, string $userid */ function cubrid_current_oid($req_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_current_oid($req_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -400,14 +488,25 @@ function cubrid_current_oid($req_identifier): string */ function cubrid_disconnect($conn_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($conn_identifier !== null) { $result = \cubrid_disconnect($conn_identifier); } else { $result = \cubrid_disconnect(); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -423,10 +522,21 @@ function cubrid_disconnect($conn_identifier = null): void */ function cubrid_drop($conn_identifier, string $oid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_drop($conn_identifier, $oid); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -443,10 +553,21 @@ function cubrid_drop($conn_identifier, string $oid): void */ function cubrid_free_result($req_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_free_result($req_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -463,10 +584,21 @@ function cubrid_free_result($req_identifier): void */ function cubrid_get_charset($conn_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_charset($conn_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -485,10 +617,21 @@ function cubrid_get_charset($conn_identifier): string */ function cubrid_get_class_name($conn_identifier, string $oid): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_class_name($conn_identifier, $oid); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -503,10 +646,21 @@ function cubrid_get_class_name($conn_identifier, string $oid): string */ function cubrid_get_client_info(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_client_info(); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -627,10 +781,21 @@ function cubrid_get_client_info(): string */ function cubrid_get_db_parameter($conn_identifier): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_db_parameter($conn_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -647,10 +812,21 @@ function cubrid_get_db_parameter($conn_identifier): array */ function cubrid_get_query_timeout($req_identifier): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_query_timeout($req_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -666,10 +842,21 @@ function cubrid_get_query_timeout($req_identifier): int */ function cubrid_get_server_info($conn_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_get_server_info($conn_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -694,14 +881,25 @@ function cubrid_get_server_info($conn_identifier): string */ function cubrid_insert_id($conn_identifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($conn_identifier !== null) { $result = \cubrid_insert_id($conn_identifier); } else { $result = \cubrid_insert_id(); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -717,10 +915,21 @@ function cubrid_insert_id($conn_identifier = null): string */ function cubrid_lob_close(array $lob_identifier_array): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob_close($lob_identifier_array); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -737,10 +946,21 @@ function cubrid_lob_close(array $lob_identifier_array): void */ function cubrid_lob_export($conn_identifier, $lob_identifier, string $path_name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob_export($conn_identifier, $lob_identifier, $path_name); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -760,10 +980,21 @@ function cubrid_lob_export($conn_identifier, $lob_identifier, string $path_name) */ function cubrid_lob_get($conn_identifier, string $sql): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob_get($conn_identifier, $sql); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -780,10 +1011,21 @@ function cubrid_lob_get($conn_identifier, string $sql): array */ function cubrid_lob_send($conn_identifier, $lob_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob_send($conn_identifier, $lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -798,10 +1040,21 @@ function cubrid_lob_send($conn_identifier, $lob_identifier): void */ function cubrid_lob_size($lob_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob_size($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -824,14 +1077,25 @@ function cubrid_lob_size($lob_identifier): string */ function cubrid_lob2_bind($req_identifier, int $bind_index, $bind_value, string $bind_value_type = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($bind_value_type !== null) { $result = \cubrid_lob2_bind($req_identifier, $bind_index, $bind_value, $bind_value_type); } else { $result = \cubrid_lob2_bind($req_identifier, $bind_index, $bind_value); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -846,10 +1110,21 @@ function cubrid_lob2_bind($req_identifier, int $bind_index, $bind_value, string */ function cubrid_lob2_close($lob_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_close($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -869,10 +1144,21 @@ function cubrid_lob2_close($lob_identifier): void */ function cubrid_lob2_export($lob_identifier, string $file_name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_export($lob_identifier, $file_name); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -892,10 +1178,21 @@ function cubrid_lob2_export($lob_identifier, string $file_name): void */ function cubrid_lob2_import($lob_identifier, string $file_name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_import($lob_identifier, $file_name); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -914,7 +1211,16 @@ function cubrid_lob2_import($lob_identifier, string $file_name): void */ function cubrid_lob2_new($conn_identifier = null, string $type = "BLOB") { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($type !== "BLOB") { $result = \cubrid_lob2_new($conn_identifier, $type); } elseif ($conn_identifier !== null) { @@ -922,8 +1228,10 @@ function cubrid_lob2_new($conn_identifier = null, string $type = "BLOB") } else { $result = \cubrid_lob2_new(); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -941,10 +1249,21 @@ function cubrid_lob2_new($conn_identifier = null, string $type = "BLOB") */ function cubrid_lob2_read($lob_identifier, int $len): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_read($lob_identifier, $len); + restore_error_handler(); + if ($result === null) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -980,10 +1299,21 @@ function cubrid_lob2_read($lob_identifier, int $len): string */ function cubrid_lob2_seek($lob_identifier, int $offset, int $origin = CUBRID_CURSOR_CURRENT): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_seek($lob_identifier, $offset, $origin); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1019,10 +1349,21 @@ function cubrid_lob2_seek($lob_identifier, int $offset, int $origin = CUBRID_CUR */ function cubrid_lob2_seek64($lob_identifier, string $offset, int $origin = CUBRID_CURSOR_CURRENT): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_seek64($lob_identifier, $offset, $origin); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1037,10 +1378,21 @@ function cubrid_lob2_seek64($lob_identifier, string $offset, int $origin = CUBRI */ function cubrid_lob2_size($lob_identifier): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_size($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1059,10 +1411,21 @@ function cubrid_lob2_size($lob_identifier): int */ function cubrid_lob2_size64($lob_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_size64($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1078,10 +1441,21 @@ function cubrid_lob2_size64($lob_identifier): string */ function cubrid_lob2_tell($lob_identifier): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_tell($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1100,10 +1474,21 @@ function cubrid_lob2_tell($lob_identifier): int */ function cubrid_lob2_tell64($lob_identifier): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_tell64($lob_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1121,10 +1506,21 @@ function cubrid_lob2_tell64($lob_identifier): string */ function cubrid_lob2_write($lob_identifier, string $buf): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lob2_write($lob_identifier, $buf); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1140,10 +1536,21 @@ function cubrid_lob2_write($lob_identifier, string $buf): void */ function cubrid_lock_read($conn_identifier, string $oid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lock_read($conn_identifier, $oid); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1159,10 +1566,21 @@ function cubrid_lock_read($conn_identifier, string $oid): void */ function cubrid_lock_write($conn_identifier, string $oid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_lock_write($conn_identifier, $oid); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1193,10 +1611,21 @@ function cubrid_lock_write($conn_identifier, string $oid): void */ function cubrid_move_cursor($req_identifier, int $offset, int $origin = CUBRID_CURSOR_CURRENT): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_move_cursor($req_identifier, $offset, $origin); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1214,10 +1643,21 @@ function cubrid_move_cursor($req_identifier, int $offset, int $origin = CUBRID_C */ function cubrid_next_result($result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_next_result($result); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1302,7 +1742,16 @@ function cubrid_next_result($result): void */ function cubrid_pconnect_with_url(string $conn_url, string $userid = null, string $passwd = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($passwd !== null) { $result = \cubrid_pconnect_with_url($conn_url, $userid, $passwd); } elseif ($userid !== null) { @@ -1310,8 +1759,10 @@ function cubrid_pconnect_with_url(string $conn_url, string $userid = null, strin } else { $result = \cubrid_pconnect_with_url($conn_url); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1347,7 +1798,16 @@ function cubrid_pconnect_with_url(string $conn_url, string $userid = null, strin */ function cubrid_pconnect(string $host, int $port, string $dbname, string $userid = null, string $passwd = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($passwd !== null) { $result = \cubrid_pconnect($host, $port, $dbname, $userid, $passwd); } elseif ($userid !== null) { @@ -1355,8 +1815,10 @@ function cubrid_pconnect(string $host, int $port, string $dbname, string $userid } else { $result = \cubrid_pconnect($host, $port, $dbname); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1382,10 +1844,21 @@ function cubrid_pconnect(string $host, int $port, string $dbname, string $userid */ function cubrid_prepare($conn_identifier, string $prepare_stmt, int $option = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_prepare($conn_identifier, $prepare_stmt, $option); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1411,7 +1884,16 @@ function cubrid_prepare($conn_identifier, string $prepare_stmt, int $option = 0) */ function cubrid_put($conn_identifier, string $oid, string $attr = null, $value = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($value !== null) { $result = \cubrid_put($conn_identifier, $oid, $attr, $value); } elseif ($attr !== null) { @@ -1419,8 +1901,10 @@ function cubrid_put($conn_identifier, string $oid, string $attr = null, $value = } else { $result = \cubrid_put($conn_identifier, $oid); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1440,10 +1924,21 @@ function cubrid_put($conn_identifier, string $oid, string $attr = null, $value = */ function cubrid_rollback($conn_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_rollback($conn_identifier); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1839,7 +2334,16 @@ function cubrid_rollback($conn_identifier): void */ function cubrid_schema($conn_identifier, int $schema_type, string $class_name = null, string $attr_name = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($attr_name !== null) { $result = \cubrid_schema($conn_identifier, $schema_type, $class_name, $attr_name); } elseif ($class_name !== null) { @@ -1847,8 +2351,10 @@ function cubrid_schema($conn_identifier, int $schema_type, string $class_name = } else { $result = \cubrid_schema($conn_identifier, $schema_type); } + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } return $result; } @@ -1868,10 +2374,21 @@ function cubrid_schema($conn_identifier, int $schema_type, string $class_name = */ function cubrid_seq_drop($conn_identifier, string $oid, string $attr_name, int $index): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_seq_drop($conn_identifier, $oid, $attr_name, $index); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1890,10 +2407,21 @@ function cubrid_seq_drop($conn_identifier, string $oid, string $attr_name, int $ */ function cubrid_seq_insert($conn_identifier, string $oid, string $attr_name, int $index, string $seq_element): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_seq_insert($conn_identifier, $oid, $attr_name, $index, $seq_element); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1912,10 +2440,21 @@ function cubrid_seq_insert($conn_identifier, string $oid, string $attr_name, int */ function cubrid_seq_put($conn_identifier, string $oid, string $attr_name, int $index, string $seq_element): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_seq_put($conn_identifier, $oid, $attr_name, $index, $seq_element); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1934,10 +2473,21 @@ function cubrid_seq_put($conn_identifier, string $oid, string $attr_name, int $i */ function cubrid_set_add($conn_identifier, string $oid, string $attr_name, string $set_element): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_set_add($conn_identifier, $oid, $attr_name, $set_element); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1962,10 +2512,21 @@ function cubrid_set_add($conn_identifier, string $oid, string $attr_name, string */ function cubrid_set_autocommit($conn_identifier, bool $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_set_autocommit($conn_identifier, $mode); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -1989,10 +2550,21 @@ function cubrid_set_autocommit($conn_identifier, bool $mode): void */ function cubrid_set_db_parameter($conn_identifier, int $param_type, int $param_value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_set_db_parameter($conn_identifier, $param_type, $param_value); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -2011,10 +2583,21 @@ function cubrid_set_db_parameter($conn_identifier, int $param_type, int $param_v */ function cubrid_set_drop($conn_identifier, string $oid, string $attr_name, string $set_element): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_set_drop($conn_identifier, $oid, $attr_name, $set_element); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } @@ -2030,9 +2613,20 @@ function cubrid_set_drop($conn_identifier, string $oid, string $attr_name, strin */ function cubrid_set_query_timeout($req_identifier, int $timeout): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cubrid_set_query_timeout($req_identifier, $timeout); + restore_error_handler(); + if ($result === false) { - throw CubridException::createFromPhpError(); + throw CubridException::createFromPhpError($error); } } diff --git a/generated/curl.php b/generated/curl.php index a85379a6..894572aa 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -15,10 +15,21 @@ */ function curl_copy_handle(\CurlHandle $handle): \CurlHandle { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_copy_handle($handle); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } return $result; } @@ -36,10 +47,21 @@ function curl_copy_handle(\CurlHandle $handle): \CurlHandle */ function curl_escape(\CurlHandle $handle, string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_escape($handle, $string); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } return $result; } @@ -61,10 +83,21 @@ function curl_escape(\CurlHandle $handle, string $string): string */ function curl_exec(\CurlHandle $handle) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_exec($handle); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } return $result; } @@ -534,14 +567,25 @@ function curl_exec(\CurlHandle $handle) */ function curl_getinfo(\CurlHandle $handle, int $option = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($option !== null) { $result = \curl_getinfo($handle, $option); } else { $result = \curl_getinfo($handle); } + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } return $result; } @@ -564,14 +608,25 @@ function curl_getinfo(\CurlHandle $handle, int $option = null) */ function curl_init(string $url = null): \CurlHandle { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($url !== null) { $result = \curl_init($url); } else { $result = \curl_init(); } + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromPhpError($error); } return $result; } @@ -624,10 +679,21 @@ function curl_init(string $url = null): \CurlHandle */ function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_messages = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_multi_info_read($multi_handle, $queued_messages); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlMultiHandle($multi_handle); } return $result; } @@ -642,10 +708,21 @@ function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_mess */ function curl_multi_init(): \CurlMultiHandle { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_multi_init(); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromPhpError($error); } return $result; } @@ -788,10 +865,21 @@ function curl_multi_init(): \CurlMultiHandle */ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_multi_setopt($multi_handle, $option, $value); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlMultiHandle($multi_handle); } } @@ -3139,10 +3227,21 @@ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): */ function curl_setopt(\CurlHandle $handle, int $option, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_setopt($handle, $option, $value); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } } @@ -3158,10 +3257,21 @@ function curl_setopt(\CurlHandle $handle, int $option, $value): void */ function curl_share_errno(\CurlShareHandle $share_handle): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_share_errno($share_handle); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlShareHandle($share_handle); } return $result; } @@ -3235,10 +3345,21 @@ function curl_share_errno(\CurlShareHandle $share_handle): int */ function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_share_setopt($share_handle, $option, $value); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlShareHandle($share_handle); } } @@ -3255,10 +3376,21 @@ function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): */ function curl_unescape(\CurlHandle $handle, string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \curl_unescape($handle, $string); + restore_error_handler(); + if ($result === false) { - throw CurlException::createFromPhpError(); + throw CurlException::createFromCurlHandle($handle); } return $result; } diff --git a/generated/datetime.php b/generated/datetime.php index 9ab44a47..b5839e26 100644 --- a/generated/datetime.php +++ b/generated/datetime.php @@ -15,10 +15,21 @@ */ function date_parse_from_format(string $format, string $datetime): ?array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \date_parse_from_format($format, $datetime); + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -36,10 +47,21 @@ function date_parse_from_format(string $format, string $datetime): ?array */ function date_parse(string $datetime): ?array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \date_parse($datetime); + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -142,10 +164,21 @@ function date_parse(string $datetime): ?array */ function date_sun_info(int $timestamp, float $latitude, float $longitude): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \date_sun_info($timestamp, $latitude, $longitude); + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -235,7 +268,16 @@ function date_sun_info(int $timestamp, float $latitude, float $longitude): array */ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($utcOffset !== null) { $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { @@ -247,8 +289,10 @@ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, f } else { $result = \date_sunrise($timestamp, $returnFormat); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -338,7 +382,16 @@ function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, f */ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($utcOffset !== null) { $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset); } elseif ($zenith !== null) { @@ -350,8 +403,10 @@ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, fl } else { $result = \date_sunset($timestamp, $returnFormat); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -376,14 +431,25 @@ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, fl */ function date(string $format, int $timestamp = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timestamp !== null) { $result = \date($format, $timestamp); } else { $result = \date($format); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -423,7 +489,16 @@ function date(string $format, int $timestamp = null): string */ function gmmktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($year !== null) { $result = \gmmktime($hour, $minute, $second, $month, $day, $year); } elseif ($day !== null) { @@ -437,8 +512,10 @@ function gmmktime(int $hour, int $minute = null, int $second = null, int $month } else { $result = \gmmktime($hour); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -467,14 +544,25 @@ function gmmktime(int $hour, int $minute = null, int $second = null, int $month */ function gmstrftime(string $format, int $timestamp = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timestamp !== null) { $result = \gmstrftime($format, $timestamp); } else { $result = \gmstrftime($format); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -589,14 +677,25 @@ function gmstrftime(string $format, int $timestamp = null): string */ function idate(string $format, int $timestamp = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timestamp !== null) { $result = \idate($format, $timestamp); } else { $result = \idate($format); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -643,7 +742,16 @@ function idate(string $format, int $timestamp = null): int */ function mktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($year !== null) { $result = \mktime($hour, $minute, $second, $month, $day, $year); } elseif ($day !== null) { @@ -657,8 +765,10 @@ function mktime(int $hour, int $minute = null, int $second = null, int $month = } else { $result = \mktime($hour); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -974,14 +1084,25 @@ function mktime(int $hour, int $minute = null, int $second = null, int $month = */ function strftime(string $format, int $timestamp = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timestamp !== null) { $result = \strftime($format, $timestamp); } else { $result = \strftime($format); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -1061,10 +1182,21 @@ function strftime(string $format, int $timestamp = null): string */ function strptime(string $timestamp, string $format): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \strptime($timestamp, $format); + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -1086,14 +1218,25 @@ function strptime(string $timestamp, string $format): array */ function strtotime(string $datetime, int $baseTimestamp = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($baseTimestamp !== null) { $result = \strtotime($datetime, $baseTimestamp); } else { $result = \strtotime($datetime); } + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -1122,10 +1265,21 @@ function strtotime(string $datetime, int $baseTimestamp = null): int */ function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \timezone_name_from_abbr($abbr, $utcOffset, $isDST); + restore_error_handler(); + if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } diff --git a/generated/dir.php b/generated/dir.php index fe4ea5af..acc21f45 100644 --- a/generated/dir.php +++ b/generated/dir.php @@ -14,10 +14,21 @@ */ function chdir(string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \chdir($directory); + restore_error_handler(); + if ($result === false) { - throw DirException::createFromPhpError(); + throw DirException::createFromPhpError($error); } } @@ -40,10 +51,21 @@ function chdir(string $directory): void */ function chroot(string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \chroot($directory); + restore_error_handler(); + if ($result === false) { - throw DirException::createFromPhpError(); + throw DirException::createFromPhpError($error); } } @@ -63,10 +85,21 @@ function chroot(string $directory): void */ function getcwd(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getcwd(); + restore_error_handler(); + if ($result === false) { - throw DirException::createFromPhpError(); + throw DirException::createFromPhpError($error); } return $result; } @@ -87,14 +120,25 @@ function getcwd(): string */ function opendir(string $directory, $context = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \opendir($directory, $context); } else { $result = \opendir($directory); } + restore_error_handler(); + if ($result === false) { - throw DirException::createFromPhpError(); + throw DirException::createFromPhpError($error); } return $result; } @@ -121,14 +165,25 @@ function opendir(string $directory, $context = null) */ function scandir(string $directory, int $sorting_order = SCANDIR_SORT_ASCENDING, $context = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \scandir($directory, $sorting_order, $context); } else { $result = \scandir($directory, $sorting_order); } + restore_error_handler(); + if ($result === false) { - throw DirException::createFromPhpError(); + throw DirException::createFromPhpError($error); } return $result; } diff --git a/generated/eio.php b/generated/eio.php index 1fffa900..7724ceb1 100644 --- a/generated/eio.php +++ b/generated/eio.php @@ -21,10 +21,21 @@ */ function eio_busy(int $delay, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_busy($delay, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -73,10 +84,21 @@ function eio_busy(int $delay, int $pri = EIO_PRI_DEFAULT, callable $callback = n */ function eio_chmod(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_chmod($path, $mode, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -125,10 +147,21 @@ function eio_chmod(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable */ function eio_chown(string $path, int $uid, int $gid = -1, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_chown($path, $uid, $gid, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -174,10 +207,21 @@ function eio_chown(string $path, int $uid, int $gid = -1, int $pri = EIO_PRI_DEF */ function eio_close($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_close($fd, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -233,10 +277,21 @@ function eio_close($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $ */ function eio_custom(callable $execute, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_custom($execute, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -282,10 +337,21 @@ function eio_custom(callable $execute, int $pri, callable $callback, $data = nul */ function eio_dup2($fd, $fd2, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_dup2($fd, $fd2, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -299,10 +365,21 @@ function eio_dup2($fd, $fd2, int $pri = EIO_PRI_DEFAULT, callable $callback = nu */ function eio_event_loop(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_event_loop(); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } } @@ -354,10 +431,21 @@ function eio_event_loop(): void */ function eio_fallocate($fd, int $mode, int $offset, int $length, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_fallocate($fd, $mode, $offset, $length, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -404,10 +492,21 @@ function eio_fallocate($fd, int $mode, int $offset, int $length, int $pri = EIO_ */ function eio_fchmod($fd, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_fchmod($fd, $mode, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -455,10 +554,21 @@ function eio_fchmod($fd, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callba */ function eio_fchown($fd, int $uid, int $gid = -1, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_fchown($fd, $uid, $gid, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -503,10 +613,21 @@ function eio_fchown($fd, int $uid, int $gid = -1, int $pri = EIO_PRI_DEFAULT, ca */ function eio_fdatasync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_fdatasync($fd, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -552,14 +673,25 @@ function eio_fdatasync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = nul */ function eio_fstat($fd, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($data !== null) { $result = \eio_fstat($fd, $pri, $callback, $data); } else { $result = \eio_fstat($fd, $pri, $callback); } + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -605,14 +737,25 @@ function eio_fstat($fd, int $pri, callable $callback, $data = null) */ function eio_fstatvfs($fd, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($data !== null) { $result = \eio_fstatvfs($fd, $pri, $callback, $data); } else { $result = \eio_fstatvfs($fd, $pri, $callback); } + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -657,10 +800,21 @@ function eio_fstatvfs($fd, int $pri, callable $callback, $data = null) */ function eio_fsync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_fsync($fd, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -708,10 +862,21 @@ function eio_fsync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $ */ function eio_ftruncate($fd, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_ftruncate($fd, $offset, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -759,10 +924,21 @@ function eio_ftruncate($fd, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callabl */ function eio_futime($fd, float $atime, float $mtime, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_futime($fd, $atime, $mtime, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -803,10 +979,21 @@ function eio_futime($fd, float $atime, float $mtime, int $pri = EIO_PRI_DEFAULT, */ function eio_grp(callable $callback, string $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_grp($callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -852,10 +1039,21 @@ function eio_grp(callable $callback, string $data = null) */ function eio_lstat(string $path, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_lstat($path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -902,10 +1100,21 @@ function eio_lstat(string $path, int $pri, callable $callback, $data = null) */ function eio_mkdir(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_mkdir($path, $mode, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -967,10 +1176,21 @@ function eio_mkdir(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable */ function eio_mknod(string $path, int $mode, int $dev, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_mknod($path, $mode, $dev, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1015,10 +1235,21 @@ function eio_mknod(string $path, int $mode, int $dev, int $pri = EIO_PRI_DEFAULT */ function eio_nop(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_nop($pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1066,10 +1297,21 @@ function eio_nop(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = */ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_readahead($fd, $offset, $length, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1370,10 +1612,21 @@ function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT */ function eio_readdir(string $path, int $flags, int $pri, callable $callback, string $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_readdir($path, $flags, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1418,10 +1671,21 @@ function eio_readdir(string $path, int $flags, int $pri, callable $callback, str */ function eio_readlink(string $path, int $pri, callable $callback, string $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_readlink($path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1467,10 +1731,21 @@ function eio_readlink(string $path, int $pri, callable $callback, string $data = */ function eio_rename(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_rename($path, $new_path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1515,10 +1790,21 @@ function eio_rename(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, */ function eio_rmdir(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_rmdir($path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1571,10 +1857,21 @@ function eio_rmdir(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback */ function eio_seek($fd, int $offset, int $whence, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_seek($fd, $offset, $whence, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1623,7 +1920,16 @@ function eio_seek($fd, int $offset, int $whence, int $pri = EIO_PRI_DEFAULT, cal */ function eio_sendfile($out_fd, $in_fd, int $offset, int $length, int $pri = null, callable $callback = null, string $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($data !== null) { $result = \eio_sendfile($out_fd, $in_fd, $offset, $length, $pri, $callback, $data); } elseif ($callback !== null) { @@ -1633,8 +1939,10 @@ function eio_sendfile($out_fd, $in_fd, int $offset, int $length, int $pri = null } else { $result = \eio_sendfile($out_fd, $in_fd, $offset, $length); } + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1681,10 +1989,21 @@ function eio_sendfile($out_fd, $in_fd, int $offset, int $length, int $pri = null */ function eio_stat(string $path, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_stat($path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1732,14 +2051,25 @@ function eio_stat(string $path, int $pri, callable $callback, $data = null) */ function eio_statvfs(string $path, int $pri, callable $callback, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($data !== null) { $result = \eio_statvfs($path, $pri, $callback, $data); } else { $result = \eio_statvfs($path, $pri, $callback); } + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1786,10 +2116,21 @@ function eio_statvfs(string $path, int $pri, callable $callback, $data = null) */ function eio_symlink(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_symlink($path, $new_path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1845,10 +2186,21 @@ function eio_symlink(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, */ function eio_sync_file_range($fd, int $offset, int $nbytes, int $flags, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_sync_file_range($fd, $offset, $nbytes, $flags, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1866,10 +2218,21 @@ function eio_sync_file_range($fd, int $offset, int $nbytes, int $flags, int $pri */ function eio_sync(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_sync($pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1914,10 +2277,21 @@ function eio_sync(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = */ function eio_syncfs($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_syncfs($fd, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -1964,10 +2338,21 @@ function eio_syncfs($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, */ function eio_truncate(string $path, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_truncate($path, $offset, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -2012,10 +2397,21 @@ function eio_truncate(string $path, int $offset = 0, int $pri = EIO_PRI_DEFAULT, */ function eio_unlink(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_unlink($path, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -2062,10 +2458,21 @@ function eio_unlink(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback */ function eio_utime(string $path, float $atime, float $mtime, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_utime($path, $atime, $mtime, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } @@ -2115,10 +2522,21 @@ function eio_utime(string $path, float $atime, float $mtime, int $pri = EIO_PRI_ */ function eio_write($fd, string $str, int $length = 0, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \eio_write($fd, $str, $length, $offset, $pri, $callback, $data); + restore_error_handler(); + if ($result === false) { - throw EioException::createFromPhpError(); + throw EioException::createFromPhpError($error); } return $result; } diff --git a/generated/errorfunc.php b/generated/errorfunc.php index 9d3e98b2..694f8379 100644 --- a/generated/errorfunc.php +++ b/generated/errorfunc.php @@ -68,7 +68,16 @@ */ function error_log(string $message, int $message_type = 0, string $destination = null, string $additional_headers = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($additional_headers !== null) { $result = \error_log($message, $message_type, $destination, $additional_headers); } elseif ($destination !== null) { @@ -76,7 +85,9 @@ function error_log(string $message, int $message_type = 0, string $destination = } else { $result = \error_log($message, $message_type); } + restore_error_handler(); + if ($result === false) { - throw ErrorfuncException::createFromPhpError(); + throw ErrorfuncException::createFromPhpError($error); } } diff --git a/generated/exec.php b/generated/exec.php index c4dd4911..6803c48e 100644 --- a/generated/exec.php +++ b/generated/exec.php @@ -34,10 +34,21 @@ */ function exec(string $command, ?array &$output = null, ?int &$result_code = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \exec($command, $output, $result_code); + restore_error_handler(); + if ($result === false) { - throw ExecException::createFromPhpError(); + throw ExecException::createFromPhpError($error); } return $result; } @@ -64,10 +75,21 @@ function exec(string $command, ?array &$output = null, ?int &$result_code = null */ function passthru(string $command, ?int &$result_code = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \passthru($command, $result_code); + restore_error_handler(); + if ($result === false) { - throw ExecException::createFromPhpError(); + throw ExecException::createFromPhpError($error); } } @@ -94,10 +116,21 @@ function passthru(string $command, ?int &$result_code = null): void */ function proc_nice(int $priority): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \proc_nice($priority); + restore_error_handler(); + if ($result === false) { - throw ExecException::createFromPhpError(); + throw ExecException::createFromPhpError($error); } } @@ -113,10 +146,21 @@ function proc_nice(int $priority): void */ function shell_exec(string $command): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shell_exec($command); + restore_error_handler(); + if ($result === null) { - throw ExecException::createFromPhpError(); + throw ExecException::createFromPhpError($error); } return $result; } @@ -145,10 +189,21 @@ function shell_exec(string $command): string */ function system(string $command, ?int &$result_code = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \system($command, $result_code); + restore_error_handler(); + if ($result === false) { - throw ExecException::createFromPhpError(); + throw ExecException::createFromPhpError($error); } return $result; } diff --git a/generated/fileinfo.php b/generated/fileinfo.php index 8bbfd3c4..cd979762 100644 --- a/generated/fileinfo.php +++ b/generated/fileinfo.php @@ -13,10 +13,21 @@ */ function finfo_close($finfo): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \finfo_close($finfo); + restore_error_handler(); + if ($result === false) { - throw FileinfoException::createFromPhpError(); + throw FileinfoException::createFromPhpError($error); } } @@ -45,14 +56,25 @@ function finfo_close($finfo): void */ function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($magic_database !== null) { $result = \finfo_open($flags, $magic_database); } else { $result = \finfo_open($flags); } + restore_error_handler(); + if ($result === false) { - throw FileinfoException::createFromPhpError(); + throw FileinfoException::createFromPhpError($error); } return $result; } @@ -70,10 +92,21 @@ function finfo_open(int $flags = FILEINFO_NONE, string $magic_database = null) */ function mime_content_type($filename): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mime_content_type($filename); + restore_error_handler(); + if ($result === false) { - throw FileinfoException::createFromPhpError(); + throw FileinfoException::createFromPhpError($error); } return $result; } diff --git a/generated/filesystem.php b/generated/filesystem.php index 833719b6..9d019ed9 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -18,10 +18,21 @@ */ function chgrp(string $filename, $group): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \chgrp($filename, $group); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -60,10 +71,21 @@ function chgrp(string $filename, $group): void */ function chmod(string $filename, int $permissions): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \chmod($filename, $permissions); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -80,10 +102,21 @@ function chmod(string $filename, int $permissions): void */ function chown(string $filename, $user): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \chown($filename, $user); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -107,14 +140,25 @@ function chown(string $filename, $user): void */ function copy(string $from, string $to, $context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \copy($from, $to, $context); } else { $result = \copy($from, $to); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -135,10 +179,21 @@ function copy(string $from, string $to, $context = null): void */ function disk_free_space(string $directory): float { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \disk_free_space($directory); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -155,10 +210,21 @@ function disk_free_space(string $directory): float */ function disk_total_space(string $directory): float { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \disk_total_space($directory); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -174,10 +240,21 @@ function disk_total_space(string $directory): float */ function fclose($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fclose($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -197,10 +274,21 @@ function fclose($stream): void */ function fdatasync($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fdatasync($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -218,10 +306,21 @@ function fdatasync($stream): void */ function fflush($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fflush($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -253,7 +352,16 @@ function fflush($stream): void */ function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\") { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($escape !== "\\") { $result = \fgetcsv($stream, $length, $separator, $enclosure, $escape); } elseif ($enclosure !== "\"") { @@ -265,8 +373,10 @@ function fgetcsv($stream, int $length = null, string $separator = ",", string $e } else { $result = \fgetcsv($stream); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -308,7 +418,16 @@ function fgetcsv($stream, int $length = null, string $separator = ",", string $e */ function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \file_get_contents($filename, $use_include_path, $context, $offset, $length); } elseif ($offset !== 0) { @@ -318,8 +437,10 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co } else { $result = \file_get_contents($filename, $use_include_path); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -401,14 +522,25 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co */ function file_put_contents(string $filename, $data, int $flags = 0, $context = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \file_put_contents($filename, $data, $flags, $context); } else { $result = \file_put_contents($filename, $data, $flags); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -461,14 +593,25 @@ function file_put_contents(string $filename, $data, int $flags = 0, $context = n */ function file(string $filename, int $flags = 0, $context = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \file($filename, $flags, $context); } else { $result = \file($filename, $flags); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -485,10 +628,21 @@ function file(string $filename, int $flags = 0, $context = null): array */ function fileatime(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fileatime($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -505,10 +659,21 @@ function fileatime(string $filename): int */ function filectime(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \filectime($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -524,10 +689,21 @@ function filectime(string $filename): int */ function fileinode(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fileinode($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -546,10 +722,21 @@ function fileinode(string $filename): int */ function filemtime(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \filemtime($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -567,10 +754,21 @@ function filemtime(string $filename): int */ function fileowner(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fileowner($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -600,10 +798,21 @@ function fileowner(string $filename): int */ function fileperms(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fileperms($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -620,10 +829,21 @@ function fileperms(string $filename): int */ function filesize(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \filesize($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -673,10 +893,21 @@ function filesize(string $filename): int */ function flock($stream, int $operation, ?int &$would_block = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \flock($stream, $operation, $would_block); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -882,14 +1113,25 @@ function flock($stream, int $operation, ?int &$would_block = null): void */ function fopen(string $filename, string $mode, bool $use_include_path = false, $context = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \fopen($filename, $mode, $use_include_path, $context); } else { $result = \fopen($filename, $mode, $use_include_path); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -936,10 +1178,21 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $ */ function fread($stream, int $length): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fread($stream, $length); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -961,10 +1214,21 @@ function fread($stream, int $length): string */ function fstat($stream): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fstat($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -983,10 +1247,21 @@ function fstat($stream): array */ function fsync($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fsync($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1010,10 +1285,21 @@ function fsync($stream): void */ function ftruncate($stream, int $size): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftruncate($stream, $size); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1033,14 +1319,25 @@ function ftruncate($stream, int $size): void */ function fwrite($stream, string $data, int $length = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \fwrite($stream, $data, $length); } else { $result = \fwrite($stream, $data); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1138,10 +1435,21 @@ function fwrite($stream, string $data, int $length = null): int */ function glob(string $pattern, int $flags = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \glob($pattern, $flags); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1162,10 +1470,21 @@ function glob(string $pattern, int $flags = 0): array */ function lchgrp(string $filename, $group): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \lchgrp($filename, $group); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1183,10 +1502,21 @@ function lchgrp(string $filename, $group): void */ function lchown(string $filename, $user): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \lchown($filename, $user); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1201,10 +1531,21 @@ function lchown(string $filename, $user): void */ function link(string $target, string $link): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \link($target, $link); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1227,10 +1568,21 @@ function link(string $target, string $link): void */ function lstat(string $filename): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \lstat($filename); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1259,14 +1611,25 @@ function lstat(string $filename): array */ function mkdir(string $directory, int $permissions = 0777, bool $recursive = false, $context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \mkdir($directory, $permissions, $recursive, $context); } else { $result = \mkdir($directory, $permissions, $recursive); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1302,10 +1665,21 @@ function mkdir(string $directory, int $permissions = 0777, bool $recursive = fal */ function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \parse_ini_file($filename, $process_sections, $scanner_mode); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1339,10 +1713,21 @@ function parse_ini_file(string $filename, bool $process_sections = false, int $s */ function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \parse_ini_string($ini_string, $process_sections, $scanner_mode); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1362,14 +1747,25 @@ function parse_ini_string(string $ini_string, bool $process_sections = false, in */ function readfile(string $filename, bool $use_include_path = false, $context = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \readfile($filename, $use_include_path, $context); } else { $result = \readfile($filename, $use_include_path); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1385,10 +1781,21 @@ function readfile(string $filename, bool $use_include_path = false, $context = n */ function readlink(string $path): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readlink($path); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1421,10 +1828,21 @@ function readlink(string $path): string */ function realpath(string $path): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \realpath($path); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1457,14 +1875,25 @@ function realpath(string $path): string */ function rename(string $from, string $to, $context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \rename($from, $to, $context); } else { $result = \rename($from, $to); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1480,10 +1909,21 @@ function rename(string $from, string $to, $context = null): void */ function rewind($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rewind($stream); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1501,14 +1941,25 @@ function rewind($stream): void */ function rmdir(string $directory, $context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \rmdir($directory, $context); } else { $result = \rmdir($directory); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1525,10 +1976,21 @@ function rmdir(string $directory, $context = null): void */ function symlink(string $target, string $link): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \symlink($target, $link); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1547,10 +2009,21 @@ function symlink(string $target, string $link): void */ function tempnam(string $directory, string $prefix): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \tempnam($directory, $prefix); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1572,10 +2045,21 @@ function tempnam(string $directory, string $prefix): string */ function tmpfile() { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \tmpfile(); + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } @@ -1602,7 +2086,16 @@ function tmpfile() */ function touch(string $filename, int $mtime = null, int $atime = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($atime !== null) { $result = \touch($filename, $mtime, $atime); } elseif ($mtime !== null) { @@ -1610,8 +2103,10 @@ function touch(string $filename, int $mtime = null, int $atime = null): void } else { $result = \touch($filename); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } @@ -1632,13 +2127,24 @@ function touch(string $filename, int $mtime = null, int $atime = null): void */ function unlink(string $filename, $context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \unlink($filename, $context); } else { $result = \unlink($filename); } + restore_error_handler(); + if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } } diff --git a/generated/filter.php b/generated/filter.php index aba02b4d..dc47440d 100644 --- a/generated/filter.php +++ b/generated/filter.php @@ -38,10 +38,21 @@ */ function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \filter_input_array($type, $options, $add_empty); + restore_error_handler(); + if ($result === false) { - throw FilterException::createFromPhpError(); + throw FilterException::createFromPhpError($error); } return $result; } @@ -72,10 +83,21 @@ function filter_input_array(int $type, $options = FILTER_DEFAULT, bool $add_empt */ function filter_var_array(array $array, $options = FILTER_DEFAULT, bool $add_empty = true): ?array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \filter_var_array($array, $options, $add_empty); + restore_error_handler(); + if ($result === false) { - throw FilterException::createFromPhpError(); + throw FilterException::createFromPhpError($error); } return $result; } diff --git a/generated/fpm.php b/generated/fpm.php index 08b39410..8ea8e245 100644 --- a/generated/fpm.php +++ b/generated/fpm.php @@ -14,9 +14,20 @@ */ function fastcgi_finish_request(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fastcgi_finish_request(); + restore_error_handler(); + if ($result === false) { - throw FpmException::createFromPhpError(); + throw FpmException::createFromPhpError($error); } } diff --git a/generated/ftp.php b/generated/ftp.php index 23846bf1..8ffb851f 100644 --- a/generated/ftp.php +++ b/generated/ftp.php @@ -17,10 +17,21 @@ */ function ftp_alloc($ftp, int $size, ?string &$response = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_alloc($ftp, $size, $response); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -37,10 +48,21 @@ function ftp_alloc($ftp, int $size, ?string &$response = null): void */ function ftp_append($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_append($ftp, $remote_filename, $local_filename, $mode); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -54,10 +76,21 @@ function ftp_append($ftp, string $remote_filename, string $local_filename, int $ */ function ftp_cdup($ftp): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_cdup($ftp); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -72,10 +105,21 @@ function ftp_cdup($ftp): void */ function ftp_chdir($ftp, string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_chdir($ftp, $directory); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -93,10 +137,21 @@ function ftp_chdir($ftp, string $directory): void */ function ftp_chmod($ftp, int $permissions, string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_chmod($ftp, $permissions, $filename); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -112,10 +167,21 @@ function ftp_chmod($ftp, int $permissions, string $filename): int */ function ftp_close($ftp): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_close($ftp); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -138,10 +204,21 @@ function ftp_close($ftp): void */ function ftp_connect(string $hostname, int $port = 21, int $timeout = 90) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_connect($hostname, $port, $timeout); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -158,10 +235,21 @@ function ftp_connect(string $hostname, int $port = 21, int $timeout = 90) */ function ftp_delete($ftp, string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_delete($ftp, $filename); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -181,10 +269,21 @@ function ftp_delete($ftp, string $filename): void */ function ftp_fget($ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_fget($ftp, $stream, $remote_filename, $mode, $offset); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -204,10 +303,21 @@ function ftp_fget($ftp, $stream, string $remote_filename, int $mode = FTP_BINARY */ function ftp_fput($ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_fput($ftp, $remote_filename, $stream, $mode, $offset); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -227,10 +337,21 @@ function ftp_fput($ftp, string $remote_filename, $stream, int $mode = FTP_BINARY */ function ftp_get($ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_get($ftp, $local_filename, $remote_filename, $mode, $offset); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -246,10 +367,21 @@ function ftp_get($ftp, string $local_filename, string $remote_filename, int $mod */ function ftp_login($ftp, string $username, string $password): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_login($ftp, $username, $password); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -265,10 +397,21 @@ function ftp_login($ftp, string $username, string $password): void */ function ftp_mkdir($ftp, string $directory): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_mkdir($ftp, $directory); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -285,10 +428,21 @@ function ftp_mkdir($ftp, string $directory): string */ function ftp_mlsd($ftp, string $directory): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_mlsd($ftp, $directory); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -314,10 +468,21 @@ function ftp_mlsd($ftp, string $directory): array */ function ftp_nb_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_nb_put($ftp, $remote_filename, $local_filename, $mode, $offset); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -337,10 +502,21 @@ function ftp_nb_put($ftp, string $remote_filename, string $local_filename, int $ */ function ftp_nlist($ftp, string $directory): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_nlist($ftp, $directory); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -362,10 +538,21 @@ function ftp_nlist($ftp, string $directory): array */ function ftp_pasv($ftp, bool $enable): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_pasv($ftp, $enable); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -384,10 +571,21 @@ function ftp_pasv($ftp, bool $enable): void */ function ftp_put($ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_put($ftp, $remote_filename, $local_filename, $mode, $offset); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -402,10 +600,21 @@ function ftp_put($ftp, string $remote_filename, string $local_filename, int $mod */ function ftp_pwd($ftp): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_pwd($ftp); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -424,10 +633,21 @@ function ftp_pwd($ftp): string */ function ftp_raw($ftp, string $command): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_raw($ftp, $command); + restore_error_handler(); + if ($result === null) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -445,10 +665,21 @@ function ftp_raw($ftp, string $command): array */ function ftp_rename($ftp, string $from, string $to): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_rename($ftp, $from, $to); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -464,10 +695,21 @@ function ftp_rename($ftp, string $from, string $to): void */ function ftp_rmdir($ftp, string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_rmdir($ftp, $directory); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -488,10 +730,21 @@ function ftp_rmdir($ftp, string $directory): void */ function ftp_site($ftp, string $command): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_site($ftp, $command); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } } @@ -519,10 +772,21 @@ function ftp_site($ftp, string $command): void */ function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_ssl_connect($hostname, $port, $timeout); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } @@ -538,10 +802,21 @@ function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90) */ function ftp_systype($ftp): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ftp_systype($ftp); + restore_error_handler(); + if ($result === false) { - throw FtpException::createFromPhpError(); + throw FtpException::createFromPhpError($error); } return $result; } diff --git a/generated/funchand.php b/generated/funchand.php index 4b2a7b8f..856ee374 100644 --- a/generated/funchand.php +++ b/generated/funchand.php @@ -18,10 +18,21 @@ */ function create_function(string $args, string $code): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \create_function($args, $code); + restore_error_handler(); + if ($result === false) { - throw FunchandException::createFromPhpError(); + throw FunchandException::createFromPhpError($error); } return $result; } @@ -37,13 +48,24 @@ function create_function(string $args, string $code): string */ function register_tick_function(callable $callback, ...$args): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($args !== []) { $result = \register_tick_function($callback, ...$args); } else { $result = \register_tick_function($callback); } + restore_error_handler(); + if ($result === false) { - throw FunchandException::createFromPhpError(); + throw FunchandException::createFromPhpError($error); } } diff --git a/generated/functionsList.php b/generated/functionsList.php index 58e78822..b1c28d6f 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -14,7 +14,6 @@ 'apcu_inc', 'apcu_sma_info', 'apc_fetch', - 'array_combine', 'array_replace', 'array_replace_recursive', 'array_walk_recursive', diff --git a/generated/gettext.php b/generated/gettext.php index f7816e38..d120ff5c 100644 --- a/generated/gettext.php +++ b/generated/gettext.php @@ -18,10 +18,21 @@ */ function bindtextdomain(string $domain, string $directory): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \bindtextdomain($domain, $directory); + restore_error_handler(); + if ($result === false) { - throw GettextException::createFromPhpError(); + throw GettextException::createFromPhpError($error); } return $result; } diff --git a/generated/gmp.php b/generated/gmp.php index b2b88f6e..6be3b1c0 100644 --- a/generated/gmp.php +++ b/generated/gmp.php @@ -17,9 +17,20 @@ */ function gmp_random_seed($seed): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gmp_random_seed($seed); + restore_error_handler(); + if ($result === false) { - throw GmpException::createFromPhpError(); + throw GmpException::createFromPhpError($error); } } diff --git a/generated/gnupg.php b/generated/gnupg.php index 0ecb886b..c890afec 100644 --- a/generated/gnupg.php +++ b/generated/gnupg.php @@ -16,10 +16,21 @@ */ function gnupg_adddecryptkey($identifier, string $fingerprint, string $passphrase): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_adddecryptkey($identifier, $fingerprint, $passphrase); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -35,10 +46,21 @@ function gnupg_adddecryptkey($identifier, string $fingerprint, string $passphras */ function gnupg_addencryptkey($identifier, string $fingerprint): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_addencryptkey($identifier, $fingerprint); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -55,14 +77,25 @@ function gnupg_addencryptkey($identifier, string $fingerprint): void */ function gnupg_addsignkey($identifier, string $fingerprint, string $passphrase = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($passphrase !== null) { $result = \gnupg_addsignkey($identifier, $fingerprint, $passphrase); } else { $result = \gnupg_addsignkey($identifier, $fingerprint); } + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -77,10 +110,21 @@ function gnupg_addsignkey($identifier, string $fingerprint, string $passphrase = */ function gnupg_cleardecryptkeys($identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_cleardecryptkeys($identifier); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -95,10 +139,21 @@ function gnupg_cleardecryptkeys($identifier): void */ function gnupg_clearencryptkeys($identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_clearencryptkeys($identifier); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -113,10 +168,21 @@ function gnupg_clearencryptkeys($identifier): void */ function gnupg_clearsignkeys($identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_clearsignkeys($identifier); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -133,10 +199,21 @@ function gnupg_clearsignkeys($identifier): void */ function gnupg_deletekey($identifier, string $key, bool $allow_secret): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_deletekey($identifier, $key, $allow_secret); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -154,10 +231,21 @@ function gnupg_deletekey($identifier, string $key, bool $allow_secret): void */ function gnupg_setarmor($identifier, int $armor): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_setarmor($identifier, $armor); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } @@ -180,9 +268,20 @@ function gnupg_setarmor($identifier, int $armor): void */ function gnupg_setsignmode($identifier, int $signmode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gnupg_setsignmode($identifier, $signmode); + restore_error_handler(); + if ($result === false) { - throw GnupgException::createFromPhpError(); + throw GnupgException::createFromPhpError($error); } } diff --git a/generated/hash.php b/generated/hash.php index 5acbc267..0e687bcd 100644 --- a/generated/hash.php +++ b/generated/hash.php @@ -33,10 +33,21 @@ */ function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = ""): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \hash_hkdf($algo, $key, $length, $info, $salt); + restore_error_handler(); + if ($result === false) { - throw HashException::createFromPhpError(); + throw HashException::createFromPhpError($error); } return $result; } @@ -53,13 +64,24 @@ function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "" */ function hash_update_file(\HashContext $context, string $filename, ?\HashContext $stream_context = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($stream_context !== null) { $result = \hash_update_file($context, $filename, $stream_context); } else { $result = \hash_update_file($context, $filename); } + restore_error_handler(); + if ($result === false) { - throw HashException::createFromPhpError(); + throw HashException::createFromPhpError($error); } } diff --git a/generated/ibase.php b/generated/ibase.php index 7a619912..b1cfd2b0 100644 --- a/generated/ibase.php +++ b/generated/ibase.php @@ -14,10 +14,21 @@ */ function fbird_blob_cancel($blob_handle): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \fbird_blob_cancel($blob_handle); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -36,7 +47,16 @@ function fbird_blob_cancel($blob_handle): void */ function ibase_add_user($service_handle, string $user_name, string $password, string $first_name = null, string $middle_name = null, string $last_name = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($last_name !== null) { $result = \ibase_add_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name); } elseif ($middle_name !== null) { @@ -46,8 +66,10 @@ function ibase_add_user($service_handle, string $user_name, string $password, st } else { $result = \ibase_add_user($service_handle, $user_name, $password); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -81,10 +103,21 @@ function ibase_add_user($service_handle, string $user_name, string $password, st */ function ibase_backup($service_handle, string $source_db, string $dest_file, int $options = 0, bool $verbose = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_backup($service_handle, $source_db, $dest_file, $options, $verbose); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -100,10 +133,21 @@ function ibase_backup($service_handle, string $source_db, string $dest_file, int */ function ibase_blob_cancel($blob_handle): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_blob_cancel($blob_handle); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -121,14 +165,25 @@ function ibase_blob_cancel($blob_handle): void */ function ibase_blob_create($link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($link_identifier !== null) { $result = \ibase_blob_create($link_identifier); } else { $result = \ibase_blob_create(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -146,10 +201,21 @@ function ibase_blob_create($link_identifier = null) */ function ibase_blob_get($blob_handle, int $len): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_blob_get($blob_handle, $len); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -169,14 +235,25 @@ function ibase_blob_get($blob_handle, int $len): string */ function ibase_close($connection_id = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection_id !== null) { $result = \ibase_close($connection_id); } else { $result = \ibase_close(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -196,14 +273,25 @@ function ibase_close($connection_id = null): void */ function ibase_commit_ret($link_or_trans_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($link_or_trans_identifier !== null) { $result = \ibase_commit_ret($link_or_trans_identifier); } else { $result = \ibase_commit_ret(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -221,14 +309,25 @@ function ibase_commit_ret($link_or_trans_identifier = null): void */ function ibase_commit($link_or_trans_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($link_or_trans_identifier !== null) { $result = \ibase_commit($link_or_trans_identifier); } else { $result = \ibase_commit(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -268,7 +367,16 @@ function ibase_commit($link_or_trans_identifier = null): void */ function ibase_connect(string $database = null, string $username = null, string $password = null, string $charset = null, int $buffers = null, int $dialect = null, string $role = null, int $sync = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($sync !== null) { $result = \ibase_connect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync); } elseif ($role !== null) { @@ -288,8 +396,10 @@ function ibase_connect(string $database = null, string $username = null, string } else { $result = \ibase_connect(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -305,10 +415,21 @@ function ibase_connect(string $database = null, string $username = null, string */ function ibase_delete_user($service_handle, string $user_name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_delete_user($service_handle, $user_name); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -324,14 +445,25 @@ function ibase_delete_user($service_handle, string $user_name): void */ function ibase_drop_db($connection = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection !== null) { $result = \ibase_drop_db($connection); } else { $result = \ibase_drop_db(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -348,10 +480,21 @@ function ibase_drop_db($connection = null): void */ function ibase_free_event_handler($event): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_free_event_handler($event); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -365,10 +508,21 @@ function ibase_free_event_handler($event): void */ function ibase_free_query($query): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_free_query($query); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -383,10 +537,21 @@ function ibase_free_query($query): void */ function ibase_free_result($result_identifier): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_free_result($result_identifier); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -403,10 +568,21 @@ function ibase_free_result($result_identifier): void */ function ibase_maintain_db($service_handle, string $db, int $action, int $argument = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_maintain_db($service_handle, $db, $action, $argument); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -425,7 +601,16 @@ function ibase_maintain_db($service_handle, string $db, int $action, int $argume */ function ibase_modify_user($service_handle, string $user_name, string $password, string $first_name = null, string $middle_name = null, string $last_name = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($last_name !== null) { $result = \ibase_modify_user($service_handle, $user_name, $password, $first_name, $middle_name, $last_name); } elseif ($middle_name !== null) { @@ -435,8 +620,10 @@ function ibase_modify_user($service_handle, string $user_name, string $password, } else { $result = \ibase_modify_user($service_handle, $user_name, $password); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -452,10 +639,21 @@ function ibase_modify_user($service_handle, string $user_name, string $password, */ function ibase_name_result($result, string $name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_name_result($result, $name); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -502,7 +700,16 @@ function ibase_name_result($result, string $name): void */ function ibase_pconnect(string $database = null, string $username = null, string $password = null, string $charset = null, int $buffers = null, int $dialect = null, string $role = null, int $sync = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($sync !== null) { $result = \ibase_pconnect($database, $username, $password, $charset, $buffers, $dialect, $role, $sync); } elseif ($role !== null) { @@ -522,8 +729,10 @@ function ibase_pconnect(string $database = null, string $username = null, string } else { $result = \ibase_pconnect(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -561,10 +770,21 @@ function ibase_pconnect(string $database = null, string $username = null, string */ function ibase_restore($service_handle, string $source_file, string $dest_db, int $options = 0, bool $verbose = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_restore($service_handle, $source_file, $dest_db, $options, $verbose); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -585,14 +805,25 @@ function ibase_restore($service_handle, string $source_file, string $dest_db, in */ function ibase_rollback_ret($link_or_trans_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($link_or_trans_identifier !== null) { $result = \ibase_rollback_ret($link_or_trans_identifier); } else { $result = \ibase_rollback_ret(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -610,14 +841,25 @@ function ibase_rollback_ret($link_or_trans_identifier = null): void */ function ibase_rollback($link_or_trans_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($link_or_trans_identifier !== null) { $result = \ibase_rollback($link_or_trans_identifier); } else { $result = \ibase_rollback(); } + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } @@ -635,10 +877,21 @@ function ibase_rollback($link_or_trans_identifier = null): void */ function ibase_service_attach(string $host, string $dba_username, string $dba_password) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_service_attach($host, $dba_username, $dba_password); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } return $result; } @@ -653,9 +906,20 @@ function ibase_service_attach(string $host, string $dba_username, string $dba_pa */ function ibase_service_detach($service_handle): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ibase_service_detach($service_handle); + restore_error_handler(); + if ($result === false) { - throw IbaseException::createFromPhpError(); + throw IbaseException::createFromPhpError($error); } } diff --git a/generated/ibmDb2.php b/generated/ibmDb2.php index f97e7b08..468419aa 100644 --- a/generated/ibmDb2.php +++ b/generated/ibmDb2.php @@ -48,14 +48,25 @@ */ function db2_autocommit($connection, int $value = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($value !== null) { $result = \db2_autocommit($connection, $value); } else { $result = \db2_autocommit($connection); } + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } return $result; } @@ -98,7 +109,16 @@ function db2_autocommit($connection, int $value = null) */ function db2_bind_param($stmt, int $parameter_number, string $variable_name, int $parameter_type = null, int $data_type = 0, int $precision = -1, int $scale = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($scale !== 0) { $result = \db2_bind_param($stmt, $parameter_number, $variable_name, $parameter_type, $data_type, $precision, $scale); } elseif ($precision !== -1) { @@ -110,8 +130,10 @@ function db2_bind_param($stmt, int $parameter_number, string $variable_name, int } else { $result = \db2_bind_param($stmt, $parameter_number, $variable_name); } + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -227,10 +249,21 @@ function db2_bind_param($stmt, int $parameter_number, string $variable_name, int */ function db2_client_info($connection): object { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_client_info($connection); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } return $result; } @@ -251,10 +284,21 @@ function db2_client_info($connection): object */ function db2_close($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_close($connection); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -272,10 +316,21 @@ function db2_close($connection): void */ function db2_commit($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_commit($connection); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -306,14 +361,25 @@ function db2_commit($connection): void */ function db2_execute($stmt, array $parameters = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($parameters !== null) { $result = \db2_execute($stmt, $parameters); } else { $result = \db2_execute($stmt); } + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -330,10 +396,21 @@ function db2_execute($stmt, array $parameters = null): void */ function db2_free_result($stmt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_free_result($stmt); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -350,10 +427,21 @@ function db2_free_result($stmt): void */ function db2_free_stmt($stmt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_free_stmt($stmt); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -510,10 +598,21 @@ function db2_free_stmt($stmt): void */ function db2_get_option($resource, string $option): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_get_option($resource, $option); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } return $result; } @@ -543,10 +642,21 @@ function db2_get_option($resource, string $option): string */ function db2_pclose($resource): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_pclose($resource); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -564,10 +674,21 @@ function db2_pclose($resource): void */ function db2_rollback($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_rollback($connection); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } @@ -825,10 +946,21 @@ function db2_rollback($connection): void */ function db2_server_info($connection): object { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_server_info($connection); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } return $result; } @@ -1213,9 +1345,20 @@ function db2_server_info($connection): object */ function db2_set_option($resource, array $options, int $type): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \db2_set_option($resource, $options, $type); + restore_error_handler(); + if ($result === false) { - throw IbmDb2Exception::createFromPhpError(); + throw IbmDb2Exception::createFromPhpError($error); } } diff --git a/generated/iconv.php b/generated/iconv.php index 7b28b496..923fd405 100644 --- a/generated/iconv.php +++ b/generated/iconv.php @@ -25,10 +25,21 @@ */ function iconv_get_encoding(string $type = "all") { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \iconv_get_encoding($type); + restore_error_handler(); + if ($result === false) { - throw IconvException::createFromPhpError(); + throw IconvException::createFromPhpError($error); } return $result; } @@ -50,10 +61,21 @@ function iconv_get_encoding(string $type = "all") */ function iconv_set_encoding(string $type, string $encoding): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \iconv_set_encoding($type, $encoding); + restore_error_handler(); + if ($result === false) { - throw IconvException::createFromPhpError(); + throw IconvException::createFromPhpError($error); } } @@ -86,10 +108,21 @@ function iconv_set_encoding(string $type, string $encoding): void */ function iconv(string $from_encoding, string $to_encoding, string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \iconv($from_encoding, $to_encoding, $string); + restore_error_handler(); + if ($result === false) { - throw IconvException::createFromPhpError(); + throw IconvException::createFromPhpError($error); } return $result; } diff --git a/generated/image.php b/generated/image.php index 91342964..99f4c9e6 100644 --- a/generated/image.php +++ b/generated/image.php @@ -68,10 +68,21 @@ */ function getimagesize(string $filename, ?array &$image_info = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getimagesize($filename, $image_info); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -89,10 +100,21 @@ function getimagesize(string $filename, ?array &$image_info = null): array */ function image_type_to_extension(int $image_type, bool $include_dot = true): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \image_type_to_extension($image_type, $include_dot); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -114,7 +136,16 @@ function image_type_to_extension(int $image_type, bool $include_dot = true): str */ function image2wbmp($image, ?string $filename = null, int $foreground = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($foreground !== null) { $result = \image2wbmp($image, $filename, $foreground); } elseif ($filename !== null) { @@ -122,8 +153,10 @@ function image2wbmp($image, ?string $filename = null, int $foreground = null): v } else { $result = \image2wbmp($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -141,14 +174,25 @@ function image2wbmp($image, ?string $filename = null, int $foreground = null): v */ function imageaffine($image, array $affine, array $clip = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($clip !== null) { $result = \imageaffine($image, $affine, $clip); } else { $result = \imageaffine($image, $affine); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -170,10 +214,21 @@ function imageaffine($image, array $affine, array $clip = null) */ function imageaffinematrixconcat(array $matrix1, array $matrix2): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageaffinematrixconcat($matrix1, $matrix2); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -198,10 +253,21 @@ function imageaffinematrixconcat(array $matrix1, array $matrix2): array */ function imageaffinematrixget(int $type, $options): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageaffinematrixget($type, $options); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -228,10 +294,21 @@ function imageaffinematrixget(int $type, $options): array */ function imagealphablending($image, bool $enable): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagealphablending($image, $enable); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -256,10 +333,21 @@ function imagealphablending($image, bool $enable): void */ function imageantialias($image, bool $enable): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageantialias($image, $enable); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -284,10 +372,21 @@ function imageantialias($image, bool $enable): void */ function imagearc($image, int $center_x, int $center_y, int $width, int $height, int $start_angle, int $end_angle, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagearc($image, $center_x, $center_y, $width, $height, $start_angle, $end_angle, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -309,7 +408,16 @@ function imagearc($image, int $center_x, int $center_y, int $width, int $height, */ function imageavif(\GdImage $image, $file = null, int $quality = -1, int $speed = -1): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($speed !== -1) { $result = \imageavif($image, $file, $quality, $speed); } elseif ($quality !== -1) { @@ -319,8 +427,10 @@ function imageavif(\GdImage $image, $file = null, int $quality = -1, int $speed } else { $result = \imageavif($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -340,7 +450,16 @@ function imageavif(\GdImage $image, $file = null, int $quality = -1, int $speed */ function imagebmp($image, $file = null, bool $compressed = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($compressed !== true) { $result = \imagebmp($image, $file, $compressed); } elseif ($file !== null) { @@ -348,8 +467,10 @@ function imagebmp($image, $file = null, bool $compressed = true): void } else { $result = \imagebmp($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -375,10 +496,21 @@ function imagebmp($image, $file = null, bool $compressed = true): void */ function imagechar($image, int $font, int $x, int $y, string $char, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagechar($image, $font, $x, $y, $char, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -401,10 +533,21 @@ function imagechar($image, int $font, int $x, int $y, string $char, int $color): */ function imagecharup($image, int $font, int $x, int $y, string $char, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecharup($image, $font, $x, $y, $char, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -428,10 +571,21 @@ function imagecharup($image, int $font, int $x, int $y, string $char, int $color */ function imagecolorat($image, int $x, int $y): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecolorat($image, $x, $y); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -450,10 +604,21 @@ function imagecolorat($image, int $x, int $y): int */ function imagecolordeallocate($image, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecolordeallocate($image, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -469,10 +634,21 @@ function imagecolordeallocate($image, int $color): void */ function imagecolormatch($image1, $image2): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecolormatch($image1, $image2); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -495,10 +671,21 @@ function imagecolormatch($image1, $image2): void */ function imagecolorset($image, int $color, int $red, int $green, int $blue, int $alpha = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecolorset($image, $color, $red, $green, $blue, $alpha); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -517,10 +704,21 @@ function imagecolorset($image, int $color, int $red, int $green, int $blue, int */ function imageconvolution($image, array $matrix, float $divisor, float $offset): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageconvolution($image, $matrix, $divisor, $offset); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -547,10 +745,21 @@ function imageconvolution($image, array $matrix, float $divisor, float $offset): */ function imagecopy($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecopy($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -583,10 +792,21 @@ function imagecopy($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, i */ function imagecopymerge($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height, int $pct): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecopymerge($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -623,10 +843,21 @@ function imagecopymerge($dst_image, $src_image, int $dst_x, int $dst_y, int $src */ function imagecopymergegray($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height, int $pct): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecopymergegray($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -668,10 +899,21 @@ function imagecopymergegray($dst_image, $src_image, int $dst_x, int $dst_y, int */ function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_width, int $dst_height, int $src_width, int $src_height): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_width, $dst_height, $src_width, $src_height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -713,10 +955,21 @@ function imagecopyresampled($dst_image, $src_image, int $dst_x, int $dst_y, int */ function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_width, int $dst_height, int $src_width, int $src_height): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecopyresized($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_width, $dst_height, $src_width, $src_height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -741,10 +994,21 @@ function imagecopyresized($dst_image, $src_image, int $dst_x, int $dst_y, int $s */ function imagecreate(int $width, int $height) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreate($width, $height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -761,10 +1025,21 @@ function imagecreate(int $width, int $height) */ function imagecreatefromavif(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromavif($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -781,10 +1056,21 @@ function imagecreatefromavif(string $filename) */ function imagecreatefrombmp(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefrombmp($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -800,10 +1086,21 @@ function imagecreatefrombmp(string $filename) */ function imagecreatefromgd(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromgd($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -819,10 +1116,21 @@ function imagecreatefromgd(string $filename) */ function imagecreatefromgd2(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromgd2($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -842,10 +1150,21 @@ function imagecreatefromgd2(string $filename) */ function imagecreatefromgd2part(string $filename, int $x, int $y, int $width, int $height) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromgd2part($filename, $x, $y, $width, $height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -862,10 +1181,21 @@ function imagecreatefromgd2part(string $filename, int $x, int $y, int $width, in */ function imagecreatefromgif(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromgif($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -882,10 +1212,21 @@ function imagecreatefromgif(string $filename) */ function imagecreatefromjpeg(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromjpeg($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -902,10 +1243,21 @@ function imagecreatefromjpeg(string $filename) */ function imagecreatefrompng(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefrompng($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -922,10 +1274,21 @@ function imagecreatefrompng(string $filename) */ function imagecreatefromtga(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromtga($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -942,10 +1305,21 @@ function imagecreatefromtga(string $filename) */ function imagecreatefromwbmp(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromwbmp($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -963,10 +1337,21 @@ function imagecreatefromwbmp(string $filename) */ function imagecreatefromwebp(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromwebp($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -983,10 +1368,21 @@ function imagecreatefromwebp(string $filename) */ function imagecreatefromxbm(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromxbm($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1003,10 +1399,21 @@ function imagecreatefromxbm(string $filename) */ function imagecreatefromxpm(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatefromxpm($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1024,10 +1431,21 @@ function imagecreatefromxpm(string $filename) */ function imagecreatetruecolor(int $width, int $height) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecreatetruecolor($width, $height); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1048,10 +1466,21 @@ function imagecreatetruecolor(int $width, int $height) */ function imagecrop($image, array $rectangle) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecrop($image, $rectangle); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1073,10 +1502,21 @@ function imagecrop($image, array $rectangle) */ function imagecropauto($image, int $mode = IMG_CROP_DEFAULT, float $threshold = 0.5, int $color = -1) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagecropauto($image, $mode, $threshold, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1099,10 +1539,21 @@ function imagecropauto($image, int $mode = IMG_CROP_DEFAULT, float $threshold = */ function imagedashedline($image, int $x1, int $y1, int $x2, int $y2, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagedashedline($image, $x1, $y1, $x2, $y2, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1118,10 +1569,21 @@ function imagedashedline($image, int $x1, int $y1, int $x2, int $y2, int $color) */ function imagedestroy($image): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagedestroy($image); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1141,10 +1603,21 @@ function imagedestroy($image): void */ function imageellipse($image, int $center_x, int $center_y, int $width, int $height, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageellipse($image, $center_x, $center_y, $width, $height, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1164,10 +1637,21 @@ function imageellipse($image, int $center_x, int $center_y, int $width, int $hei */ function imagefill($image, int $x, int $y, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefill($image, $x, $y, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1208,10 +1692,21 @@ function imagefill($image, int $x, int $y, int $color): void */ function imagefilledarc($image, int $center_x, int $center_y, int $width, int $height, int $start_angle, int $end_angle, int $color, int $style): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefilledarc($image, $center_x, $center_y, $width, $height, $start_angle, $end_angle, $color, $style); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1232,10 +1727,21 @@ function imagefilledarc($image, int $center_x, int $center_y, int $width, int $h */ function imagefilledellipse($image, int $center_x, int $center_y, int $width, int $height, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefilledellipse($image, $center_x, $center_y, $width, $height, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1257,10 +1763,21 @@ function imagefilledellipse($image, int $center_x, int $center_y, int $width, in */ function imagefilledrectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefilledrectangle($image, $x1, $y1, $x2, $y2, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1283,10 +1800,21 @@ function imagefilledrectangle($image, int $x1, int $y1, int $x2, int $y2, int $c */ function imagefilltoborder($image, int $x, int $y, int $border_color, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefilltoborder($image, $x, $y, $border_color, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1429,14 +1957,25 @@ function imagefilltoborder($image, int $x, int $y, int $border_color, int $color */ function imagefilter($image, int $filter, int ...$args): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($args !== []) { $result = \imagefilter($image, $filter, ...$args); } else { $result = \imagefilter($image, $filter); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1484,10 +2023,21 @@ function imagefilter($image, int $filter, int ...$args): void */ function imageflip($image, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageflip($image, $mode); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1575,10 +2125,21 @@ function imageflip($image, int $mode): void */ function imageftbbox(float $size, float $angle, string $font_filename, string $string, array $options = []): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageftbbox($size, $angle, $font_filename, $string, $options); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1684,10 +2245,21 @@ function imageftbbox(float $size, float $angle, string $font_filename, string $s */ function imagefttext($image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagefttext($image, $size, $angle, $x, $y, $color, $font_filename, $text, $options); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1706,10 +2278,21 @@ function imagefttext($image, float $size, float $angle, int $x, int $y, int $col */ function imagegammacorrect($image, float $input_gamma, float $output_gamma): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagegammacorrect($image, $input_gamma, $output_gamma); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1725,14 +2308,25 @@ function imagegammacorrect($image, float $input_gamma, float $output_gamma): voi */ function imagegd($image, $file = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($file !== null) { $result = \imagegd($image, $file); } else { $result = \imagegd($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1752,7 +2346,16 @@ function imagegd($image, $file = null): void */ function imagegd2($image, $file = null, int $chunk_size = 128, int $mode = IMG_GD2_RAW): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($mode !== IMG_GD2_RAW) { $result = \imagegd2($image, $file, $chunk_size, $mode); } elseif ($chunk_size !== 128) { @@ -1762,8 +2365,10 @@ function imagegd2($image, $file = null, int $chunk_size = 128, int $mode = IMG_G } else { $result = \imagegd2($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1788,14 +2393,25 @@ function imagegd2($image, $file = null, int $chunk_size = 128, int $mode = IMG_G */ function imagegif($image, $file = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($file !== null) { $result = \imagegif($image, $file); } else { $result = \imagegif($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1809,10 +2425,21 @@ function imagegif($image, $file = null): void */ function imagegrabscreen() { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagegrabscreen(); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1829,10 +2456,11 @@ function imagegrabscreen() */ function imagegrabwindow(int $handle, bool $client_area = false): \GdImage { - error_clear_last(); $result = \imagegrabwindow($handle, $client_area); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -1853,7 +2481,16 @@ function imagegrabwindow(int $handle, bool $client_area = false): \GdImage */ function imagejpeg($image, $file = null, int $quality = -1): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($quality !== -1) { $result = \imagejpeg($image, $file, $quality); } elseif ($file !== null) { @@ -1861,8 +2498,10 @@ function imagejpeg($image, $file = null, int $quality = -1): void } else { $result = \imagejpeg($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1924,10 +2563,21 @@ function imagejpeg($image, $file = null, int $quality = -1): void */ function imagelayereffect($image, int $effect): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagelayereffect($image, $effect); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -1947,10 +2597,21 @@ function imagelayereffect($image, int $effect): void */ function imageline($image, int $x1, int $y1, int $x2, int $y2, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageline($image, $x1, $y1, $x2, $y2, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2013,10 +2674,21 @@ function imageline($image, int $x1, int $y1, int $x2, int $y2, int $color): void */ function imageloadfont(string $filename): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imageloadfont($filename); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2046,7 +2718,16 @@ function imageloadfont(string $filename): int */ function imagepng($image, $file = null, int $quality = -1, int $filters = -1): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($filters !== -1) { $result = \imagepng($image, $file, $quality, $filters); } elseif ($quality !== -1) { @@ -2056,8 +2737,10 @@ function imagepng($image, $file = null, int $quality = -1, int $filters = -1): v } else { $result = \imagepng($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2079,10 +2762,21 @@ function imagepng($image, $file = null, int $quality = -1, int $filters = -1): v */ function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagerectangle($image, $x1, $y1, $x2, $y2, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2114,7 +2808,16 @@ function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color): */ function imageresolution($image, int $resolution_x = null, int $resolution_y = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($resolution_y !== null) { $result = \imageresolution($image, $resolution_x, $resolution_y); } elseif ($resolution_x !== null) { @@ -2122,8 +2825,10 @@ function imageresolution($image, int $resolution_x = null, int $resolution_y = n } else { $result = \imageresolution($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2148,10 +2853,21 @@ function imageresolution($image, int $resolution_x = null, int $resolution_y = n */ function imagerotate($image, float $angle, int $background_color, bool $ignore_transparent = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagerotate($image, $angle, $background_color, $ignore_transparent); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2173,10 +2889,21 @@ function imagerotate($image, float $angle, int $background_color, bool $ignore_t */ function imagesavealpha($image, bool $enable): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesavealpha($image, $enable); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2206,10 +2933,21 @@ function imagesavealpha($image, bool $enable): void */ function imagescale($image, int $width, int $height = -1, int $mode = IMG_BILINEAR_FIXED) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagescale($image, $width, $height, $mode); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2230,10 +2968,21 @@ function imagescale($image, int $width, int $height = -1, int $mode = IMG_BILINE */ function imagesetbrush($image, $brush): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetbrush($image, $brush); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2253,10 +3002,21 @@ function imagesetbrush($image, $brush): void */ function imagesetclip($image, int $x1, int $y1, int $x2, int $y2): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetclip($image, $x1, $y1, $x2, $y2); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2380,10 +3140,21 @@ function imagesetclip($image, int $x1, int $y1, int $x2, int $y2): void */ function imagesetinterpolation($image, int $method = IMG_BILINEAR_FIXED): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetinterpolation($image, $method); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2402,10 +3173,21 @@ function imagesetinterpolation($image, int $method = IMG_BILINEAR_FIXED): void */ function imagesetpixel($image, int $x, int $y, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetpixel($image, $x, $y, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2428,10 +3210,21 @@ function imagesetpixel($image, int $x, int $y, int $color): void */ function imagesetstyle($image, array $style): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetstyle($image, $style); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2449,10 +3242,21 @@ function imagesetstyle($image, array $style): void */ function imagesetthickness($image, int $thickness): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesetthickness($image, $thickness); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2476,10 +3280,21 @@ function imagesetthickness($image, int $thickness): void */ function imagesettile($image, $tile): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesettile($image, $tile); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2501,10 +3316,21 @@ function imagesettile($image, $tile): void */ function imagestring($image, int $font, int $x, int $y, string $string, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagestring($image, $font, $x, $y, $string, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2527,10 +3353,21 @@ function imagestring($image, int $font, int $x, int $y, string $string, int $col */ function imagestringup($image, int $font, int $x, int $y, string $string, int $color): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagestringup($image, $font, $x, $y, $string, $color); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2546,10 +3383,21 @@ function imagestringup($image, int $font, int $x, int $y, string $string, int $c */ function imagesx($image): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesx($image); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2566,10 +3414,21 @@ function imagesx($image): int */ function imagesy($image): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagesy($image); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2596,10 +3455,21 @@ function imagesy($image): int */ function imagetruecolortopalette($image, bool $dither, int $num_colors): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagetruecolortopalette($image, $dither, $num_colors); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2691,10 +3561,21 @@ function imagetruecolortopalette($image, bool $dither, int $num_colors): void */ function imagettfbbox(float $size, float $angle, string $font_filename, string $string, array $options = []): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagettfbbox($size, $angle, $font_filename, $string, $options); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2768,10 +3649,21 @@ function imagettfbbox(float $size, float $angle, string $font_filename, string $ */ function imagettftext($image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imagettftext($image, $size, $angle, $x, $y, $color, $font_filename, $text, $options); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2792,7 +3684,16 @@ function imagettftext($image, float $size, float $angle, int $x, int $y, int $co */ function imagewbmp($image, $file = null, int $foreground_color = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($foreground_color !== null) { $result = \imagewbmp($image, $file, $foreground_color); } elseif ($file !== null) { @@ -2800,8 +3701,10 @@ function imagewbmp($image, $file = null, int $foreground_color = null): void } else { $result = \imagewbmp($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2819,7 +3722,16 @@ function imagewbmp($image, $file = null, int $foreground_color = null): void */ function imagewebp($image, $file = null, int $quality = -1): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($quality !== -1) { $result = \imagewebp($image, $file, $quality); } elseif ($file !== null) { @@ -2827,8 +3739,10 @@ function imagewebp($image, $file = null, int $quality = -1): void } else { $result = \imagewebp($image); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2855,14 +3769,25 @@ function imagewebp($image, $file = null, int $quality = -1): void */ function imagexbm($image, $filename, int $foreground_color = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($foreground_color !== null) { $result = \imagexbm($image, $filename, $foreground_color); } else { $result = \imagexbm($image, $filename); } + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2880,10 +3805,21 @@ function imagexbm($image, $filename, int $foreground_color = null): void */ function iptcembed(string $iptc_data, string $filename, int $spool = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \iptcembed($iptc_data, $filename, $spool); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2900,10 +3836,21 @@ function iptcembed(string $iptc_data, string $filename, int $spool = 0) */ function iptcparse(string $iptc_block): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \iptcparse($iptc_block); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } return $result; } @@ -2922,10 +3869,21 @@ function iptcparse(string $iptc_block): array */ function jpeg2wbmp(string $jpegname, string $wbmpname, int $dest_height, int $dest_width, int $threshold): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \jpeg2wbmp($jpegname, $wbmpname, $dest_height, $dest_width, $threshold); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } @@ -2943,9 +3901,20 @@ function jpeg2wbmp(string $jpegname, string $wbmpname, int $dest_height, int $de */ function png2wbmp(string $pngname, string $wbmpname, int $dest_height, int $dest_width, int $threshold): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \png2wbmp($pngname, $wbmpname, $dest_height, $dest_width, $threshold); + restore_error_handler(); + if ($result === false) { - throw ImageException::createFromPhpError(); + throw ImageException::createFromPhpError($error); } } diff --git a/generated/imap.php b/generated/imap.php index 917a8e20..380c721a 100644 --- a/generated/imap.php +++ b/generated/imap.php @@ -15,10 +15,21 @@ */ function imap_8bit(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_8bit($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -43,7 +54,16 @@ function imap_8bit(string $string): string */ function imap_append($imap, string $folder, string $message, string $options = null, string $internal_date = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($internal_date !== null) { $result = \imap_append($imap, $folder, $message, $options, $internal_date); } elseif ($options !== null) { @@ -51,8 +71,10 @@ function imap_append($imap, string $folder, string $message, string $options = n } else { $result = \imap_append($imap, $folder, $message); } + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -67,10 +89,21 @@ function imap_append($imap, string $folder, string $message, string $options = n */ function imap_base64(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_base64($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -86,10 +119,21 @@ function imap_base64(string $string): string */ function imap_binary(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_binary($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -134,10 +178,21 @@ function imap_binary(string $string): string */ function imap_body($imap, int $message_num, int $flags = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_body($imap, $message_num, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -158,10 +213,21 @@ function imap_body($imap, int $message_num, int $flags = 0): string */ function imap_bodystruct($imap, int $message_num, string $section): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_bodystruct($imap, $message_num, $section); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -207,10 +273,21 @@ function imap_bodystruct($imap, int $message_num, string $section): \stdClass */ function imap_check($imap): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_check($imap); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -242,10 +319,21 @@ function imap_check($imap): \stdClass */ function imap_clearflag_full($imap, string $sequence, string $flag, int $options = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_clearflag_full($imap, $sequence, $flag, $options); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -263,10 +351,21 @@ function imap_clearflag_full($imap, string $sequence, string $flag, int $options */ function imap_close($imap, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_close($imap, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -283,10 +382,21 @@ function imap_close($imap, int $flags = 0): void */ function imap_createmailbox($imap, string $mailbox): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_createmailbox($imap, $mailbox); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -302,10 +412,21 @@ function imap_createmailbox($imap, string $mailbox): void */ function imap_deletemailbox($imap, string $mailbox): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_deletemailbox($imap, $mailbox); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -418,10 +539,21 @@ function imap_deletemailbox($imap, string $mailbox): void */ function imap_fetch_overview($imap, string $sequence, int $flags = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_fetch_overview($imap, $sequence, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -462,10 +594,21 @@ function imap_fetch_overview($imap, string $sequence, int $flags = 0): array */ function imap_fetchbody($imap, int $message_num, string $section, int $flags = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_fetchbody($imap, $message_num, $section, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -507,10 +650,21 @@ function imap_fetchbody($imap, int $message_num, string $section, int $flags = 0 */ function imap_fetchheader($imap, int $message_num, int $flags = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_fetchheader($imap, $message_num, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -550,10 +704,21 @@ function imap_fetchheader($imap, int $message_num, int $flags = 0): string */ function imap_fetchmime($imap, int $message_num, string $section, int $flags = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_fetchmime($imap, $message_num, $section, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -697,10 +862,21 @@ function imap_fetchmime($imap, int $message_num, string $section, int $flags = 0 */ function imap_fetchstructure($imap, int $message_num, int $flags = 0): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_fetchstructure($imap, $message_num, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -720,10 +896,21 @@ function imap_fetchstructure($imap, int $message_num, int $flags = 0): \stdClass */ function imap_gc($imap, int $flags): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_gc($imap, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -740,10 +927,21 @@ function imap_gc($imap, int $flags): void */ function imap_getacl($imap, string $mailbox): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_getacl($imap, $mailbox); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -826,10 +1024,21 @@ function imap_getacl($imap, string $mailbox): array */ function imap_getmailboxes($imap, string $reference, string $pattern): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_getmailboxes($imap, $reference, $pattern); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -912,10 +1121,21 @@ function imap_getmailboxes($imap, string $reference, string $pattern): array */ function imap_getsubscribed($imap, string $reference, string $pattern): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_getsubscribed($imap, $reference, $pattern); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1137,10 +1357,21 @@ function imap_getsubscribed($imap, string $reference, string $pattern): array */ function imap_headerinfo($imap, int $message_num, int $from_length = 0, int $subject_length = 0): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_headerinfo($imap, $message_num, $from_length, $subject_length); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1158,10 +1389,21 @@ function imap_headerinfo($imap, int $message_num, int $from_length = 0, int $sub */ function imap_headers($imap): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_headers($imap); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1200,10 +1442,21 @@ function imap_headers($imap): array */ function imap_listscan($imap, string $reference, string $pattern, string $content): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_listscan($imap, $reference, $pattern, $content); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1235,10 +1488,21 @@ function imap_listscan($imap, string $reference, string $pattern, string $conten */ function imap_lsub($imap, string $reference, string $pattern): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_lsub($imap, $reference, $pattern); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1353,10 +1617,21 @@ function imap_lsub($imap, string $reference, string $pattern): array */ function imap_mail_compose(array $envelope, array $bodies): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mail_compose($envelope, $bodies); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1391,10 +1666,21 @@ function imap_mail_compose(array $envelope, array $bodies): string */ function imap_mail_copy($imap, string $message_nums, string $mailbox, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mail_copy($imap, $message_nums, $mailbox, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1424,10 +1710,21 @@ function imap_mail_copy($imap, string $message_nums, string $mailbox, int $flags */ function imap_mail_move($imap, string $message_nums, string $mailbox, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mail_move($imap, $message_nums, $mailbox, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1454,7 +1751,16 @@ function imap_mail_move($imap, string $message_nums, string $mailbox, int $flags */ function imap_mail(string $to, string $subject, string $message, string $additional_headers = null, string $cc = null, string $bcc = null, string $return_path = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($return_path !== null) { $result = \imap_mail($to, $subject, $message, $additional_headers, $cc, $bcc, $return_path); } elseif ($bcc !== null) { @@ -1466,8 +1772,10 @@ function imap_mail(string $to, string $subject, string $message, string $additio } else { $result = \imap_mail($to, $subject, $message); } + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1526,10 +1834,21 @@ function imap_mail(string $to, string $subject, string $message, string $additio */ function imap_mailboxmsginfo($imap): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mailboxmsginfo($imap); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1553,10 +1872,21 @@ function imap_mailboxmsginfo($imap): \stdClass */ function imap_mime_header_decode(string $string): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mime_header_decode($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1572,10 +1902,21 @@ function imap_mime_header_decode(string $string): array */ function imap_mutf7_to_utf8(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_mutf7_to_utf8($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1591,10 +1932,21 @@ function imap_mutf7_to_utf8(string $string): string */ function imap_num_msg($imap): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_num_msg($imap); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1806,10 +2158,21 @@ function imap_num_msg($imap): int */ function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_open($mailbox, $user, $password, $flags, $retries, $options); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1825,10 +2188,21 @@ function imap_open(string $mailbox, string $user, string $password, int $flags = */ function imap_qprint(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_qprint($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1849,10 +2223,21 @@ function imap_qprint(string $string): string */ function imap_renamemailbox($imap, string $from, string $to): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_renamemailbox($imap, $from, $to); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1870,10 +2255,21 @@ function imap_renamemailbox($imap, string $from, string $to): void */ function imap_rfc822_write_address(?string $mailbox, ?string $hostname, ?string $personal): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_rfc822_write_address($mailbox, $hostname, $personal); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -1913,10 +2309,21 @@ function imap_rfc822_write_address(?string $mailbox, ?string $hostname, ?string */ function imap_savebody($imap, $file, int $message_num, string $section = "", int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_savebody($imap, $file, $message_num, $section, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1933,10 +2340,21 @@ function imap_savebody($imap, $file, int $message_num, string $section = "", int */ function imap_set_quota($imap, string $quota_root, int $mailbox_size): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_set_quota($imap, $quota_root, $mailbox_size); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1955,10 +2373,21 @@ function imap_set_quota($imap, string $quota_root, int $mailbox_size): void */ function imap_setacl($imap, string $mailbox, string $user_id, string $rights): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_setacl($imap, $mailbox, $user_id, $rights); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -1990,10 +2419,21 @@ function imap_setacl($imap, string $mailbox, string $user_id, string $rights): v */ function imap_setflag_full($imap, string $sequence, string $flag, int $options = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_setflag_full($imap, $sequence, $flag, $options); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -2065,7 +2505,16 @@ function imap_setflag_full($imap, string $sequence, string $flag, int $options = */ function imap_sort($imap, int $criteria, int $reverse, int $flags = 0, string $search_criteria = null, string $charset = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($charset !== null) { $result = \imap_sort($imap, $criteria, $reverse, $flags, $search_criteria, $charset); } elseif ($search_criteria !== null) { @@ -2073,8 +2522,10 @@ function imap_sort($imap, int $criteria, int $reverse, int $flags = 0, string $s } else { $result = \imap_sort($imap, $criteria, $reverse, $flags); } + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -2137,10 +2588,21 @@ function imap_sort($imap, int $criteria, int $reverse, int $flags = 0, string $s */ function imap_status($imap, string $mailbox, int $flags): \stdClass { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_status($imap, $mailbox, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -2157,10 +2619,21 @@ function imap_status($imap, string $mailbox, int $flags): \stdClass */ function imap_subscribe($imap, string $mailbox): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_subscribe($imap, $mailbox); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -2191,10 +2664,21 @@ function imap_subscribe($imap, string $mailbox): void */ function imap_thread($imap, int $flags = SE_FREE): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_thread($imap, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -2220,10 +2704,21 @@ function imap_thread($imap, int $flags = SE_FREE): array */ function imap_timeout(int $timeout_type, int $timeout = -1) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_timeout($timeout_type, $timeout); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } @@ -2243,10 +2738,21 @@ function imap_timeout(int $timeout_type, int $timeout = -1) */ function imap_undelete($imap, string $message_nums, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_undelete($imap, $message_nums, $flags); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -2262,10 +2768,21 @@ function imap_undelete($imap, string $message_nums, int $flags = 0): void */ function imap_unsubscribe($imap, string $mailbox): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_unsubscribe($imap, $mailbox); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } } @@ -2280,10 +2797,21 @@ function imap_unsubscribe($imap, string $mailbox): void */ function imap_utf8_to_mutf7(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \imap_utf8_to_mutf7($string); + restore_error_handler(); + if ($result === false) { - throw ImapException::createFromPhpError(); + throw ImapException::createFromPhpError($error); } return $result; } diff --git a/generated/info.php b/generated/info.php index aefa0819..19a82d7f 100644 --- a/generated/info.php +++ b/generated/info.php @@ -108,14 +108,25 @@ */ function assert_options(int $what, $value = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($value !== null) { $result = \assert_options($what, $value); } else { $result = \assert_options($what); } + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -132,10 +143,21 @@ function assert_options(int $what, $value = null) */ function cli_set_process_title(string $title): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \cli_set_process_title($title); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } @@ -196,10 +218,21 @@ function cli_set_process_title(string $title): void */ function dl(string $extension_filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \dl($extension_filename); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } @@ -213,10 +246,21 @@ function dl(string $extension_filename): void */ function get_include_path(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \get_include_path(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -236,10 +280,21 @@ function get_include_path(): string */ function getlastmod(): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getlastmod(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -254,10 +309,21 @@ function getlastmod(): int */ function getmygid(): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getmygid(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -272,10 +338,21 @@ function getmygid(): int */ function getmyinode(): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getmyinode(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -290,10 +367,21 @@ function getmyinode(): int */ function getmypid(): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getmypid(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -308,10 +396,21 @@ function getmypid(): int */ function getmyuid(): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getmyuid(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -329,10 +428,21 @@ function getmyuid(): int */ function getopt(string $short_options, array $long_options = [], ?int &$rest_index = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getopt($short_options, $long_options, $rest_index); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -352,10 +462,21 @@ function getopt(string $short_options, array $long_options = [], ?int &$rest_ind */ function getrusage(int $mode = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getrusage($mode); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -373,10 +494,21 @@ function getrusage(int $mode = 0): array */ function ini_get(string $option): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ini_get($option); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -397,10 +529,21 @@ function ini_get(string $option): string */ function ini_set(string $option, string $value): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ini_set($option, $value); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -424,10 +567,21 @@ function ini_set(string $option, string $value): string */ function php_sapi_name(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \php_sapi_name(); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -504,10 +658,21 @@ function php_sapi_name(): string */ function phpcredits(int $flags = CREDITS_ALL): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \phpcredits($flags); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } @@ -614,10 +779,21 @@ function phpcredits(int $flags = CREDITS_ALL): void */ function phpinfo(int $flags = INFO_ALL): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \phpinfo($flags); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } @@ -634,10 +810,21 @@ function phpinfo(int $flags = INFO_ALL): void */ function putenv(string $assignment): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \putenv($assignment); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } @@ -654,10 +841,21 @@ function putenv(string $assignment): void */ function set_include_path(string $include_path): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \set_include_path($include_path); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } return $result; } @@ -682,9 +880,20 @@ function set_include_path(string $include_path): string */ function set_time_limit(int $seconds): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \set_time_limit($seconds); + restore_error_handler(); + if ($result === false) { - throw InfoException::createFromPhpError(); + throw InfoException::createFromPhpError($error); } } diff --git a/generated/inotify.php b/generated/inotify.php index 2e070415..1b8f8f72 100644 --- a/generated/inotify.php +++ b/generated/inotify.php @@ -14,10 +14,21 @@ */ function inotify_init() { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inotify_init(); + restore_error_handler(); + if ($result === false) { - throw InotifyException::createFromPhpError(); + throw InotifyException::createFromPhpError($error); } return $result; } @@ -36,9 +47,20 @@ function inotify_init() */ function inotify_rm_watch($inotify_instance, int $watch_descriptor): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inotify_rm_watch($inotify_instance, $watch_descriptor); + restore_error_handler(); + if ($result === false) { - throw InotifyException::createFromPhpError(); + throw InotifyException::createFromPhpError($error); } } diff --git a/generated/json.php b/generated/json.php index 76fc6c17..c195db06 100644 --- a/generated/json.php +++ b/generated/json.php @@ -44,10 +44,21 @@ */ function json_encode($value, int $flags = 0, int $depth = 512): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \json_encode($value, $flags, $depth); + restore_error_handler(); + if ($result === false) { - throw JsonException::createFromPhpError(); + throw JsonException::createFromPhpError($error); } return $result; } diff --git a/generated/ldap.php b/generated/ldap.php index 97b42e5a..6c0c871c 100644 --- a/generated/ldap.php +++ b/generated/ldap.php @@ -19,10 +19,21 @@ */ function ldap_8859_to_t61(string $value): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_8859_to_t61($value); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -49,14 +60,25 @@ function ldap_8859_to_t61(string $value): string */ function ldap_add($ldap, string $dn, array $entry, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_add($ldap, $dn, $entry, $controls); } else { $result = \ldap_add($ldap, $dn, $entry); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -72,7 +94,16 @@ function ldap_add($ldap, string $dn, array $entry, array $controls = null): void */ function ldap_bind($ldap, ?string $dn = null, ?string $password = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($password !== null) { $result = \ldap_bind($ldap, $dn, $password); } elseif ($dn !== null) { @@ -80,8 +111,10 @@ function ldap_bind($ldap, ?string $dn = null, ?string $password = null): void } else { $result = \ldap_bind($ldap); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -98,10 +131,21 @@ function ldap_bind($ldap, ?string $dn = null, ?string $password = null): void */ function ldap_control_paged_result_response($link, $result, ?string &$cookie = null, ?int &$estimated = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_control_paged_result_response($link, $result, $cookie, $estimated); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -121,10 +165,21 @@ function ldap_control_paged_result_response($link, $result, ?string &$cookie = n */ function ldap_control_paged_result($link, int $pagesize, bool $iscritical = false, string $cookie = ""): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_control_paged_result($link, $pagesize, $iscritical, $cookie); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -141,10 +196,21 @@ function ldap_control_paged_result($link, int $pagesize, bool $iscritical = fals */ function ldap_count_entries($ldap, $result): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_count_entries($ldap, $result); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -161,14 +227,25 @@ function ldap_count_entries($ldap, $result): int */ function ldap_delete($ldap, string $dn, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_delete($ldap, $dn, $controls); } else { $result = \ldap_delete($ldap, $dn); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -184,10 +261,21 @@ function ldap_delete($ldap, string $dn, array $controls = null): void */ function ldap_dn2ufn(string $dn): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_dn2ufn($dn); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -210,10 +298,21 @@ function ldap_dn2ufn(string $dn): string */ function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", string $new_password = "", array &$controls = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_exop_passwd($ldap, $user, $old_password, $new_password, $controls); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -229,10 +328,21 @@ function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", s */ function ldap_exop_whoami($ldap) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_exop_whoami($ldap); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -258,7 +368,16 @@ function ldap_exop_whoami($ldap) */ function ldap_exop($ldap, string $reqoid, string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($retoid !== null) { $result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls, $retdata, $retoid); } elseif ($retdata !== null) { @@ -270,8 +389,10 @@ function ldap_exop($ldap, string $reqoid, string $reqdata = null, ?array $server } else { $result = \ldap_exop($ldap, $reqoid); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -296,10 +417,21 @@ function ldap_exop($ldap, string $reqoid, string $reqdata = null, ?array $server */ function ldap_explode_dn(string $dn, int $with_attrib): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_explode_dn($dn, $with_attrib); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -321,10 +453,21 @@ function ldap_explode_dn(string $dn, int $with_attrib): array */ function ldap_first_attribute($ldap, $entry): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_first_attribute($ldap, $entry); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -347,10 +490,21 @@ function ldap_first_attribute($ldap, $entry): string */ function ldap_first_entry($ldap, $result) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_first_entry($ldap, $result); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -371,10 +525,21 @@ function ldap_first_entry($ldap, $result) */ function ldap_free_result($result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_free_result($result); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -403,10 +568,21 @@ function ldap_free_result($result): void */ function ldap_get_attributes($ldap, $entry): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_attributes($ldap, $entry); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -423,10 +599,21 @@ function ldap_get_attributes($ldap, $entry): array */ function ldap_get_dn($ldap, $entry): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_dn($ldap, $entry); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -455,10 +642,21 @@ function ldap_get_dn($ldap, $entry): string */ function ldap_get_entries($ldap, $result): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_entries($ldap, $result); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -648,10 +846,21 @@ function ldap_get_entries($ldap, $result): array */ function ldap_get_option($ldap, int $option, &$value = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_option($ldap, $option, $value); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -674,10 +883,21 @@ function ldap_get_option($ldap, int $option, &$value = null): void */ function ldap_get_values_len($ldap, $entry, string $attribute): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_values_len($ldap, $entry, $attribute); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -718,10 +938,21 @@ function ldap_get_values_len($ldap, $entry, string $attribute): array */ function ldap_get_values($ldap, $entry, string $attribute): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_get_values($ldap, $entry, $attribute); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -740,14 +971,25 @@ function ldap_get_values($ldap, $entry, string $attribute): array */ function ldap_mod_add($ldap, string $dn, array $entry, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_mod_add($ldap, $dn, $entry, $controls); } else { $result = \ldap_mod_add($ldap, $dn, $entry); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -766,14 +1008,25 @@ function ldap_mod_add($ldap, string $dn, array $entry, array $controls = null): */ function ldap_mod_del($ldap, string $dn, array $entry, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_mod_del($ldap, $dn, $entry, $controls); } else { $result = \ldap_mod_del($ldap, $dn, $entry); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -791,14 +1044,25 @@ function ldap_mod_del($ldap, string $dn, array $entry, array $controls = null): */ function ldap_mod_replace($ldap, string $dn, array $entry, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_mod_replace($ldap, $dn, $entry, $controls); } else { $result = \ldap_mod_replace($ldap, $dn, $entry); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -890,14 +1154,25 @@ function ldap_mod_replace($ldap, string $dn, array $entry, array $controls = nul */ function ldap_modify_batch($ldap, string $dn, array $modifications_info, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_modify_batch($ldap, $dn, $modifications_info, $controls); } else { $result = \ldap_modify_batch($ldap, $dn, $modifications_info); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -917,10 +1192,21 @@ function ldap_modify_batch($ldap, string $dn, array $modifications_info, array $ */ function ldap_next_attribute($ldap, $entry): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_next_attribute($ldap, $entry); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } return $result; } @@ -938,10 +1224,21 @@ function ldap_next_attribute($ldap, $entry): string */ function ldap_parse_exop($ldap, $result, ?string &$response_data = null, ?string &$response_oid = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_parse_exop($ldap, $result, $response_data, $response_oid); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -966,10 +1263,21 @@ function ldap_parse_exop($ldap, $result, ?string &$response_data = null, ?string */ function ldap_parse_result($ldap, $result, ?int &$error_code, ?string &$matched_dn = null, ?string &$error_message = null, ?array &$referrals = null, ?array &$controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_parse_result($ldap, $result, $error_code, $matched_dn, $error_message, $referrals, $controls); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -989,14 +1297,25 @@ function ldap_parse_result($ldap, $result, ?int &$error_code, ?string &$matched_ */ function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, array $controls = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($controls !== null) { $result = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn, $controls); } else { $result = \ldap_rename($ldap, $dn, $new_rdn, $new_parent, $delete_old_rdn); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -1017,7 +1336,16 @@ function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, boo */ function ldap_sasl_bind($ldap, string $dn = null, string $password = null, string $mech = null, string $realm = null, string $authc_id = null, string $authz_id = null, string $props = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($props !== null) { $result = \ldap_sasl_bind($ldap, $dn, $password, $mech, $realm, $authc_id, $authz_id, $props); } elseif ($authz_id !== null) { @@ -1035,8 +1363,10 @@ function ldap_sasl_bind($ldap, string $dn = null, string $password = null, strin } else { $result = \ldap_sasl_bind($ldap); } + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -1219,10 +1549,21 @@ function ldap_sasl_bind($ldap, string $dn = null, string $password = null, strin */ function ldap_set_option($ldap, int $option, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_set_option($ldap, $option, $value); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } @@ -1236,9 +1577,20 @@ function ldap_set_option($ldap, int $option, $value): void */ function ldap_unbind($ldap): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ldap_unbind($ldap); + restore_error_handler(); + if ($result === false) { - throw LdapException::createFromPhpError(); + throw LdapException::createFromPhpError($error); } } diff --git a/generated/libxml.php b/generated/libxml.php index 74925c12..3cb648ea 100644 --- a/generated/libxml.php +++ b/generated/libxml.php @@ -14,10 +14,21 @@ */ function libxml_get_last_error(): \LibXMLError { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \libxml_get_last_error(); + restore_error_handler(); + if ($result === false) { - throw LibxmlException::createFromPhpError(); + throw LibxmlException::createFromPhpError($error); } return $result; } @@ -70,9 +81,20 @@ function libxml_get_last_error(): \LibXMLError */ function libxml_set_external_entity_loader(callable $resolver_function): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \libxml_set_external_entity_loader($resolver_function); + restore_error_handler(); + if ($result === false) { - throw LibxmlException::createFromPhpError(); + throw LibxmlException::createFromPhpError($error); } } diff --git a/generated/lzf.php b/generated/lzf.php index 7fce838a..a95885c4 100644 --- a/generated/lzf.php +++ b/generated/lzf.php @@ -15,10 +15,21 @@ */ function lzf_compress(string $data): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \lzf_compress($data); + restore_error_handler(); + if ($result === false) { - throw LzfException::createFromPhpError(); + throw LzfException::createFromPhpError($error); } return $result; } @@ -35,10 +46,21 @@ function lzf_compress(string $data): string */ function lzf_decompress(string $data): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \lzf_decompress($data); + restore_error_handler(); + if ($result === false) { - throw LzfException::createFromPhpError(); + throw LzfException::createFromPhpError($error); } return $result; } diff --git a/generated/mailparse.php b/generated/mailparse.php index 1bae182a..3d133c26 100644 --- a/generated/mailparse.php +++ b/generated/mailparse.php @@ -28,14 +28,25 @@ */ function mailparse_msg_extract_part_file($mimemail, $filename, callable $callbackfunc = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callbackfunc !== null) { $result = \mailparse_msg_extract_part_file($mimemail, $filename, $callbackfunc); } else { $result = \mailparse_msg_extract_part_file($mimemail, $filename); } + restore_error_handler(); + if ($result === false) { - throw MailparseException::createFromPhpError(); + throw MailparseException::createFromPhpError($error); } return $result; } @@ -52,10 +63,21 @@ function mailparse_msg_extract_part_file($mimemail, $filename, callable $callbac */ function mailparse_msg_free($mimemail): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mailparse_msg_free($mimemail); + restore_error_handler(); + if ($result === false) { - throw MailparseException::createFromPhpError(); + throw MailparseException::createFromPhpError($error); } } @@ -75,10 +97,21 @@ function mailparse_msg_free($mimemail): void */ function mailparse_msg_parse_file(string $filename) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mailparse_msg_parse_file($filename); + restore_error_handler(); + if ($result === false) { - throw MailparseException::createFromPhpError(); + throw MailparseException::createFromPhpError($error); } return $result; } @@ -98,10 +131,21 @@ function mailparse_msg_parse_file(string $filename) */ function mailparse_msg_parse($mimemail, string $data): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mailparse_msg_parse($mimemail, $data); + restore_error_handler(); + if ($result === false) { - throw MailparseException::createFromPhpError(); + throw MailparseException::createFromPhpError($error); } } @@ -119,9 +163,20 @@ function mailparse_msg_parse($mimemail, string $data): void */ function mailparse_stream_encode($sourcefp, $destfp, string $encoding): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mailparse_stream_encode($sourcefp, $destfp, $encoding); + restore_error_handler(); + if ($result === false) { - throw MailparseException::createFromPhpError(); + throw MailparseException::createFromPhpError($error); } } diff --git a/generated/mbstring.php b/generated/mbstring.php index 49622015..5f27c11a 100644 --- a/generated/mbstring.php +++ b/generated/mbstring.php @@ -21,14 +21,25 @@ */ function mb_chr(int $codepoint, string $encoding = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_chr($codepoint, $encoding); } else { $result = \mb_chr($codepoint); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -60,14 +71,25 @@ function mb_chr(int $codepoint, string $encoding = null): string */ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($from_encoding !== null) { $result = \mb_convert_encoding($string, $to_encoding, $from_encoding); } else { $result = \mb_convert_encoding($string, $to_encoding); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -104,14 +126,25 @@ function mb_convert_encoding($string, string $to_encoding, $from_encoding = null */ function mb_detect_order($encoding = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_detect_order($encoding); } else { $result = \mb_detect_order(); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -127,10 +160,21 @@ function mb_detect_order($encoding = null) */ function mb_encoding_aliases(string $encoding): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_encoding_aliases($encoding); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -172,14 +216,25 @@ function mb_encoding_aliases(string $encoding): array */ function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \mb_ereg_replace_callback($pattern, $callback, $string, $options); } else { $result = \mb_ereg_replace_callback($pattern, $callback, $string); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -202,14 +257,25 @@ function mb_ereg_replace_callback(string $pattern, callable $callback, string $s */ function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \mb_ereg_replace($pattern, $replacement, $string, $options); } else { $result = \mb_ereg_replace($pattern, $replacement, $string); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -224,10 +290,21 @@ function mb_ereg_replace(string $pattern, string $replacement, string $string, s */ function mb_ereg_search_getregs(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_ereg_search_getregs(); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -249,7 +326,16 @@ function mb_ereg_search_getregs(): array */ function mb_ereg_search_init(string $string, string $pattern = null, string $options = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \mb_ereg_search_init($string, $pattern, $options); } elseif ($pattern !== null) { @@ -257,8 +343,10 @@ function mb_ereg_search_init(string $string, string $pattern = null, string $opt } else { $result = \mb_ereg_search_init($string); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } } @@ -274,7 +362,16 @@ function mb_ereg_search_init(string $string, string $pattern = null, string $opt */ function mb_ereg_search_regs(string $pattern = null, string $options = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \mb_ereg_search_regs($pattern, $options); } elseif ($pattern !== null) { @@ -282,8 +379,10 @@ function mb_ereg_search_regs(string $pattern = null, string $options = null): ar } else { $result = \mb_ereg_search_regs(); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -298,10 +397,21 @@ function mb_ereg_search_regs(string $pattern = null, string $options = null): ar */ function mb_ereg_search_setpos(int $offset): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_ereg_search_setpos($offset); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } } @@ -321,14 +431,25 @@ function mb_ereg_search_setpos(int $offset): void */ function mb_eregi_replace(string $pattern, string $replacement, string $string, string $options = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \mb_eregi_replace($pattern, $replacement, $string, $options); } else { $result = \mb_eregi_replace($pattern, $replacement, $string); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -363,10 +484,21 @@ function mb_eregi_replace(string $pattern, string $replacement, string $string, */ function mb_get_info(string $type = "all") { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_get_info($type); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -392,14 +524,25 @@ function mb_get_info(string $type = "all") */ function mb_http_output(string $encoding = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_http_output($encoding); } else { $result = \mb_http_output(); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -423,14 +566,25 @@ function mb_http_output(string $encoding = null) */ function mb_internal_encoding(string $encoding = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_internal_encoding($encoding); } else { $result = \mb_internal_encoding(); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -451,14 +605,25 @@ function mb_internal_encoding(string $encoding = null) */ function mb_ord(string $string, string $encoding = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_ord($string, $encoding); } else { $result = \mb_ord($string); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -479,10 +644,21 @@ function mb_ord(string $string, string $encoding = null): int */ function mb_parse_str(string $string, ?array &$result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_parse_str($string, $result); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } } @@ -499,14 +675,25 @@ function mb_parse_str(string $string, ?array &$result): void */ function mb_regex_encoding(string $encoding = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== null) { $result = \mb_regex_encoding($encoding); } else { $result = \mb_regex_encoding(); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } @@ -571,14 +758,25 @@ function mb_regex_encoding(string $encoding = null) */ function mb_send_mail(string $to, string $subject, string $message, $additional_headers = [], string $additional_params = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($additional_params !== null) { $result = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_params); } else { $result = \mb_send_mail($to, $subject, $message, $additional_headers); } + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } } @@ -595,10 +793,21 @@ function mb_send_mail(string $to, string $subject, string $message, $additional_ */ function mb_split(string $pattern, string $string, int $limit = -1): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mb_split($pattern, $string, $limit); + restore_error_handler(); + if ($result === false) { - throw MbstringException::createFromPhpError(); + throw MbstringException::createFromPhpError($error); } return $result; } diff --git a/generated/misc.php b/generated/misc.php index 31ca6158..d257d911 100644 --- a/generated/misc.php +++ b/generated/misc.php @@ -30,10 +30,21 @@ */ function define(string $constant_name, $value, bool $case_insensitive = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \define($constant_name, $value, $case_insensitive); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -60,10 +71,21 @@ function define(string $constant_name, $value, bool $case_insensitive = false): */ function highlight_file(string $filename, bool $return = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \highlight_file($filename, $return); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -83,10 +105,21 @@ function highlight_file(string $filename, bool $return = false) */ function highlight_string(string $string, bool $return = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \highlight_string($string, $return); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -107,10 +140,21 @@ function highlight_string(string $string, bool $return = false) */ function hrtime(bool $as_number = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \hrtime($as_number); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -272,14 +316,25 @@ function hrtime(bool $as_number = false) */ function pack(string $format, ...$values): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($values !== []) { $result = \pack($format, ...$values); } else { $result = \pack($format); } + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -300,10 +355,21 @@ function pack(string $format, ...$values): string */ function sapi_windows_cp_conv($in_codepage, $out_codepage, string $subject): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sapi_windows_cp_conv($in_codepage, $out_codepage, $subject); + restore_error_handler(); + if ($result === null) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -318,10 +384,21 @@ function sapi_windows_cp_conv($in_codepage, $out_codepage, string $subject): str */ function sapi_windows_cp_set(int $codepage): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sapi_windows_cp_set($codepage); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -339,10 +416,21 @@ function sapi_windows_cp_set(int $codepage): void */ function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sapi_windows_generate_ctrl_event($event, $pid); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -380,10 +468,21 @@ function sapi_windows_generate_ctrl_event(int $event, int $pid = 0): void */ function sapi_windows_set_ctrl_handler($handler, bool $add = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sapi_windows_set_ctrl_handler($handler, $add); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -406,14 +505,25 @@ function sapi_windows_set_ctrl_handler($handler, bool $add = true): void */ function sapi_windows_vt100_support($stream, bool $enable = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($enable !== null) { $result = \sapi_windows_vt100_support($stream, $enable); } else { $result = \sapi_windows_vt100_support($stream); } + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -435,10 +545,21 @@ function sapi_windows_vt100_support($stream, bool $enable = null): void */ function sleep(int $seconds): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sleep($seconds); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -473,10 +594,21 @@ function sleep(int $seconds): int */ function time_nanosleep(int $seconds, int $nanoseconds) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \time_nanosleep($seconds, $nanoseconds); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -492,10 +624,21 @@ function time_nanosleep(int $seconds, int $nanoseconds) */ function time_sleep_until(float $timestamp): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \time_sleep_until($timestamp); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } } @@ -535,10 +678,21 @@ function time_sleep_until(float $timestamp): void */ function unpack(string $format, string $string, int $offset = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \unpack($format, $string, $offset); + restore_error_handler(); + if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } diff --git a/generated/mysql.php b/generated/mysql.php index 475c609c..521c3c78 100644 --- a/generated/mysql.php +++ b/generated/mysql.php @@ -28,10 +28,21 @@ */ function mysql_close($link_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_close($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -75,7 +86,16 @@ function mysql_close($link_identifier = null): void */ function mysql_connect(string $server = null, string $username = null, string $password = null, bool $new_link = false, int $client_flags = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($client_flags !== 0) { $result = \mysql_connect($server, $username, $password, $new_link, $client_flags); } elseif ($new_link !== false) { @@ -89,8 +109,10 @@ function mysql_connect(string $server = null, string $username = null, string $p } else { $result = \mysql_connect(); } + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -113,10 +135,21 @@ function mysql_connect(string $server = null, string $username = null, string $p */ function mysql_create_db(string $database_name, $link_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_create_db($database_name, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -144,10 +177,21 @@ function mysql_create_db(string $database_name, $link_identifier = null): void */ function mysql_data_seek($result, int $row_number): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_data_seek($result, $row_number); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -167,10 +211,21 @@ function mysql_data_seek($result, int $row_number): void */ function mysql_db_name($result, int $row, $field = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_db_name($result, $row, $field); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -198,10 +253,21 @@ function mysql_db_name($result, int $row, $field = null): string */ function mysql_db_query(string $database, string $query, $link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_db_query($database, $query, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -226,10 +292,21 @@ function mysql_db_query(string $database, string $query, $link_identifier = null */ function mysql_drop_db(string $database_name, $link_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_drop_db($database_name, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -255,10 +332,21 @@ function mysql_drop_db(string $database_name, $link_identifier = null): void */ function mysql_fetch_lengths($result): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_fetch_lengths($result); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -291,10 +379,21 @@ function mysql_fetch_lengths($result): array */ function mysql_field_flags($result, int $field_offset): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_field_flags($result, $field_offset); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -317,10 +416,21 @@ function mysql_field_flags($result, int $field_offset): string */ function mysql_field_len($result, int $field_offset): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_field_len($result, $field_offset); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -343,10 +453,21 @@ function mysql_field_len($result, int $field_offset): int */ function mysql_field_name($result, int $field_offset): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_field_name($result, $field_offset); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -370,10 +491,21 @@ function mysql_field_name($result, int $field_offset): string */ function mysql_field_seek($result, int $field_offset): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_field_seek($result, $field_offset); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -395,10 +527,21 @@ function mysql_field_seek($result, int $field_offset): void */ function mysql_free_result($result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_free_result($result); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -420,10 +563,21 @@ function mysql_free_result($result): void */ function mysql_get_host_info($link_identifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_get_host_info($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -444,10 +598,21 @@ function mysql_get_host_info($link_identifier = null): string */ function mysql_get_proto_info($link_identifier = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_get_proto_info($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -468,10 +633,21 @@ function mysql_get_proto_info($link_identifier = null): int */ function mysql_get_server_info($link_identifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_get_server_info($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -494,10 +670,21 @@ function mysql_get_server_info($link_identifier = null): string */ function mysql_info($link_identifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_info($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -521,10 +708,21 @@ function mysql_info($link_identifier = null): string */ function mysql_list_dbs($link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_list_dbs($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -556,10 +754,21 @@ function mysql_list_dbs($link_identifier = null) */ function mysql_list_fields(string $database_name, string $table_name, $link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_list_fields($database_name, $table_name, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -580,10 +789,21 @@ function mysql_list_fields(string $database_name, string $table_name, $link_iden */ function mysql_list_processes($link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_list_processes($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -613,10 +833,21 @@ function mysql_list_processes($link_identifier = null) */ function mysql_list_tables(string $database, $link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_list_tables($database, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -635,10 +866,21 @@ function mysql_list_tables(string $database, $link_identifier = null) */ function mysql_num_fields($result): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_num_fields($result); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -659,10 +901,21 @@ function mysql_num_fields($result): int */ function mysql_num_rows($result): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_num_rows($result); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -709,10 +962,21 @@ function mysql_num_rows($result): int */ function mysql_query(string $query, $link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_query($query, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -746,10 +1010,21 @@ function mysql_query(string $query, $link_identifier = null) */ function mysql_real_escape_string(string $unescaped_string, $link_identifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_real_escape_string($unescaped_string, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -783,10 +1058,21 @@ function mysql_real_escape_string(string $unescaped_string, $link_identifier = n */ function mysql_result($result, int $row, $field = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_result($result, $row, $field); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -809,10 +1095,21 @@ function mysql_result($result, int $row, $field = 0): string */ function mysql_select_db(string $database_name, $link_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_select_db($database_name, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -832,10 +1129,21 @@ function mysql_select_db(string $database_name, $link_identifier = null): void */ function mysql_set_charset(string $charset, $link_identifier = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_set_charset($charset, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } } @@ -860,10 +1168,21 @@ function mysql_set_charset(string $charset, $link_identifier = null): void */ function mysql_tablename($result, int $i): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_tablename($result, $i); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -886,10 +1205,21 @@ function mysql_tablename($result, int $i): string */ function mysql_thread_id($link_identifier = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_thread_id($link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } @@ -929,10 +1259,21 @@ function mysql_thread_id($link_identifier = null): int */ function mysql_unbuffered_query(string $query, $link_identifier = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \mysql_unbuffered_query($query, $link_identifier); + restore_error_handler(); + if ($result === false) { - throw MysqlException::createFromPhpError(); + throw MysqlException::createFromPhpError($error); } return $result; } diff --git a/generated/network.php b/generated/network.php index 21186d1f..87f7d9e9 100644 --- a/generated/network.php +++ b/generated/network.php @@ -13,10 +13,21 @@ */ function closelog(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \closelog(); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } } @@ -248,10 +259,21 @@ function closelog(): void */ function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authoritative_name_servers = null, ?array &$additional_records = null, bool $raw = false): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \dns_get_record($hostname, $type, $authoritative_name_servers, $additional_records, $raw); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -308,14 +330,25 @@ function dns_get_record(string $hostname, int $type = DNS_ANY, ?array &$authorit */ function fsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timeout !== null) { $result = \fsockopen($hostname, $port, $error_code, $error_message, $timeout); } else { $result = \fsockopen($hostname, $port, $error_code, $error_message); } + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -332,10 +365,21 @@ function fsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ? */ function gethostname(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gethostname(); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -353,10 +397,21 @@ function gethostname(): string */ function getprotobyname(string $protocol): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getprotobyname($protocol); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -374,10 +429,21 @@ function getprotobyname(string $protocol): int */ function getprotobynumber(int $protocol): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getprotobynumber($protocol); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -397,10 +463,21 @@ function getprotobynumber(int $protocol): string */ function getservbyport(int $port, string $protocol): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \getservbyport($port, $protocol); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -420,10 +497,21 @@ function getservbyport(int $port, string $protocol): string */ function header_register_callback(callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \header_register_callback($callback); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } } @@ -438,10 +526,21 @@ function header_register_callback(callable $callback): void */ function inet_ntop(string $ip): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inet_ntop($ip); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -459,10 +558,21 @@ function inet_ntop(string $ip): string */ function long2ip(int $ip): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \long2ip($ip); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -564,10 +674,21 @@ function long2ip(int $ip): string */ function net_get_interfaces(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \net_get_interfaces(); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -707,10 +828,21 @@ function net_get_interfaces(): array */ function openlog(string $prefix, int $flags, int $facility): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openlog($prefix, $flags, $facility); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } } @@ -735,14 +867,25 @@ function openlog(string $prefix, int $flags, int $facility): void */ function pfsockopen(string $hostname, int $port = -1, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($timeout !== null) { $result = \pfsockopen($hostname, $port, $error_code, $error_message, $timeout); } else { $result = \pfsockopen($hostname, $port, $error_code, $error_message); } + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } return $result; } @@ -812,9 +955,20 @@ function pfsockopen(string $hostname, int $port = -1, ?int &$error_code = null, */ function syslog(int $priority, string $message): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \syslog($priority, $message); + restore_error_handler(); + if ($result === false) { - throw NetworkException::createFromPhpError(); + throw NetworkException::createFromPhpError($error); } } diff --git a/generated/oci8.php b/generated/oci8.php index 4a7e3880..098c04b5 100644 --- a/generated/oci8.php +++ b/generated/oci8.php @@ -103,10 +103,21 @@ */ function oci_bind_array_by_name($statement, string $param, array &$var, int $max_array_length, int $max_item_length = -1, int $type = SQLT_AFC): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_bind_array_by_name($statement, $param, $var, $max_array_length, $max_item_length, $type); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -309,10 +320,21 @@ function oci_bind_array_by_name($statement, string $param, array &$var, int $max */ function oci_bind_by_name($statement, string $param, &$var, int $max_length = -1, int $type = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_bind_by_name($statement, $param, $var, $max_length, $type); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -327,10 +349,21 @@ function oci_bind_by_name($statement, string $param, &$var, int $max_length = -1 */ function oci_cancel($statement): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_cancel($statement); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -359,10 +392,21 @@ function oci_cancel($statement): void */ function oci_commit($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_commit($connection); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -468,7 +512,16 @@ function oci_commit($connection): void */ function oci_connect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($session_mode !== OCI_DEFAULT) { $result = \oci_connect($username, $password, $connection_string, $encoding, $session_mode); } elseif ($encoding !== "") { @@ -478,8 +531,10 @@ function oci_connect(string $username, string $password, string $connection_stri } else { $result = \oci_connect($username, $password); } + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -513,10 +568,21 @@ function oci_connect(string $username, string $password, string $connection_stri */ function oci_define_by_name($statement, string $column, &$var, int $type = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_define_by_name($statement, $column, $var, $type); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -600,10 +666,21 @@ function oci_define_by_name($statement, string $column, &$var, int $type = 0): v */ function oci_execute($statement, int $mode = OCI_COMMIT_ON_SUCCESS): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_execute($statement, $mode); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -619,10 +696,21 @@ function oci_execute($statement, int $mode = OCI_COMMIT_ON_SUCCESS): void */ function oci_field_name($statement, $column): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_name($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -643,10 +731,21 @@ function oci_field_name($statement, $column): string */ function oci_field_precision($statement, $column): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_precision($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -667,10 +766,21 @@ function oci_field_precision($statement, $column): int */ function oci_field_scale($statement, $column): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_scale($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -687,10 +797,21 @@ function oci_field_scale($statement, $column): int */ function oci_field_size($statement, $column): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_size($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -709,10 +830,21 @@ function oci_field_size($statement, $column): int */ function oci_field_type_raw($statement, $column): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_type_raw($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -729,10 +861,21 @@ function oci_field_type_raw($statement, $column): int */ function oci_field_type($statement, $column) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_field_type($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -747,10 +890,21 @@ function oci_field_type($statement, $column) */ function oci_free_descriptor(\OCILob $lob): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_free_descriptor($lob); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -766,10 +920,21 @@ function oci_free_descriptor(\OCILob $lob): void */ function oci_free_statement($statement): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_free_statement($statement); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -788,14 +953,25 @@ function oci_free_statement($statement): void */ function oci_new_collection($connection, string $type_name, string $schema = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($schema !== null) { $result = \oci_new_collection($connection, $type_name, $schema); } else { $result = \oci_new_collection($connection, $type_name); } + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -891,7 +1067,16 @@ function oci_new_collection($connection, string $type_name, string $schema = nul */ function oci_new_connect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($session_mode !== OCI_DEFAULT) { $result = \oci_new_connect($username, $password, $connection_string, $encoding, $session_mode); } elseif ($encoding !== "") { @@ -901,8 +1086,10 @@ function oci_new_connect(string $username, string $password, string $connection_ } else { $result = \oci_new_connect($username, $password); } + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -919,10 +1106,21 @@ function oci_new_connect(string $username, string $password, string $connection_ */ function oci_new_cursor($connection) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_new_cursor($connection); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -942,10 +1140,21 @@ function oci_new_cursor($connection) */ function oci_new_descriptor($connection, int $type = OCI_DTYPE_LOB) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_new_descriptor($connection, $type); + restore_error_handler(); + if ($result === null) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -961,10 +1170,21 @@ function oci_new_descriptor($connection, int $type = OCI_DTYPE_LOB) */ function oci_num_rows($statement): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_num_rows($statement); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -994,10 +1214,21 @@ function oci_num_rows($statement): int */ function oci_parse($connection, string $sql) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_parse($connection, $sql); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -1094,7 +1325,16 @@ function oci_parse($connection, string $sql) */ function oci_pconnect(string $username, string $password, string $connection_string = null, string $encoding = "", int $session_mode = OCI_DEFAULT) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($session_mode !== OCI_DEFAULT) { $result = \oci_pconnect($username, $password, $connection_string, $encoding, $session_mode); } elseif ($encoding !== "") { @@ -1104,8 +1344,10 @@ function oci_pconnect(string $username, string $password, string $connection_str } else { $result = \oci_pconnect($username, $password); } + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -1141,10 +1383,21 @@ function oci_pconnect(string $username, string $password, string $connection_str */ function oci_register_taf_callback($connection, callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_register_taf_callback($connection, $callback); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1169,10 +1422,21 @@ function oci_register_taf_callback($connection, callable $callback): void */ function oci_result($statement, $column): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_result($statement, $column); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -1203,10 +1467,21 @@ function oci_result($statement, $column): string */ function oci_rollback($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_rollback($connection); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1221,10 +1496,21 @@ function oci_rollback($connection): void */ function oci_server_version($connection): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_server_version($connection); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -1253,10 +1539,21 @@ function oci_server_version($connection): string */ function oci_set_action($connection, string $action): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_action($connection, $action); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1295,10 +1592,21 @@ function oci_set_action($connection, string $action): void */ function oci_set_call_timeout($connection, int $timeout): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_call_timeout($connection, $timeout); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1330,10 +1638,21 @@ function oci_set_call_timeout($connection, int $timeout): void */ function oci_set_client_identifier($connection, string $client_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_client_identifier($connection, $client_id); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1359,10 +1678,21 @@ function oci_set_client_identifier($connection, string $client_id): void */ function oci_set_client_info($connection, string $client_info): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_client_info($connection, $client_info); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1389,10 +1719,21 @@ function oci_set_client_info($connection, string $client_info): void */ function oci_set_db_operation($connection, string $action): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_db_operation($connection, $action); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1423,10 +1764,21 @@ function oci_set_db_operation($connection, string $action): void */ function oci_set_edition(string $edition): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_edition($edition); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1454,10 +1806,21 @@ function oci_set_edition(string $edition): void */ function oci_set_module_name($connection, string $name): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_module_name($connection, $name); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1490,10 +1853,21 @@ function oci_set_module_name($connection, string $name): void */ function oci_set_prefetch_lob($statement, int $prefetch_lob_size): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_prefetch_lob($statement, $prefetch_lob_size); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1554,10 +1928,21 @@ function oci_set_prefetch_lob($statement, int $prefetch_lob_size): void */ function oci_set_prefetch($statement, int $rows): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_set_prefetch($statement, $rows); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } @@ -1626,10 +2011,21 @@ function oci_set_prefetch($statement, int $rows): void */ function oci_statement_type($statement): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_statement_type($statement); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } return $result; } @@ -1647,9 +2043,20 @@ function oci_statement_type($statement): string */ function oci_unregister_taf_callback($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \oci_unregister_taf_callback($connection); + restore_error_handler(); + if ($result === false) { - throw Oci8Exception::createFromPhpError(); + throw Oci8Exception::createFromPhpError($error); } } diff --git a/generated/opcache.php b/generated/opcache.php index dcac8549..6e3b6fe1 100644 --- a/generated/opcache.php +++ b/generated/opcache.php @@ -15,10 +15,21 @@ */ function opcache_compile_file(string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \opcache_compile_file($filename); + restore_error_handler(); + if ($result === false) { - throw OpcacheException::createFromPhpError(); + throw OpcacheException::createFromPhpError($error); } } @@ -34,10 +45,21 @@ function opcache_compile_file(string $filename): void */ function opcache_get_status(bool $include_scripts = true): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \opcache_get_status($include_scripts); + restore_error_handler(); + if ($result === false) { - throw OpcacheException::createFromPhpError(); + throw OpcacheException::createFromPhpError($error); } return $result; } diff --git a/generated/openssl.php b/generated/openssl.php index 1c5b875d..6b5753fb 100644 --- a/generated/openssl.php +++ b/generated/openssl.php @@ -14,10 +14,21 @@ */ function openssl_cipher_iv_length(string $cipher_algo): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_cipher_iv_length($cipher_algo); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -37,7 +48,16 @@ function openssl_cipher_iv_length(string $cipher_algo): int */ function openssl_cms_decrypt(string $input_filename, string $output_filename, $certificate, $private_key = null, int $encoding = OPENSSL_ENCODING_SMIME): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== OPENSSL_ENCODING_SMIME) { $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate, $private_key, $encoding); } elseif ($private_key !== null) { @@ -45,8 +65,10 @@ function openssl_cms_decrypt(string $input_filename, string $output_filename, $c } else { $result = \openssl_cms_decrypt($input_filename, $output_filename, $certificate); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -68,10 +90,21 @@ function openssl_cms_decrypt(string $input_filename, string $output_filename, $c */ function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_cms_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $encoding, $cipher_algo); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -86,10 +119,21 @@ function openssl_cms_encrypt(string $input_filename, string $output_filename, $c */ function openssl_cms_read(string $input_filename, array &$certificates): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_cms_read($input_filename, $certificates); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -113,14 +157,25 @@ function openssl_cms_read(string $input_filename, array &$certificates): void */ function openssl_cms_sign(string $input_filename, string $output_filename, $certificate, $private_key, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, $untrusted_certificates_filename = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($untrusted_certificates_filename !== null) { $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding, $untrusted_certificates_filename); } else { $result = \openssl_cms_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $encoding); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -143,7 +198,16 @@ function openssl_cms_sign(string $input_filename, string $output_filename, $cert */ function openssl_cms_verify(string $input_filename, int $flags = 0, $certificates = null, array $ca_info = [], $untrusted_certificates_filename = null, $content = null, $pk7 = null, $sigfile = null, int $encoding = OPENSSL_ENCODING_SMIME): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($encoding !== OPENSSL_ENCODING_SMIME) { $result = \openssl_cms_verify($input_filename, $flags, $certificates, $ca_info, $untrusted_certificates_filename, $content, $pk7, $sigfile, $encoding); } elseif ($sigfile !== null) { @@ -161,8 +225,10 @@ function openssl_cms_verify(string $input_filename, int $flags = 0, $certificate } else { $result = \openssl_cms_verify($input_filename, $flags); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -184,10 +250,21 @@ function openssl_cms_verify(string $input_filename, int $flags = 0, $certificate */ function openssl_csr_export_to_file($csr, string $output_filename, bool $no_text = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_csr_export_to_file($csr, $output_filename, $no_text); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -210,10 +287,21 @@ function openssl_csr_export_to_file($csr, string $output_filename, bool $no_text */ function openssl_csr_export($csr, ?string &$output, bool $no_text = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_csr_export($csr, $output, $no_text); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -230,10 +318,21 @@ function openssl_csr_export($csr, ?string &$output, bool $no_text = true): void */ function openssl_csr_get_public_key($csr, bool $short_names = true) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_csr_get_public_key($csr, $short_names); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -255,10 +354,21 @@ function openssl_csr_get_public_key($csr, bool $short_names = true) */ function openssl_csr_get_subject($csr, bool $short_names = true): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_csr_get_subject($csr, $short_names); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -376,7 +486,16 @@ function openssl_csr_get_subject($csr, bool $short_names = true): array */ function openssl_csr_new(array $distinguished_names, &$private_key, array $options = null, array $extra_attributes = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($extra_attributes !== null) { $result = \openssl_csr_new($distinguished_names, $private_key, $options, $extra_attributes); } elseif ($options !== null) { @@ -384,8 +503,10 @@ function openssl_csr_new(array $distinguished_names, &$private_key, array $optio } else { $result = \openssl_csr_new($distinguished_names, $private_key); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -416,7 +537,16 @@ function openssl_csr_new(array $distinguished_names, &$private_key, array $optio */ function openssl_csr_sign($csr, $ca_certificate, $private_key, int $days, array $options = null, int $serial = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($serial !== 0) { $result = \openssl_csr_sign($csr, $ca_certificate, $private_key, $days, $options, $serial); } elseif ($options !== null) { @@ -424,8 +554,10 @@ function openssl_csr_sign($csr, $ca_certificate, $private_key, int $days, array } else { $result = \openssl_csr_sign($csr, $ca_certificate, $private_key, $days); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -450,7 +582,16 @@ function openssl_csr_sign($csr, $ca_certificate, $private_key, int $days, array */ function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", string $tag = null, string $aad = ""): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($aad !== "") { $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag, $aad); } elseif ($tag !== null) { @@ -458,8 +599,10 @@ function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, } else { $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -478,10 +621,21 @@ function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, */ function openssl_dh_compute_key(string $public_key, $private_key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_dh_compute_key($public_key, $private_key); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -501,10 +655,21 @@ function openssl_dh_compute_key(string $public_key, $private_key): string */ function openssl_digest(string $data, string $digest_algo, bool $binary = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_digest($data, $digest_algo, $binary); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -563,10 +728,21 @@ function openssl_digest(string $data, string $digest_algo, bool $binary = false) */ function openssl_get_curve_names(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_get_curve_names(); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -600,14 +776,25 @@ function openssl_get_curve_names(): array */ function openssl_open(string $data, ?string &$output, string $encrypted_key, $private_key, string $cipher_algo, string $iv = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($iv !== null) { $result = \openssl_open($data, $output, $encrypted_key, $private_key, $cipher_algo, $iv); } else { $result = \openssl_open($data, $output, $encrypted_key, $private_key, $cipher_algo); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -628,10 +815,21 @@ function openssl_open(string $data, ?string &$output, string $encrypted_key, $pr */ function openssl_pbkdf2(string $password, string $salt, int $key_length, int $iterations, string $digest_algo = "sha1"): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pbkdf2($password, $salt, $key_length, $iterations, $digest_algo); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -673,10 +871,21 @@ function openssl_pbkdf2(string $password, string $salt, int $key_length, int $it */ function openssl_pkcs12_export_to_file($certificate, string $output_filename, $private_key, string $passphrase, array $options = []): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkcs12_export_to_file($certificate, $output_filename, $private_key, $passphrase, $options); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -717,10 +926,21 @@ function openssl_pkcs12_export_to_file($certificate, string $output_filename, $p */ function openssl_pkcs12_export($certificate, ?string &$output, $private_key, string $passphrase, array $options = []): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkcs12_export($certificate, $output, $private_key, $passphrase, $options); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -738,10 +958,21 @@ function openssl_pkcs12_export($certificate, ?string &$output, $private_key, str */ function openssl_pkcs12_read(string $pkcs12, ?array &$certificates, string $passphrase): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkcs12_read($pkcs12, $certificates, $passphrase); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -762,14 +993,25 @@ function openssl_pkcs12_read(string $pkcs12, ?array &$certificates, string $pass */ function openssl_pkcs7_decrypt(string $input_filename, string $output_filename, $certificate, $private_key = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($private_key !== null) { $result = \openssl_pkcs7_decrypt($input_filename, $output_filename, $certificate, $private_key); } else { $result = \openssl_pkcs7_decrypt($input_filename, $output_filename, $certificate); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -798,10 +1040,21 @@ function openssl_pkcs7_decrypt(string $input_filename, string $output_filename, */ function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, array $headers, int $flags = 0, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkcs7_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $cipher_algo); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -816,10 +1069,21 @@ function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, */ function openssl_pkcs7_read(string $data, ?array &$certificates): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkcs7_read($data, $certificates); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -850,14 +1114,25 @@ function openssl_pkcs7_read(string $data, ?array &$certificates): void */ function openssl_pkcs7_sign(string $input_filename, string $output_filename, $certificate, $private_key, array $headers, int $flags = PKCS7_DETACHED, string $untrusted_certificates_filename = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($untrusted_certificates_filename !== null) { $result = \openssl_pkcs7_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags, $untrusted_certificates_filename); } else { $result = \openssl_pkcs7_sign($input_filename, $output_filename, $certificate, $private_key, $headers, $flags); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -877,10 +1152,21 @@ function openssl_pkcs7_sign(string $input_filename, string $output_filename, $ce */ function openssl_pkey_derive($public_key, $private_key, int $key_length = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkey_derive($public_key, $private_key, $key_length); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -904,7 +1190,16 @@ function openssl_pkey_derive($public_key, $private_key, int $key_length = 0): st */ function openssl_pkey_export_to_file($key, string $output_filename, ?string $passphrase = null, array $options = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \openssl_pkey_export_to_file($key, $output_filename, $passphrase, $options); } elseif ($passphrase !== null) { @@ -912,8 +1207,10 @@ function openssl_pkey_export_to_file($key, string $output_filename, ?string $pas } else { $result = \openssl_pkey_export_to_file($key, $output_filename); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -935,7 +1232,16 @@ function openssl_pkey_export_to_file($key, string $output_filename, ?string $pas */ function openssl_pkey_export($key, ?string &$output, ?string $passphrase = null, array $options = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \openssl_pkey_export($key, $output, $passphrase, $options); } elseif ($passphrase !== null) { @@ -943,8 +1249,10 @@ function openssl_pkey_export($key, ?string &$output, ?string $passphrase = null, } else { $result = \openssl_pkey_export($key, $output); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -970,14 +1278,25 @@ function openssl_pkey_export($key, ?string &$output, ?string $passphrase = null, */ function openssl_pkey_get_private(string $private_key, string $passphrase = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($passphrase !== null) { $result = \openssl_pkey_get_private($private_key, $passphrase); } else { $result = \openssl_pkey_get_private($private_key); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1004,10 +1323,21 @@ function openssl_pkey_get_private(string $private_key, string $passphrase = null */ function openssl_pkey_get_public($public_key) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_pkey_get_public($public_key); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1028,14 +1358,25 @@ function openssl_pkey_get_public($public_key) */ function openssl_pkey_new(array $options = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \openssl_pkey_new($options); } else { $result = \openssl_pkey_new(); } + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1063,10 +1404,21 @@ function openssl_pkey_new(array $options = null) */ function openssl_private_decrypt(string $data, ?string &$decrypted_data, $private_key, int $padding = OPENSSL_PKCS1_PADDING): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_private_decrypt($data, $decrypted_data, $private_key, $padding); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1091,10 +1443,21 @@ function openssl_private_decrypt(string $data, ?string &$decrypted_data, $privat */ function openssl_private_encrypt(string $data, ?string &$encrypted_data, $private_key, int $padding = OPENSSL_PKCS1_PADDING): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_private_encrypt($data, $encrypted_data, $private_key, $padding); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1120,10 +1483,21 @@ function openssl_private_encrypt(string $data, ?string &$encrypted_data, $privat */ function openssl_public_decrypt(string $data, ?string &$decrypted_data, $public_key, int $padding = OPENSSL_PKCS1_PADDING): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_public_decrypt($data, $decrypted_data, $public_key, $padding); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1151,10 +1525,21 @@ function openssl_public_decrypt(string $data, ?string &$decrypted_data, $public_ */ function openssl_public_encrypt(string $data, ?string &$encrypted_data, $public_key, int $padding = OPENSSL_PKCS1_PADDING): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_public_encrypt($data, $encrypted_data, $public_key, $padding); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1178,10 +1563,21 @@ function openssl_public_encrypt(string $data, ?string &$encrypted_data, $public_ */ function openssl_random_pseudo_bytes(int $length, ?bool &$strong_result = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_random_pseudo_bytes($length, $strong_result); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1219,10 +1615,21 @@ function openssl_random_pseudo_bytes(int $length, ?bool &$strong_result = null): */ function openssl_seal(string $data, ?string &$sealed_data, ?array &$encrypted_keys, array $public_key, string $cipher_algo, ?string &$iv = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_seal($data, $sealed_data, $encrypted_keys, $public_key, $cipher_algo, $iv); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1249,10 +1656,21 @@ function openssl_seal(string $data, ?string &$sealed_data, ?array &$encrypted_ke */ function openssl_sign(string $data, ?string &$signature, $private_key, $algorithm = OPENSSL_ALGO_SHA1): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_sign($data, $signature, $private_key, $algorithm); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1267,10 +1685,21 @@ function openssl_sign(string $data, ?string &$signature, $private_key, $algorith */ function openssl_spki_export_challenge(string $spki): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_spki_export_challenge($spki); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1286,10 +1715,21 @@ function openssl_spki_export_challenge(string $spki): ?string */ function openssl_spki_export(string $spki): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_spki_export($spki); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1311,10 +1751,21 @@ function openssl_spki_export(string $spki): ?string */ function openssl_spki_new($private_key, string $challenge, int $digest_algo = OPENSSL_ALGO_MD5): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_spki_new($private_key, $challenge, $digest_algo); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1329,10 +1780,21 @@ function openssl_spki_new($private_key, string $challenge, int $digest_algo = OP */ function openssl_spki_verify(string $spki): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_spki_verify($spki); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1360,10 +1822,21 @@ function openssl_spki_verify(string $spki): void */ function openssl_verify(string $data, string $signature, $public_key, $algorithm = OPENSSL_ALGO_SHA1): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_verify($data, $signature, $public_key, $algorithm); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1386,10 +1859,21 @@ function openssl_verify(string $data, string $signature, $public_key, $algorithm */ function openssl_x509_export_to_file($certificate, string $output_filename, bool $no_text = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_x509_export_to_file($certificate, $output_filename, $no_text); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1411,10 +1895,21 @@ function openssl_x509_export_to_file($certificate, string $output_filename, bool */ function openssl_x509_export($certificate, ?string &$output, bool $no_text = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_x509_export($certificate, $output, $no_text); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } } @@ -1434,10 +1929,21 @@ function openssl_x509_export($certificate, ?string &$output, bool $no_text = tru */ function openssl_x509_fingerprint($certificate, string $digest_algo = "sha1", bool $binary = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_x509_fingerprint($certificate, $digest_algo, $binary); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } @@ -1455,10 +1961,21 @@ function openssl_x509_fingerprint($certificate, string $digest_algo = "sha1", bo */ function openssl_x509_read($certificate) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \openssl_x509_read($certificate); + restore_error_handler(); + if ($result === false) { - throw OpensslException::createFromPhpError(); + throw OpensslException::createFromPhpError($error); } return $result; } diff --git a/generated/outcontrol.php b/generated/outcontrol.php index e52c4a08..56668ef8 100644 --- a/generated/outcontrol.php +++ b/generated/outcontrol.php @@ -19,10 +19,21 @@ */ function ob_clean(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ob_clean(); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -44,10 +55,21 @@ function ob_clean(): void */ function ob_end_clean(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ob_end_clean(); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -70,10 +92,21 @@ function ob_end_clean(): void */ function ob_end_flush(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ob_end_flush(); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -93,10 +126,21 @@ function ob_end_flush(): void */ function ob_flush(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ob_flush(); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -190,7 +234,16 @@ function ob_flush(): void */ function ob_start($callback = null, int $chunk_size = 0, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($flags !== PHP_OUTPUT_HANDLER_STDFLAGS) { $result = \ob_start($callback, $chunk_size, $flags); } elseif ($chunk_size !== 0) { @@ -200,8 +253,10 @@ function ob_start($callback = null, int $chunk_size = 0, int $flags = PHP_OUTPUT } else { $result = \ob_start(); } + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -225,10 +280,21 @@ function ob_start($callback = null, int $chunk_size = 0, int $flags = PHP_OUTPUT */ function output_add_rewrite_var(string $name, string $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \output_add_rewrite_var($name, $value); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } @@ -243,9 +309,20 @@ function output_add_rewrite_var(string $name, string $value): void */ function output_reset_rewrite_vars(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \output_reset_rewrite_vars(); + restore_error_handler(); + if ($result === false) { - throw OutcontrolException::createFromPhpError(); + throw OutcontrolException::createFromPhpError($error); } } diff --git a/generated/pcntl.php b/generated/pcntl.php index 66cc28d4..60c3b26e 100644 --- a/generated/pcntl.php +++ b/generated/pcntl.php @@ -20,7 +20,16 @@ */ function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($mode !== PRIO_PROCESS) { $result = \pcntl_getpriority($process_id, $mode); } elseif ($process_id !== null) { @@ -28,8 +37,10 @@ function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): in } else { $result = \pcntl_getpriority(); } + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } return $result; } @@ -53,7 +64,16 @@ function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): in */ function pcntl_setpriority(int $priority, int $process_id = null, int $mode = PRIO_PROCESS): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($mode !== PRIO_PROCESS) { $result = \pcntl_setpriority($priority, $process_id, $mode); } elseif ($process_id !== null) { @@ -61,8 +81,10 @@ function pcntl_setpriority(int $priority, int $process_id = null, int $mode = PR } else { $result = \pcntl_setpriority($priority); } + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } } @@ -77,10 +99,21 @@ function pcntl_setpriority(int $priority, int $process_id = null, int $mode = PR */ function pcntl_signal_dispatch(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pcntl_signal_dispatch(); + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } } @@ -132,10 +165,21 @@ function pcntl_signal_dispatch(): void */ function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pcntl_signal($signal, $handler, $restart_syscalls); + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } } @@ -162,10 +206,21 @@ function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): voi */ function pcntl_sigprocmask(int $mode, array $signals, ?array &$old_signals = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pcntl_sigprocmask($mode, $signals, $old_signals); + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } } @@ -189,10 +244,21 @@ function pcntl_sigprocmask(int $mode, array $signals, ?array &$old_signals = nul */ function pcntl_sigtimedwait(array $signals, ?array &$info = [], int $seconds = 0, int $nanoseconds = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pcntl_sigtimedwait($signals, $info, $seconds, $nanoseconds); + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } return $result; } @@ -244,10 +310,21 @@ function pcntl_sigtimedwait(array $signals, ?array &$info = [], int $seconds = 0 */ function pcntl_sigwaitinfo(array $signals, ?array &$info = []): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pcntl_sigwaitinfo($signals, $info); + restore_error_handler(); + if ($result === false) { - throw PcntlException::createFromPhpError(); + throw PcntlException::createFromPhpError($error); } return $result; } diff --git a/generated/pcre.php b/generated/pcre.php index 4ebb9839..f7793524 100644 --- a/generated/pcre.php +++ b/generated/pcre.php @@ -21,10 +21,21 @@ */ function preg_grep(string $pattern, array $array, int $flags = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \preg_grep($pattern, $array, $flags); + restore_error_handler(); + if ($result === false) { - throw PcreException::createFromPhpError(); + throw PcreException::createFromPhpError($error); } return $result; } @@ -375,10 +386,21 @@ function preg_grep(string $pattern, array $array, int $flags = 0): array */ function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): ?int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \preg_match_all($pattern, $subject, $matches, $flags, $offset); + restore_error_handler(); + if ($result === false) { - throw PcreException::createFromPhpError(); + throw PcreException::createFromPhpError($error); } return $result; } @@ -612,10 +634,21 @@ function preg_match_all(string $pattern, string $subject, ?array &$matches = nul */ function preg_match(string $pattern, string $subject, ?iterable &$matches = null, int $flags = 0, int $offset = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \preg_match($pattern, $subject, $matches, $flags, $offset); + restore_error_handler(); + if ($result === false) { - throw PcreException::createFromPhpError(); + throw PcreException::createFromPhpError($error); } return $result; } @@ -676,10 +709,21 @@ function preg_match(string $pattern, string $subject, ?iterable &$matches = null */ function preg_split(string $pattern, string $subject, ?int $limit = -1, int $flags = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \preg_split($pattern, $subject, $limit, $flags); + restore_error_handler(); + if ($result === false) { - throw PcreException::createFromPhpError(); + throw PcreException::createFromPhpError($error); } return $result; } diff --git a/generated/pgsql.php b/generated/pgsql.php index ee24da57..27bd67e4 100644 --- a/generated/pgsql.php +++ b/generated/pgsql.php @@ -16,10 +16,21 @@ */ function pg_cancel_query($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_cancel_query($connection); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -73,10 +84,21 @@ function pg_cancel_query($connection): void */ function pg_connect(string $connection_string, int $flags = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_connect($connection_string, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -92,10 +114,21 @@ function pg_connect(string $connection_string, int $flags = 0) */ function pg_connection_reset($connection): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_connection_reset($connection); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -123,10 +156,21 @@ function pg_connection_reset($connection): void */ function pg_convert($connection, string $table_name, array $values, int $flags = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_convert($connection, $table_name, $values, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -152,10 +196,21 @@ function pg_convert($connection, string $table_name, array $values, int $flags = */ function pg_copy_from($connection, string $table_name, array $rows, string $separator = "\t", string $null_as = "\\\\N"): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_copy_from($connection, $table_name, $rows, $separator, $null_as); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -177,10 +232,21 @@ function pg_copy_from($connection, string $table_name, array $rows, string $sepa */ function pg_copy_to($connection, string $table_name, string $separator = "\t", string $null_as = "\\\\N"): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_copy_to($connection, $table_name, $separator, $null_as); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -223,10 +289,21 @@ function pg_copy_to($connection, string $table_name, string $separator = "\t", s */ function pg_delete($connection, string $table_name, array $conditions, int $flags = PGSQL_DML_EXEC) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_delete($connection, $table_name, $conditions, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -249,14 +326,25 @@ function pg_delete($connection, string $table_name, array $conditions, int $flag */ function pg_end_copy($connection = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection !== null) { $result = \pg_end_copy($connection); } else { $result = \pg_end_copy(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -297,7 +385,16 @@ function pg_end_copy($connection = null): void */ function pg_execute($connection = null, string $stmtname = null, array $params = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($params !== null) { $result = \pg_execute($connection, $stmtname, $params); } elseif ($stmtname !== null) { @@ -307,8 +404,10 @@ function pg_execute($connection = null, string $stmtname = null, array $params = } else { $result = \pg_execute(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -330,10 +429,21 @@ function pg_execute($connection = null, string $stmtname = null, array $params = */ function pg_field_table($result, int $field, bool $oid_only = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_field_table($result, $field, $oid_only); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -352,10 +462,21 @@ function pg_field_table($result, int $field, bool $oid_only = false) */ function pg_flush($connection) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_flush($connection); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -376,10 +497,21 @@ function pg_flush($connection) */ function pg_free_result($result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_free_result($result); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -400,14 +532,25 @@ function pg_free_result($result): void */ function pg_host($connection = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection !== null) { $result = \pg_host($connection); } else { $result = \pg_host(); } + restore_error_handler(); + if ($result === '') { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -452,10 +595,21 @@ function pg_host($connection = null): string */ function pg_insert($connection, string $table_name, array $values, int $flags = PGSQL_DML_EXEC) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_insert($connection, $table_name, $values, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -491,10 +645,21 @@ function pg_insert($connection, string $table_name, array $values, int $flags = */ function pg_last_oid($result): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_last_oid($result); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -512,10 +677,21 @@ function pg_last_oid($result): string */ function pg_lo_close($lob): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_close($lob); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -540,7 +716,16 @@ function pg_lo_close($lob): void */ function pg_lo_export($connection = null, int $oid = null, string $pathname = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($pathname !== null) { $result = \pg_lo_export($connection, $oid, $pathname); } elseif ($oid !== null) { @@ -550,8 +735,10 @@ function pg_lo_export($connection = null, int $oid = null, string $pathname = nu } else { $result = \pg_lo_export(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -581,7 +768,16 @@ function pg_lo_export($connection = null, int $oid = null, string $pathname = nu */ function pg_lo_import($connection = null, string $pathname = null, $object_id = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($object_id !== null) { $result = \pg_lo_import($connection, $pathname, $object_id); } elseif ($pathname !== null) { @@ -591,8 +787,10 @@ function pg_lo_import($connection = null, string $pathname = null, $object_id = } else { $result = \pg_lo_import(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -618,10 +816,21 @@ function pg_lo_import($connection = null, string $pathname = null, $object_id = */ function pg_lo_open($connection, int $oid, string $mode) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_open($connection, $oid, $mode); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -644,10 +853,21 @@ function pg_lo_open($connection, int $oid, string $mode) */ function pg_lo_read($lob, int $length = 8192): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_read($lob, $length); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -669,10 +889,21 @@ function pg_lo_read($lob, int $length = 8192): string */ function pg_lo_seek($lob, int $offset, int $whence = SEEK_CUR): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_seek($lob, $offset, $whence); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -690,10 +921,21 @@ function pg_lo_seek($lob, int $offset, int $whence = SEEK_CUR): void */ function pg_lo_truncate($lob, int $size): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_truncate($lob, $size); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -715,10 +957,21 @@ function pg_lo_truncate($lob, int $size): void */ function pg_lo_unlink($connection, int $oid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_lo_unlink($connection, $oid); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -743,14 +996,25 @@ function pg_lo_unlink($connection, int $oid): void */ function pg_lo_write($lob, string $data, int $length = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \pg_lo_write($lob, $data, $length); } else { $result = \pg_lo_write($lob, $data); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -769,10 +1033,21 @@ function pg_lo_write($lob, string $data, int $length = null): int */ function pg_meta_data($connection, string $table_name, bool $extended = false): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_meta_data($connection, $table_name, $extended); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -818,7 +1093,16 @@ function pg_meta_data($connection, string $table_name, bool $extended = false): */ function pg_parameter_status($connection = null, string $param_name = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($param_name !== null) { $result = \pg_parameter_status($connection, $param_name); } elseif ($connection !== null) { @@ -826,8 +1110,10 @@ function pg_parameter_status($connection = null, string $param_name = null): str } else { $result = \pg_parameter_status(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -879,10 +1165,21 @@ function pg_parameter_status($connection = null, string $param_name = null): str */ function pg_pconnect(string $connection_string, int $flags = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_pconnect($connection_string, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -901,14 +1198,25 @@ function pg_pconnect(string $connection_string, int $flags = 0) */ function pg_ping($connection = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection !== null) { $result = \pg_ping($connection); } else { $result = \pg_ping(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -950,7 +1258,16 @@ function pg_ping($connection = null): void */ function pg_prepare($connection = null, string $stmtname = null, string $query = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($query !== null) { $result = \pg_prepare($connection, $stmtname, $query); } elseif ($stmtname !== null) { @@ -960,8 +1277,10 @@ function pg_prepare($connection = null, string $stmtname = null, string $query = } else { $result = \pg_prepare(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -991,7 +1310,16 @@ function pg_prepare($connection = null, string $stmtname = null, string $query = */ function pg_put_line($connection = null, string $data = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($data !== null) { $result = \pg_put_line($connection, $data); } elseif ($connection !== null) { @@ -999,8 +1327,10 @@ function pg_put_line($connection = null, string $data = null): void } else { $result = \pg_put_line(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -1057,7 +1387,16 @@ function pg_put_line($connection = null, string $data = null): void */ function pg_query_params($connection = null, string $query = null, array $params = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($params !== null) { $result = \pg_query_params($connection, $query, $params); } elseif ($query !== null) { @@ -1067,8 +1406,10 @@ function pg_query_params($connection = null, string $query = null, array $params } else { $result = \pg_query_params(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -1115,7 +1456,16 @@ function pg_query_params($connection = null, string $query = null, array $params */ function pg_query($connection = null, string $query = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($query !== null) { $result = \pg_query($connection, $query); } elseif ($connection !== null) { @@ -1123,8 +1473,10 @@ function pg_query($connection = null, string $query = null) } else { $result = \pg_query(); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -1161,10 +1513,21 @@ function pg_query($connection = null, string $query = null) */ function pg_result_error_field($result, int $field_code): ?string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_result_error_field($result, $field_code); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -1183,10 +1546,21 @@ function pg_result_error_field($result, int $field_code): ?string */ function pg_result_seek($result, int $row): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_result_seek($result, $row); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -1232,10 +1606,21 @@ function pg_result_seek($result, int $row): void */ function pg_select($connection, string $table_name, array $conditions, int $flags = PGSQL_DML_EXEC, int $mode = PGSQL_ASSOC) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_select($connection, $table_name, $conditions, $flags, $mode); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -1252,10 +1637,21 @@ function pg_select($connection, string $table_name, array $conditions, int $flag */ function pg_socket($connection) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_socket($connection); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } @@ -1286,14 +1682,25 @@ function pg_socket($connection) */ function pg_trace(string $filename, string $mode = "w", $connection = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($connection !== null) { $result = \pg_trace($filename, $mode, $connection); } else { $result = \pg_trace($filename, $mode); } + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } } @@ -1337,10 +1744,21 @@ function pg_trace(string $filename, string $mode = "w", $connection = null): voi */ function pg_update($connection, string $table_name, array $values, array $conditions, int $flags = PGSQL_DML_EXEC) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pg_update($connection, $table_name, $values, $conditions, $flags); + restore_error_handler(); + if ($result === false) { - throw PgsqlException::createFromPhpError(); + throw PgsqlException::createFromPhpError($error); } return $result; } diff --git a/generated/posix.php b/generated/posix.php index 26b77eaa..1384a80a 100644 --- a/generated/posix.php +++ b/generated/posix.php @@ -22,10 +22,21 @@ */ function posix_access(string $filename, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_access($filename, $flags); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -85,10 +96,21 @@ function posix_access(string $filename, int $flags = 0): void */ function posix_getgrgid(int $group_id): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getgrgid($group_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -149,10 +171,21 @@ function posix_getgrgid(int $group_id): array */ function posix_getgrnam(string $name): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getgrnam($name); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -168,10 +201,21 @@ function posix_getgrnam(string $name): array */ function posix_getgroups(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getgroups(); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -186,10 +230,21 @@ function posix_getgroups(): array */ function posix_getlogin(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getlogin(); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -278,10 +333,21 @@ function posix_getlogin(): string */ function posix_getpwuid(int $user_id): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getpwuid($user_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -388,10 +454,21 @@ function posix_getpwuid(int $user_id): array */ function posix_getrlimit(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getrlimit(); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -411,10 +488,21 @@ function posix_getrlimit(): array */ function posix_getsid(int $process_id): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getsid($process_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -430,10 +518,21 @@ function posix_getsid(int $process_id): int */ function posix_initgroups(string $username, int $group_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_initgroups($username, $group_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -449,10 +548,21 @@ function posix_initgroups(string $username, int $group_id): void */ function posix_kill(int $process_id, int $signal): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_kill($process_id, $signal); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -473,10 +583,21 @@ function posix_kill(int $process_id, int $signal): void */ function posix_mkfifo(string $filename, int $permissions): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_mkfifo($filename, $permissions); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -498,10 +619,21 @@ function posix_mkfifo(string $filename, int $permissions): void */ function posix_mknod(string $filename, int $flags, int $major = 0, int $minor = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_mknod($filename, $flags, $major, $minor); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -517,10 +649,21 @@ function posix_mknod(string $filename, int $flags, int $major = 0, int $minor = */ function posix_setegid(int $group_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_setegid($group_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -536,10 +679,21 @@ function posix_setegid(int $group_id): void */ function posix_seteuid(int $user_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_seteuid($user_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -558,10 +712,21 @@ function posix_seteuid(int $user_id): void */ function posix_setgid(int $group_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_setgid($group_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -577,10 +742,21 @@ function posix_setgid(int $group_id): void */ function posix_setpgid(int $process_id, int $process_group_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_setpgid($process_id, $process_group_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -608,10 +784,21 @@ function posix_setpgid(int $process_id, int $process_group_id): void */ function posix_setrlimit(int $resource, int $soft_limit, int $hard_limit): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_setrlimit($resource, $soft_limit, $hard_limit); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -627,10 +814,21 @@ function posix_setrlimit(int $resource, int $soft_limit, int $hard_limit): void */ function posix_setuid(int $user_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_setuid($user_id); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } } @@ -674,10 +872,21 @@ function posix_setuid(int $user_id): void */ function posix_times(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_times(); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -724,10 +933,21 @@ function posix_times(): array */ function posix_uname(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_uname(); + restore_error_handler(); + if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } diff --git a/generated/ps.php b/generated/ps.php index a2dca797..df8235c3 100644 --- a/generated/ps.php +++ b/generated/ps.php @@ -27,10 +27,21 @@ */ function ps_add_launchlink($psdoc, float $llx, float $lly, float $urx, float $ury, string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_add_launchlink($psdoc, $llx, $lly, $urx, $ury, $filename); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -65,10 +76,21 @@ function ps_add_launchlink($psdoc, float $llx, float $lly, float $urx, float $ur */ function ps_add_locallink($psdoc, float $llx, float $lly, float $urx, float $ury, int $page, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_add_locallink($psdoc, $llx, $lly, $urx, $ury, $page, $dest); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -104,10 +126,21 @@ function ps_add_locallink($psdoc, float $llx, float $lly, float $urx, float $ury */ function ps_add_note($psdoc, float $llx, float $lly, float $urx, float $ury, string $contents, string $title, string $icon, int $open): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_add_note($psdoc, $llx, $lly, $urx, $ury, $contents, $title, $icon, $open); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -144,10 +177,21 @@ function ps_add_note($psdoc, float $llx, float $lly, float $urx, float $ury, str */ function ps_add_pdflink($psdoc, float $llx, float $lly, float $urx, float $ury, string $filename, int $page, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_add_pdflink($psdoc, $llx, $lly, $urx, $ury, $filename, $page, $dest); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -177,10 +221,21 @@ function ps_add_pdflink($psdoc, float $llx, float $lly, float $urx, float $ury, */ function ps_add_weblink($psdoc, float $llx, float $lly, float $urx, float $ury, string $url): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_add_weblink($psdoc, $llx, $lly, $urx, $ury, $url); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -206,10 +261,21 @@ function ps_add_weblink($psdoc, float $llx, float $lly, float $urx, float $ury, */ function ps_arc($psdoc, float $x, float $y, float $radius, float $alpha, float $beta): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_arc($psdoc, $x, $y, $radius, $alpha, $beta); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -235,10 +301,21 @@ function ps_arc($psdoc, float $x, float $y, float $radius, float $alpha, float $ */ function ps_arcn($psdoc, float $x, float $y, float $radius, float $alpha, float $beta): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_arcn($psdoc, $x, $y, $radius, $alpha, $beta); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -286,10 +363,21 @@ function ps_arcn($psdoc, float $x, float $y, float $radius, float $alpha, float */ function ps_begin_page($psdoc, float $width, float $height): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_begin_page($psdoc, $width, $height); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -315,10 +403,21 @@ function ps_begin_page($psdoc, float $width, float $height): void */ function ps_begin_pattern($psdoc, float $width, float $height, float $xstep, float $ystep, int $painttype): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_begin_pattern($psdoc, $width, $height, $xstep, $ystep, $painttype); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -342,10 +441,21 @@ function ps_begin_pattern($psdoc, float $width, float $height, float $xstep, flo */ function ps_begin_template($psdoc, float $width, float $height): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_begin_template($psdoc, $width, $height); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -371,10 +481,21 @@ function ps_begin_template($psdoc, float $width, float $height): int */ function ps_circle($psdoc, float $x, float $y, float $radius): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_circle($psdoc, $x, $y, $radius); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -390,10 +511,21 @@ function ps_circle($psdoc, float $x, float $y, float $radius): void */ function ps_clip($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_clip($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -412,10 +544,21 @@ function ps_clip($psdoc): void */ function ps_close_image($psdoc, int $imageid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_close_image($psdoc, $imageid); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -437,10 +580,21 @@ function ps_close_image($psdoc, int $imageid): void */ function ps_close($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_close($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -456,10 +610,21 @@ function ps_close($psdoc): void */ function ps_closepath_stroke($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_closepath_stroke($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -475,10 +640,21 @@ function ps_closepath_stroke($psdoc): void */ function ps_closepath($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_closepath($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -498,10 +674,21 @@ function ps_closepath($psdoc): void */ function ps_continue_text($psdoc, string $text): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_continue_text($psdoc, $text); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -523,10 +710,21 @@ function ps_continue_text($psdoc, string $text): void */ function ps_curveto($psdoc, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_curveto($psdoc, $x1, $y1, $x2, $y2, $x3, $y3); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -546,10 +744,21 @@ function ps_curveto($psdoc, float $x1, float $y1, float $x2, float $y2, float $x */ function ps_delete($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_delete($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -567,10 +776,21 @@ function ps_delete($psdoc): void */ function ps_end_page($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_end_page($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -587,10 +807,21 @@ function ps_end_page($psdoc): void */ function ps_end_pattern($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_end_pattern($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -606,10 +837,21 @@ function ps_end_pattern($psdoc): void */ function ps_end_template($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_end_template($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -625,10 +867,21 @@ function ps_end_template($psdoc): void */ function ps_fill_stroke($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_fill_stroke($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -644,10 +897,21 @@ function ps_fill_stroke($psdoc): void */ function ps_fill($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_fill($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -780,14 +1044,25 @@ function ps_fill($psdoc): void */ function ps_get_parameter($psdoc, string $name, float $modifier = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($modifier !== null) { $result = \ps_get_parameter($psdoc, $name, $modifier); } else { $result = \ps_get_parameter($psdoc, $name); } + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -816,10 +1091,21 @@ function ps_get_parameter($psdoc, string $name, float $modifier = null): string */ function ps_hyphenate($psdoc, string $text): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_hyphenate($psdoc, $text); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -838,10 +1124,21 @@ function ps_hyphenate($psdoc, string $text): array */ function ps_include_file($psdoc, string $file): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_include_file($psdoc, $file); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -860,10 +1157,21 @@ function ps_include_file($psdoc, string $file): void */ function ps_lineto($psdoc, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_lineto($psdoc, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -883,10 +1191,21 @@ function ps_lineto($psdoc, float $x, float $y): void */ function ps_moveto($psdoc, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_moveto($psdoc, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -904,10 +1223,21 @@ function ps_moveto($psdoc, float $x, float $y): void */ function ps_new() { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_new(); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -927,14 +1257,25 @@ function ps_new() */ function ps_open_file($psdoc, string $filename = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($filename !== null) { $result = \ps_open_file($psdoc, $filename); } else { $result = \ps_open_file($psdoc); } + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -959,10 +1300,21 @@ function ps_open_file($psdoc, string $filename = null): void */ function ps_place_image($psdoc, int $imageid, float $x, float $y, float $scale): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_place_image($psdoc, $imageid, $x, $y, $scale); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -986,10 +1338,21 @@ function ps_place_image($psdoc, int $imageid, float $x, float $y, float $scale): */ function ps_rect($psdoc, float $x, float $y, float $width, float $height): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_rect($psdoc, $x, $y, $width, $height); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1008,10 +1371,21 @@ function ps_rect($psdoc, float $x, float $y, float $width, float $height): void */ function ps_restore($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_restore($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1027,10 +1401,21 @@ function ps_restore($psdoc): void */ function ps_rotate($psdoc, float $rot): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_rotate($psdoc, $rot); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1047,10 +1432,21 @@ function ps_rotate($psdoc, float $rot): void */ function ps_save($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_save($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1067,10 +1463,21 @@ function ps_save($psdoc): void */ function ps_scale($psdoc, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_scale($psdoc, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1093,10 +1500,21 @@ function ps_scale($psdoc, float $x, float $y): void */ function ps_set_border_color($psdoc, float $red, float $green, float $blue): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_border_color($psdoc, $red, $green, $blue); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1119,10 +1537,21 @@ function ps_set_border_color($psdoc, float $red, float $green, float $blue): voi */ function ps_set_border_dash($psdoc, float $black, float $white): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_border_dash($psdoc, $black, $white); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1145,10 +1574,21 @@ function ps_set_border_dash($psdoc, float $black, float $white): void */ function ps_set_border_style($psdoc, string $style, float $width): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_border_style($psdoc, $style, $width); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1192,10 +1632,21 @@ function ps_set_border_style($psdoc, string $style, float $width): void */ function ps_set_info($p, string $key, string $val): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_info($p, $key, $val); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1213,10 +1664,21 @@ function ps_set_info($p, string $key, string $val): void */ function ps_set_parameter($psdoc, string $name, string $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_parameter($psdoc, $name, $value); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1240,10 +1702,21 @@ function ps_set_parameter($psdoc, string $name, string $value): void */ function ps_set_text_pos($psdoc, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_text_pos($psdoc, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1313,10 +1786,21 @@ function ps_set_text_pos($psdoc, float $x, float $y): void */ function ps_set_value($psdoc, string $name, float $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_set_value($psdoc, $name, $value); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1348,10 +1832,21 @@ function ps_set_value($psdoc, string $name, float $value): void */ function ps_setcolor($psdoc, string $type, string $colorspace, float $c1, float $c2, float $c3, float $c4): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setcolor($psdoc, $type, $colorspace, $c1, $c2, $c3, $c4); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1368,10 +1863,21 @@ function ps_setcolor($psdoc, string $type, string $colorspace, float $c1, float */ function ps_setdash($psdoc, float $on, float $off): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setdash($psdoc, $on, $off); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1389,10 +1895,21 @@ function ps_setdash($psdoc, float $on, float $off): void */ function ps_setflat($psdoc, float $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setflat($psdoc, $value); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1411,10 +1928,21 @@ function ps_setflat($psdoc, float $value): void */ function ps_setfont($psdoc, int $fontid, float $size): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setfont($psdoc, $fontid, $size); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1430,10 +1958,21 @@ function ps_setfont($psdoc, int $fontid, float $size): void */ function ps_setgray($psdoc, float $gray): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setgray($psdoc, $gray); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1452,10 +1991,21 @@ function ps_setgray($psdoc, float $gray): void */ function ps_setlinecap($psdoc, int $type): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setlinecap($psdoc, $type); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1474,10 +2024,21 @@ function ps_setlinecap($psdoc, int $type): void */ function ps_setlinejoin($psdoc, int $type): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setlinejoin($psdoc, $type); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1493,10 +2054,21 @@ function ps_setlinejoin($psdoc, int $type): void */ function ps_setlinewidth($psdoc, float $width): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setlinewidth($psdoc, $width); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1517,10 +2089,21 @@ function ps_setlinewidth($psdoc, float $width): void */ function ps_setmiterlimit($psdoc, float $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setmiterlimit($psdoc, $value); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1538,10 +2121,21 @@ function ps_setmiterlimit($psdoc, float $value): void */ function ps_setoverprintmode($psdoc, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setoverprintmode($psdoc, $mode); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1560,10 +2154,21 @@ function ps_setoverprintmode($psdoc, int $mode): void */ function ps_setpolydash($psdoc, float $arr): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_setpolydash($psdoc, $arr); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1584,10 +2189,21 @@ function ps_setpolydash($psdoc, float $arr): void */ function ps_shading_pattern($psdoc, int $shadingid, string $optlist): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_shading_pattern($psdoc, $shadingid, $optlist); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -1629,10 +2245,21 @@ function ps_shading_pattern($psdoc, int $shadingid, string $optlist): int */ function ps_shading($psdoc, string $type, float $x0, float $y0, float $x1, float $y1, float $c1, float $c2, float $c3, float $c4, string $optlist): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_shading($psdoc, $type, $x0, $y0, $x1, $y1, $c1, $c2, $c3, $c4, $optlist); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } return $result; } @@ -1653,10 +2280,21 @@ function ps_shading($psdoc, string $type, float $x0, float $y0, float $x1, float */ function ps_shfill($psdoc, int $shadingid): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_shfill($psdoc, $shadingid); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1674,10 +2312,21 @@ function ps_shfill($psdoc, int $shadingid): void */ function ps_show_xy($psdoc, string $text, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_show_xy($psdoc, $text, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1697,10 +2346,21 @@ function ps_show_xy($psdoc, string $text, float $x, float $y): void */ function ps_show_xy2($psdoc, string $text, int $len, float $xcoor, float $ycoor): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_show_xy2($psdoc, $text, $len, $xcoor, $ycoor); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1724,10 +2384,21 @@ function ps_show_xy2($psdoc, string $text, int $len, float $xcoor, float $ycoor) */ function ps_show($psdoc, string $text): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_show($psdoc, $text); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1744,10 +2415,21 @@ function ps_show($psdoc, string $text): void */ function ps_show2($psdoc, string $text, int $len): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_show2($psdoc, $text, $len); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1763,10 +2445,21 @@ function ps_show2($psdoc, string $text, int $len): void */ function ps_stroke($psdoc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_stroke($psdoc); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1784,10 +2477,21 @@ function ps_stroke($psdoc): void */ function ps_symbol($psdoc, int $ord): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_symbol($psdoc, $ord); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } @@ -1804,9 +2508,20 @@ function ps_symbol($psdoc, int $ord): void */ function ps_translate($psdoc, float $x, float $y): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ps_translate($psdoc, $x, $y); + restore_error_handler(); + if ($result === false) { - throw PsException::createFromPhpError(); + throw PsException::createFromPhpError($error); } } diff --git a/generated/pspell.php b/generated/pspell.php index b1e296d6..2996db3b 100644 --- a/generated/pspell.php +++ b/generated/pspell.php @@ -14,10 +14,21 @@ */ function pspell_add_to_personal(int $dictionary, string $word): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_add_to_personal($dictionary, $word); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -32,10 +43,21 @@ function pspell_add_to_personal(int $dictionary, string $word): void */ function pspell_add_to_session(int $dictionary, string $word): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_add_to_session($dictionary, $word); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -49,10 +71,21 @@ function pspell_add_to_session(int $dictionary, string $word): void */ function pspell_clear_session(int $dictionary): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_clear_session($dictionary); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -92,10 +125,21 @@ function pspell_clear_session(int $dictionary): void */ function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_create($language, $spelling, $jargon, $encoding); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } return $result; } @@ -113,10 +157,21 @@ function pspell_config_create(string $language, string $spelling = "", string $j */ function pspell_config_data_dir(int $config, string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_data_dir($config, $directory); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -133,10 +188,21 @@ function pspell_config_data_dir(int $config, string $directory): void */ function pspell_config_dict_dir(int $config, string $directory): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_dict_dir($config, $directory); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -151,10 +217,21 @@ function pspell_config_dict_dir(int $config, string $directory): void */ function pspell_config_ignore(int $config, int $min_length): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_ignore($config, $min_length); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -189,10 +266,21 @@ function pspell_config_ignore(int $config, int $min_length): void */ function pspell_config_mode(int $config, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_mode($config, $mode); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -214,10 +302,21 @@ function pspell_config_mode(int $config, int $mode): void */ function pspell_config_personal(int $config, string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_personal($config, $filename); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -241,10 +340,21 @@ function pspell_config_personal(int $config, string $filename): void */ function pspell_config_repl(int $config, string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_repl($config, $filename); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -267,10 +377,21 @@ function pspell_config_repl(int $config, string $filename): void */ function pspell_config_runtogether(int $config, bool $allow): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_runtogether($config, $allow); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -294,10 +415,21 @@ function pspell_config_runtogether(int $config, bool $allow): void */ function pspell_config_save_repl(int $config, bool $save): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_config_save_repl($config, $save); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -313,10 +445,21 @@ function pspell_config_save_repl(int $config, bool $save): void */ function pspell_new_config(int $config): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_new_config($config); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } return $result; } @@ -383,10 +526,21 @@ function pspell_new_config(int $config): int */ function pspell_new_personal(string $filename, string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_new_personal($filename, $language, $spelling, $jargon, $encoding, $mode); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } return $result; } @@ -456,10 +610,21 @@ function pspell_new_personal(string $filename, string $language, string $spellin */ function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_new($language, $spelling, $jargon, $encoding, $mode); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } return $result; } @@ -474,10 +639,21 @@ function pspell_new(string $language, string $spelling = "", string $jargon = "" */ function pspell_save_wordlist(int $dictionary): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_save_wordlist($dictionary); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } @@ -493,9 +669,20 @@ function pspell_save_wordlist(int $dictionary): void */ function pspell_store_replacement(int $dictionary, string $misspelled, string $correct): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \pspell_store_replacement($dictionary, $misspelled, $correct); + restore_error_handler(); + if ($result === false) { - throw PspellException::createFromPhpError(); + throw PspellException::createFromPhpError($error); } } diff --git a/generated/readline.php b/generated/readline.php index ddbf5a35..86eae53a 100644 --- a/generated/readline.php +++ b/generated/readline.php @@ -13,10 +13,21 @@ */ function readline_add_history(string $prompt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readline_add_history($prompt); + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } @@ -40,10 +51,21 @@ function readline_add_history(string $prompt): void */ function readline_callback_handler_install(string $prompt, callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readline_callback_handler_install($prompt, $callback); + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } @@ -56,10 +78,21 @@ function readline_callback_handler_install(string $prompt, callable $callback): */ function readline_clear_history(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readline_clear_history(); + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } @@ -75,10 +108,21 @@ function readline_clear_history(): void */ function readline_completion_function(callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readline_completion_function($callback); + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } @@ -92,14 +136,25 @@ function readline_completion_function(callable $callback): void */ function readline_read_history(string $filename = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($filename !== null) { $result = \readline_read_history($filename); } else { $result = \readline_read_history(); } + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } @@ -113,13 +168,24 @@ function readline_read_history(string $filename = null): void */ function readline_write_history(string $filename = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($filename !== null) { $result = \readline_write_history($filename); } else { $result = \readline_write_history(); } + restore_error_handler(); + if ($result === false) { - throw ReadlineException::createFromPhpError(); + throw ReadlineException::createFromPhpError($error); } } diff --git a/generated/rpminfo.php b/generated/rpminfo.php index 44de1ce2..dc7427a5 100644 --- a/generated/rpminfo.php +++ b/generated/rpminfo.php @@ -13,9 +13,20 @@ */ function rpmaddtag(int $tag): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rpmaddtag($tag); + restore_error_handler(); + if ($result === false) { - throw RpminfoException::createFromPhpError(); + throw RpminfoException::createFromPhpError($error); } } diff --git a/generated/rrd.php b/generated/rrd.php index 2da227d0..97a78fa6 100644 --- a/generated/rrd.php +++ b/generated/rrd.php @@ -15,10 +15,21 @@ */ function rrd_create(string $filename, array $options): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_create($filename, $options); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } } @@ -34,10 +45,21 @@ function rrd_create(string $filename, array $options): void */ function rrd_first(string $file, int $raaindex = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_first($file, $raaindex); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } return $result; } @@ -58,10 +80,21 @@ function rrd_first(string $file, int $raaindex = 0): int */ function rrd_graph(string $filename, array $options): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_graph($filename, $options); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } return $result; } @@ -77,10 +110,21 @@ function rrd_graph(string $filename, array $options): array */ function rrd_info(string $filename): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_info($filename); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } return $result; } @@ -97,10 +141,21 @@ function rrd_info(string $filename): array */ function rrd_lastupdate(string $filename): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_lastupdate($filename); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } return $result; } @@ -117,14 +172,25 @@ function rrd_lastupdate(string $filename): array */ function rrd_restore(string $xml_file, string $rrd_file, array $options = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \rrd_restore($xml_file, $rrd_file, $options); } else { $result = \rrd_restore($xml_file, $rrd_file); } + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } } @@ -141,10 +207,21 @@ function rrd_restore(string $xml_file, string $rrd_file, array $options = null): */ function rrd_tune(string $filename, array $options): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_tune($filename, $options); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } } @@ -161,10 +238,21 @@ function rrd_tune(string $filename, array $options): void */ function rrd_update(string $filename, array $options): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_update($filename, $options); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } } @@ -181,10 +269,21 @@ function rrd_update(string $filename, array $options): void */ function rrd_xport(array $options): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \rrd_xport($options); + restore_error_handler(); + if ($result === false) { - throw RrdException::createFromPhpError(); + throw RrdException::createFromPhpError($error); } return $result; } diff --git a/generated/sem.php b/generated/sem.php index 02021215..e2cb03bb 100644 --- a/generated/sem.php +++ b/generated/sem.php @@ -23,10 +23,21 @@ */ function msg_get_queue(int $key, int $permissions = 0666) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_get_queue($key, $permissions); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } return $result; } @@ -41,10 +52,21 @@ function msg_get_queue(int $key, int $permissions = 0666) */ function msg_queue_exists(int $key): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_queue_exists($key); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -122,10 +144,21 @@ function msg_queue_exists(int $key): void */ function msg_receive($queue, int $desired_message_type, ?int &$received_message_type, int $max_message_size, &$message, bool $unserialize = true, int $flags = 0, ?int &$error_code = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_receive($queue, $desired_message_type, $received_message_type, $max_message_size, $message, $unserialize, $flags, $error_code); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -142,10 +175,21 @@ function msg_receive($queue, int $desired_message_type, ?int &$received_message_ */ function msg_remove_queue($queue): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_remove_queue($queue); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -185,10 +229,21 @@ function msg_remove_queue($queue): void */ function msg_send($queue, int $message_type, $message, bool $serialize = true, bool $blocking = true, ?int &$error_code = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_send($queue, $message_type, $message, $serialize, $blocking, $error_code); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -212,10 +267,21 @@ function msg_send($queue, int $message_type, $message, bool $serialize = true, b */ function msg_set_queue($queue, array $data): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_set_queue($queue, $data); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -305,10 +371,21 @@ function msg_set_queue($queue, array $data): void */ function msg_stat_queue($queue): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \msg_stat_queue($queue); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } return $result; } @@ -335,10 +412,21 @@ function msg_stat_queue($queue): array */ function sem_acquire($semaphore, bool $non_blocking = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sem_acquire($semaphore, $non_blocking); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -368,10 +456,21 @@ function sem_acquire($semaphore, bool $non_blocking = false): void */ function sem_get(int $key, int $max_acquire = 1, int $permissions = 0666, bool $auto_release = true) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sem_get($key, $max_acquire, $permissions, $auto_release); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } return $result; } @@ -392,10 +491,21 @@ function sem_get(int $key, int $max_acquire = 1, int $permissions = 0666, bool $ */ function sem_release($semaphore): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sem_release($semaphore); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -412,10 +522,21 @@ function sem_release($semaphore): void */ function sem_remove($semaphore): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sem_remove($semaphore); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -444,7 +565,16 @@ function sem_remove($semaphore): void */ function shm_attach(int $key, int $size = null, int $permissions = 0666) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($permissions !== 0666) { $result = \shm_attach($key, $size, $permissions); } elseif ($size !== null) { @@ -452,8 +582,10 @@ function shm_attach(int $key, int $size = null, int $permissions = 0666) } else { $result = \shm_attach($key); } + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } return $result; } @@ -471,10 +603,21 @@ function shm_attach(int $key, int $size = null, int $permissions = 0666) */ function shm_detach($shm): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shm_detach($shm); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -500,10 +643,21 @@ function shm_detach($shm): void */ function shm_put_var($shm, int $key, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shm_put_var($shm, $key, $value); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -519,10 +673,21 @@ function shm_put_var($shm, int $key, $value): void */ function shm_remove_var($shm, int $key): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shm_remove_var($shm, $key); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } @@ -537,9 +702,20 @@ function shm_remove_var($shm, int $key): void */ function shm_remove($shm): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shm_remove($shm); + restore_error_handler(); + if ($result === false) { - throw SemException::createFromPhpError(); + throw SemException::createFromPhpError($error); } } diff --git a/generated/session.php b/generated/session.php index 212cf850..c90ee2a3 100644 --- a/generated/session.php +++ b/generated/session.php @@ -13,10 +13,21 @@ */ function session_abort(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_abort(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -48,10 +59,21 @@ function session_abort(): void */ function session_create_id(string $prefix = ""): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_create_id($prefix); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -71,10 +93,21 @@ function session_create_id(string $prefix = ""): string */ function session_decode(string $data): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_decode($data); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -97,10 +130,21 @@ function session_decode(string $data): void */ function session_destroy(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_destroy(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -118,10 +162,21 @@ function session_destroy(): void */ function session_encode(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_encode(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -151,14 +206,25 @@ function session_encode(): string */ function session_id(string $id = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($id !== null) { $result = \session_id($id); } else { $result = \session_id(); } + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -180,14 +246,25 @@ function session_id(string $id = null): string */ function session_module_name(string $module = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($module !== null) { $result = \session_module_name($module); } else { $result = \session_module_name(); } + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -237,14 +314,25 @@ function session_module_name(string $module = null): string */ function session_name(string $name = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($name !== null) { $result = \session_name($name); } else { $result = \session_name(); } + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -267,10 +355,21 @@ function session_name(string $name = null): string */ function session_regenerate_id(bool $delete_old_session = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_regenerate_id($delete_old_session); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -285,10 +384,21 @@ function session_regenerate_id(bool $delete_old_session = false): void */ function session_reset(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_reset(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -318,14 +428,25 @@ function session_reset(): void */ function session_save_path(string $path = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($path !== null) { $result = \session_save_path($path); } else { $result = \session_save_path(); } + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } return $result; } @@ -340,10 +461,21 @@ function session_save_path(string $path = null): string */ function session_unset(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_unset(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } @@ -364,9 +496,20 @@ function session_unset(): void */ function session_write_close(): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \session_write_close(); + restore_error_handler(); + if ($result === false) { - throw SessionException::createFromPhpError(); + throw SessionException::createFromPhpError($error); } } diff --git a/generated/shmop.php b/generated/shmop.php index aa5d8f49..e2348f79 100644 --- a/generated/shmop.php +++ b/generated/shmop.php @@ -14,10 +14,21 @@ */ function shmop_delete($shmop): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shmop_delete($shmop); + restore_error_handler(); + if ($result === false) { - throw ShmopException::createFromPhpError(); + throw ShmopException::createFromPhpError($error); } } @@ -36,10 +47,21 @@ function shmop_delete($shmop): void */ function shmop_read($shmop, int $offset, int $size): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \shmop_read($shmop, $offset, $size); + restore_error_handler(); + if ($result === false) { - throw ShmopException::createFromPhpError(); + throw ShmopException::createFromPhpError($error); } return $result; } diff --git a/generated/sockets.php b/generated/sockets.php index bfcd9bac..fa195b1d 100644 --- a/generated/sockets.php +++ b/generated/sockets.php @@ -36,10 +36,21 @@ */ function socket_accept($socket) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_accept($socket); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -56,10 +67,21 @@ function socket_accept($socket) */ function socket_addrinfo_bind($address) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_addrinfo_bind($address); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -76,10 +98,21 @@ function socket_addrinfo_bind($address) */ function socket_addrinfo_connect($address) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_addrinfo_connect($address); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -101,7 +134,16 @@ function socket_addrinfo_connect($address) */ function socket_addrinfo_lookup(string $host, $service = null, array $hints = []): iterable { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($hints !== []) { $result = \socket_addrinfo_lookup($host, $service, $hints); } elseif ($service !== null) { @@ -109,8 +151,10 @@ function socket_addrinfo_lookup(string $host, $service = null, array $hints = [] } else { $result = \socket_addrinfo_lookup($host); } + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -138,10 +182,21 @@ function socket_addrinfo_lookup(string $host, $service = null, array $hints = [] */ function socket_bind($socket, string $address, int $port = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_bind($socket, $address, $port); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -169,14 +224,25 @@ function socket_bind($socket, string $address, int $port = 0): void */ function socket_connect($socket, string $address, int $port = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($port !== null) { $result = \socket_connect($socket, $address, $port); } else { $result = \socket_connect($socket, $address); } + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -205,10 +271,21 @@ function socket_connect($socket, string $address, int $port = null): void */ function socket_create_listen(int $port, int $backlog = 128) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_create_listen($port, $backlog); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -241,10 +318,21 @@ function socket_create_listen(int $port, int $backlog = 128) */ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$pair): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_create_pair($domain, $type, $protocol, $pair); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -274,10 +362,21 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$p */ function socket_create(int $domain, int $type, int $protocol) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_create($domain, $type, $protocol); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -293,10 +392,21 @@ function socket_create(int $domain, int $type, int $protocol) */ function socket_export_stream($socket) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_export_stream($socket); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -340,10 +450,21 @@ function socket_export_stream($socket) */ function socket_get_option($socket, int $level, int $option) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_get_option($socket, $level, $option); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -374,10 +495,21 @@ function socket_get_option($socket, int $level, int $option) */ function socket_getpeername($socket, ?string &$address, ?int &$port = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_getpeername($socket, $address, $port); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -404,10 +536,21 @@ function socket_getpeername($socket, ?string &$address, ?int &$port = null): voi */ function socket_getsockname($socket, ?string &$address, ?int &$port = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_getsockname($socket, $address, $port); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -422,10 +565,21 @@ function socket_getsockname($socket, ?string &$address, ?int &$port = null): voi */ function socket_import_stream($stream) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_import_stream($stream); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -461,10 +615,21 @@ function socket_import_stream($stream) */ function socket_listen($socket, int $backlog = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_listen($socket, $backlog); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -507,10 +672,21 @@ function socket_listen($socket, int $backlog = 0): void */ function socket_read($socket, int $length, int $mode = PHP_BINARY_READ): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_read($socket, $length, $mode); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -568,10 +744,21 @@ function socket_read($socket, int $length, int $mode = PHP_BINARY_READ): string */ function socket_send($socket, string $data, int $length, int $flags): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_send($socket, $data, $length, $flags); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -589,10 +776,21 @@ function socket_send($socket, string $data, int $length, int $flags): int */ function socket_sendmsg($socket, array $message, int $flags = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_sendmsg($socket, $message, $flags); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -654,14 +852,25 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int */ function socket_sendto($socket, string $data, int $length, int $flags, string $address, int $port = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($port !== null) { $result = \socket_sendto($socket, $data, $length, $flags, $address, $port); } else { $result = \socket_sendto($socket, $data, $length, $flags, $address); } + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -683,10 +892,21 @@ function socket_sendto($socket, string $data, int $length, int $flags, string $a */ function socket_set_block($socket): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_set_block($socket); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -708,10 +928,21 @@ function socket_set_block($socket): void */ function socket_set_nonblock($socket): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_set_nonblock($socket); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -740,10 +971,21 @@ function socket_set_nonblock($socket): void */ function socket_set_option($socket, int $level, int $option, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_set_option($socket, $level, $option, $value); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -785,10 +1027,21 @@ function socket_set_option($socket, int $level, int $option, $value): void */ function socket_shutdown($socket, int $mode = 2): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_shutdown($socket, $mode); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } @@ -806,10 +1059,21 @@ function socket_shutdown($socket, int $mode = 2): void */ function socket_wsaprotocol_info_export($socket, int $process_id): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_wsaprotocol_info_export($socket, $process_id); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -826,10 +1090,21 @@ function socket_wsaprotocol_info_export($socket, int $process_id): string */ function socket_wsaprotocol_info_import(string $info_id) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_wsaprotocol_info_import($info_id); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -845,9 +1120,20 @@ function socket_wsaprotocol_info_import(string $info_id) */ function socket_wsaprotocol_info_release(string $info_id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \socket_wsaprotocol_info_release($info_id); + restore_error_handler(); + if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } } diff --git a/generated/sodium.php b/generated/sodium.php index d13da0da..330af7cf 100644 --- a/generated/sodium.php +++ b/generated/sodium.php @@ -20,10 +20,21 @@ */ function sodium_crypto_aead_aes256gcm_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -44,10 +55,21 @@ function sodium_crypto_aead_aes256gcm_decrypt(string $ciphertext, string $additi */ function sodium_crypto_aead_chacha20poly1305_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -67,10 +89,21 @@ function sodium_crypto_aead_chacha20poly1305_decrypt(string $ciphertext, string */ function sodium_crypto_aead_chacha20poly1305_encrypt(string $message, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -93,10 +126,21 @@ function sodium_crypto_aead_chacha20poly1305_encrypt(string $message, string $ad */ function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_chacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -118,10 +162,21 @@ function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(string $ciphertext, st */ function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -145,10 +200,21 @@ function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(string $message, strin */ function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(string $ciphertext, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -171,10 +237,21 @@ function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(string $ciphertext, s */ function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(string $message, string $additional_data, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -195,10 +272,21 @@ function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(string $message, stri */ function sodium_crypto_auth_verify(string $mac, string $message, string $key): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_auth_verify($mac, $message, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } } @@ -217,10 +305,21 @@ function sodium_crypto_auth_verify(string $mac, string $message, string $key): v */ function sodium_crypto_box_open(string $ciphertext, string $nonce, string $key_pair): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_box_open($ciphertext, $nonce, $key_pair); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -237,10 +336,21 @@ function sodium_crypto_box_open(string $ciphertext, string $nonce, string $key_p */ function sodium_crypto_box_seal_open(string $ciphertext, string $key_pair): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_box_seal_open($ciphertext, $key_pair); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -256,10 +366,21 @@ function sodium_crypto_box_seal_open(string $ciphertext, string $key_pair): stri */ function sodium_crypto_generichash_update(string &$state, string $message): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_generichash_update($state, $message); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } } @@ -278,10 +399,21 @@ function sodium_crypto_generichash_update(string &$state, string $message): void */ function sodium_crypto_secretbox_open(string $ciphertext, string $nonce, string $key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_secretbox_open($ciphertext, $nonce, $key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -298,10 +430,21 @@ function sodium_crypto_secretbox_open(string $ciphertext, string $nonce, string */ function sodium_crypto_sign_open(string $signed_message, string $public_key): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_sign_open($signed_message, $public_key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } return $result; } @@ -318,9 +461,20 @@ function sodium_crypto_sign_open(string $signed_message, string $public_key): st */ function sodium_crypto_sign_verify_detached(string $signature, string $message, string $public_key): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sodium_crypto_sign_verify_detached($signature, $message, $public_key); + restore_error_handler(); + if ($result === false) { - throw SodiumException::createFromPhpError(); + throw SodiumException::createFromPhpError($error); } } diff --git a/generated/solr.php b/generated/solr.php index 4d4e0418..54d98066 100644 --- a/generated/solr.php +++ b/generated/solr.php @@ -13,10 +13,21 @@ */ function solr_get_version(): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \solr_get_version(); + restore_error_handler(); + if ($result === false) { - throw SolrException::createFromPhpError(); + throw SolrException::createFromPhpError($error); } return $result; } diff --git a/generated/spl.php b/generated/spl.php index 08c679dc..bd5c3345 100644 --- a/generated/spl.php +++ b/generated/spl.php @@ -16,10 +16,21 @@ */ function class_implements($object_or_class, bool $autoload = true): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \class_implements($object_or_class, $autoload); + restore_error_handler(); + if ($result === false) { - throw SplException::createFromPhpError(); + throw SplException::createFromPhpError($error); } return $result; } @@ -37,10 +48,21 @@ function class_implements($object_or_class, bool $autoload = true): array */ function class_parents($object_or_class, bool $autoload = true): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \class_parents($object_or_class, $autoload); + restore_error_handler(); + if ($result === false) { - throw SplException::createFromPhpError(); + throw SplException::createFromPhpError($error); } return $result; } @@ -59,10 +81,21 @@ function class_parents($object_or_class, bool $autoload = true): array */ function class_uses($object_or_class, bool $autoload = true): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \class_uses($object_or_class, $autoload); + restore_error_handler(); + if ($result === false) { - throw SplException::createFromPhpError(); + throw SplException::createFromPhpError($error); } return $result; } @@ -98,7 +131,16 @@ function class_uses($object_or_class, bool $autoload = true): array */ function spl_autoload_register(callable $callback = null, bool $throw = true, bool $prepend = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($prepend !== false) { $result = \spl_autoload_register($callback, $throw, $prepend); } elseif ($throw !== true) { @@ -108,8 +150,10 @@ function spl_autoload_register(callable $callback = null, bool $throw = true, bo } else { $result = \spl_autoload_register(); } + restore_error_handler(); + if ($result === false) { - throw SplException::createFromPhpError(); + throw SplException::createFromPhpError($error); } } @@ -128,9 +172,20 @@ function spl_autoload_register(callable $callback = null, bool $throw = true, bo */ function spl_autoload_unregister($callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \spl_autoload_unregister($callback); + restore_error_handler(); + if ($result === false) { - throw SplException::createFromPhpError(); + throw SplException::createFromPhpError($error); } } diff --git a/generated/sqlsrv.php b/generated/sqlsrv.php index e93aa37a..7199dd7b 100644 --- a/generated/sqlsrv.php +++ b/generated/sqlsrv.php @@ -20,10 +20,21 @@ */ function sqlsrv_begin_transaction($conn): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_begin_transaction($conn); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -42,10 +53,21 @@ function sqlsrv_begin_transaction($conn): void */ function sqlsrv_cancel($stmt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_cancel($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -89,10 +111,21 @@ function sqlsrv_cancel($stmt): void */ function sqlsrv_client_info($conn): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_client_info($conn); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -107,10 +140,21 @@ function sqlsrv_client_info($conn): array */ function sqlsrv_close($conn): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_close($conn); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -131,10 +175,21 @@ function sqlsrv_close($conn): void */ function sqlsrv_commit($conn): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_commit($conn); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -183,10 +238,21 @@ function sqlsrv_commit($conn): void */ function sqlsrv_configure(string $setting, $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_configure($setting, $value); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -202,10 +268,21 @@ function sqlsrv_configure(string $setting, $value): void */ function sqlsrv_execute($stmt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_execute($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -225,10 +302,21 @@ function sqlsrv_execute($stmt): void */ function sqlsrv_free_stmt($stmt): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_free_stmt($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } @@ -253,14 +341,25 @@ function sqlsrv_free_stmt($stmt): void */ function sqlsrv_get_field($stmt, int $fieldIndex, int $getAsType = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($getAsType !== null) { $result = \sqlsrv_get_field($stmt, $fieldIndex, $getAsType); } else { $result = \sqlsrv_get_field($stmt, $fieldIndex); } + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -278,10 +377,21 @@ function sqlsrv_get_field($stmt, int $fieldIndex, int $getAsType = null) */ function sqlsrv_next_result($stmt): ?bool { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_next_result($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -299,10 +409,21 @@ function sqlsrv_next_result($stmt): ?bool */ function sqlsrv_num_fields($stmt): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_num_fields($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -327,10 +448,21 @@ function sqlsrv_num_fields($stmt): int */ function sqlsrv_num_rows($stmt): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_num_rows($stmt); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -359,7 +491,16 @@ function sqlsrv_num_rows($stmt): int */ function sqlsrv_prepare($conn, string $sql, array $params = null, array $options = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \sqlsrv_prepare($conn, $sql, $params, $options); } elseif ($params !== null) { @@ -367,8 +508,10 @@ function sqlsrv_prepare($conn, string $sql, array $params = null, array $options } else { $result = \sqlsrv_prepare($conn, $sql); } + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -396,7 +539,16 @@ function sqlsrv_prepare($conn, string $sql, array $params = null, array $options */ function sqlsrv_query($conn, string $sql, array $params = null, array $options = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \sqlsrv_query($conn, $sql, $params, $options); } elseif ($params !== null) { @@ -404,8 +556,10 @@ function sqlsrv_query($conn, string $sql, array $params = null, array $options = } else { $result = \sqlsrv_query($conn, $sql); } + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } return $result; } @@ -421,9 +575,20 @@ function sqlsrv_query($conn, string $sql, array $params = null, array $options = */ function sqlsrv_rollback($conn): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sqlsrv_rollback($conn); + restore_error_handler(); + if ($result === false) { - throw SqlsrvException::createFromPhpError(); + throw SqlsrvException::createFromPhpError($error); } } diff --git a/generated/ssdeep.php b/generated/ssdeep.php index 662fc9b9..984ccace 100644 --- a/generated/ssdeep.php +++ b/generated/ssdeep.php @@ -18,10 +18,21 @@ */ function ssdeep_fuzzy_compare(string $signature1, string $signature2): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssdeep_fuzzy_compare($signature1, $signature2); + restore_error_handler(); + if ($result === false) { - throw SsdeepException::createFromPhpError(); + throw SsdeepException::createFromPhpError($error); } return $result; } @@ -40,10 +51,21 @@ function ssdeep_fuzzy_compare(string $signature1, string $signature2): int */ function ssdeep_fuzzy_hash_filename(string $file_name): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssdeep_fuzzy_hash_filename($file_name); + restore_error_handler(); + if ($result === false) { - throw SsdeepException::createFromPhpError(); + throw SsdeepException::createFromPhpError($error); } return $result; } @@ -61,10 +83,21 @@ function ssdeep_fuzzy_hash_filename(string $file_name): string */ function ssdeep_fuzzy_hash(string $to_hash): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssdeep_fuzzy_hash($to_hash); + restore_error_handler(); + if ($result === false) { - throw SsdeepException::createFromPhpError(); + throw SsdeepException::createFromPhpError($error); } return $result; } diff --git a/generated/ssh2.php b/generated/ssh2.php index fff3ceb6..2c347308 100644 --- a/generated/ssh2.php +++ b/generated/ssh2.php @@ -15,10 +15,21 @@ */ function ssh2_auth_agent($session, string $username): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_auth_agent($session, $username); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -41,7 +52,16 @@ function ssh2_auth_agent($session, string $username): void */ function ssh2_auth_hostbased_file($session, string $username, string $hostname, string $pubkeyfile, string $privkeyfile, string $passphrase = null, string $local_username = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($local_username !== null) { $result = \ssh2_auth_hostbased_file($session, $username, $hostname, $pubkeyfile, $privkeyfile, $passphrase, $local_username); } elseif ($passphrase !== null) { @@ -49,8 +69,10 @@ function ssh2_auth_hostbased_file($session, string $username, string $hostname, } else { $result = \ssh2_auth_hostbased_file($session, $username, $hostname, $pubkeyfile, $privkeyfile); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -68,10 +90,21 @@ function ssh2_auth_hostbased_file($session, string $username, string $hostname, */ function ssh2_auth_password($session, string $username, string $password): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_auth_password($session, $username, $password); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -93,14 +126,25 @@ function ssh2_auth_password($session, string $username, string $password): void */ function ssh2_auth_pubkey_file($session, string $username, string $pubkeyfile, string $privkeyfile, string $passphrase = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($passphrase !== null) { $result = \ssh2_auth_pubkey_file($session, $username, $pubkeyfile, $privkeyfile, $passphrase); } else { $result = \ssh2_auth_pubkey_file($session, $username, $pubkeyfile, $privkeyfile); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -306,7 +350,16 @@ function ssh2_auth_pubkey_file($session, string $username, string $pubkeyfile, s */ function ssh2_connect(string $host, int $port = 22, array $methods = null, array $callbacks = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callbacks !== null) { $result = \ssh2_connect($host, $port, $methods, $callbacks); } elseif ($methods !== null) { @@ -314,8 +367,10 @@ function ssh2_connect(string $host, int $port = 22, array $methods = null, array } else { $result = \ssh2_connect($host, $port); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -331,10 +386,21 @@ function ssh2_connect(string $host, int $port = 22, array $methods = null, array */ function ssh2_disconnect($session): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_disconnect($session); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -359,7 +425,16 @@ function ssh2_disconnect($session): void */ function ssh2_exec($session, string $command, string $pty = null, array $env = null, int $width = 80, int $height = 25, int $width_height_type = SSH2_TERM_UNIT_CHARS) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($width_height_type !== SSH2_TERM_UNIT_CHARS) { $result = \ssh2_exec($session, $command, $pty, $env, $width, $height, $width_height_type); } elseif ($height !== 25) { @@ -373,8 +448,10 @@ function ssh2_exec($session, string $command, string $pty = null, array $env = n } else { $result = \ssh2_exec($session, $command); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -390,10 +467,21 @@ function ssh2_exec($session, string $command, string $pty = null, array $env = n */ function ssh2_forward_accept($listener) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_forward_accept($listener); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -412,7 +500,16 @@ function ssh2_forward_accept($listener) */ function ssh2_forward_listen($session, int $port, string $host = null, int $max_connections = 16) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($max_connections !== 16) { $result = \ssh2_forward_listen($session, $port, $host, $max_connections); } elseif ($host !== null) { @@ -420,8 +517,10 @@ function ssh2_forward_listen($session, int $port, string $host = null, int $max_ } else { $result = \ssh2_forward_listen($session, $port); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -444,14 +543,25 @@ function ssh2_forward_listen($session, int $port, string $host = null, int $max_ */ function ssh2_publickey_add($pkey, string $algoname, string $blob, bool $overwrite = false, array $attributes = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($attributes !== null) { $result = \ssh2_publickey_add($pkey, $algoname, $blob, $overwrite, $attributes); } else { $result = \ssh2_publickey_add($pkey, $algoname, $blob, $overwrite); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -473,10 +583,21 @@ function ssh2_publickey_add($pkey, string $algoname, string $blob, bool $overwri */ function ssh2_publickey_init($session) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_publickey_init($session); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -493,10 +614,21 @@ function ssh2_publickey_init($session) */ function ssh2_publickey_remove($pkey, string $algoname, string $blob): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_publickey_remove($pkey, $algoname, $blob); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -513,10 +645,21 @@ function ssh2_publickey_remove($pkey, string $algoname, string $blob): void */ function ssh2_scp_recv($session, string $remote_file, string $local_file): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_scp_recv($session, $remote_file, $local_file); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -535,10 +678,21 @@ function ssh2_scp_recv($session, string $remote_file, string $local_file): void */ function ssh2_scp_send($session, string $local_file, string $remote_file, int $create_mode = 0644): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_scp_send($session, $local_file, $remote_file, $create_mode); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -556,10 +710,21 @@ function ssh2_scp_send($session, string $local_file, string $remote_file, int $c */ function ssh2_send_eof($channel): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_send_eof($channel); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -576,10 +741,21 @@ function ssh2_send_eof($channel): void */ function ssh2_sftp_chmod($sftp, string $filename, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_chmod($sftp, $filename, $mode); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -602,10 +778,21 @@ function ssh2_sftp_chmod($sftp, string $filename, int $mode): void */ function ssh2_sftp_mkdir($sftp, string $dirname, int $mode = 0777, bool $recursive = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_mkdir($sftp, $dirname, $mode, $recursive); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -621,10 +808,21 @@ function ssh2_sftp_mkdir($sftp, string $dirname, int $mode = 0777, bool $recursi */ function ssh2_sftp_rename($sftp, string $from, string $to): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_rename($sftp, $from, $to); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -642,10 +840,21 @@ function ssh2_sftp_rename($sftp, string $from, string $to): void */ function ssh2_sftp_rmdir($sftp, string $dirname): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_rmdir($sftp, $dirname); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -662,10 +871,21 @@ function ssh2_sftp_rmdir($sftp, string $dirname): void */ function ssh2_sftp_symlink($sftp, string $target, string $link): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_symlink($sftp, $target, $link); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -680,10 +900,21 @@ function ssh2_sftp_symlink($sftp, string $target, string $link): void */ function ssh2_sftp_unlink($sftp, string $filename): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp_unlink($sftp, $filename); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } } @@ -701,10 +932,21 @@ function ssh2_sftp_unlink($sftp, string $filename): void */ function ssh2_sftp($session) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \ssh2_sftp($session); + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } @@ -730,7 +972,16 @@ function ssh2_sftp($session) */ function ssh2_shell($session, string $term_type = "vanilla", array $env = null, int $width = 80, int $height = 25, int $width_height_type = SSH2_TERM_UNIT_CHARS) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($width_height_type !== SSH2_TERM_UNIT_CHARS) { $result = \ssh2_shell($session, $term_type, $env, $width, $height, $width_height_type); } elseif ($height !== 25) { @@ -742,8 +993,10 @@ function ssh2_shell($session, string $term_type = "vanilla", array $env = null, } else { $result = \ssh2_shell($session, $term_type); } + restore_error_handler(); + if ($result === false) { - throw Ssh2Exception::createFromPhpError(); + throw Ssh2Exception::createFromPhpError($error); } return $result; } diff --git a/generated/stream.php b/generated/stream.php index 3d086e14..6dd1ab44 100644 --- a/generated/stream.php +++ b/generated/stream.php @@ -15,10 +15,21 @@ */ function stream_context_set_params($context, array $params): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_context_set_params($context, $params); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -41,7 +52,16 @@ function stream_context_set_params($context, array $params): void */ function stream_copy_to_stream($from, $to, int $length = null, int $offset = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($offset !== 0) { $result = \stream_copy_to_stream($from, $to, $length, $offset); } elseif ($length !== null) { @@ -49,8 +69,10 @@ function stream_copy_to_stream($from, $to, int $length = null, int $offset = 0): } else { $result = \stream_copy_to_stream($from, $to); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -89,7 +111,16 @@ function stream_copy_to_stream($from, $to, int $length = null, int $offset = 0): */ function stream_filter_append($stream, string $filtername, int $read_write = null, array $params = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($params !== null) { $result = \stream_filter_append($stream, $filtername, $read_write, $params); } elseif ($read_write !== null) { @@ -97,8 +128,10 @@ function stream_filter_append($stream, string $filtername, int $read_write = nul } else { $result = \stream_filter_append($stream, $filtername); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -138,7 +171,16 @@ function stream_filter_append($stream, string $filtername, int $read_write = nul */ function stream_filter_prepend($stream, string $filtername, int $read_write = null, array $params = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($params !== null) { $result = \stream_filter_prepend($stream, $filtername, $read_write, $params); } elseif ($read_write !== null) { @@ -146,8 +188,10 @@ function stream_filter_prepend($stream, string $filtername, int $read_write = nu } else { $result = \stream_filter_prepend($stream, $filtername); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -173,10 +217,21 @@ function stream_filter_prepend($stream, string $filtername, int $read_write = nu */ function stream_filter_register(string $filter_name, string $class): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_filter_register($filter_name, $class); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -194,10 +249,21 @@ function stream_filter_register(string $filter_name, string $class): void */ function stream_filter_remove($stream_filter): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_filter_remove($stream_filter); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -220,7 +286,16 @@ function stream_filter_remove($stream_filter): void */ function stream_get_contents($stream, int $length = null, int $offset = -1): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($offset !== -1) { $result = \stream_get_contents($stream, $length, $offset); } elseif ($length !== null) { @@ -228,8 +303,10 @@ function stream_get_contents($stream, int $length = null, int $offset = -1): str } else { $result = \stream_get_contents($stream); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -260,10 +337,21 @@ function stream_get_contents($stream, int $length = null, int $offset = -1): str */ function stream_get_line($stream, int $length, string $ending = ""): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_get_line($stream, $length, $ending); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -279,10 +367,21 @@ function stream_get_line($stream, int $length, string $ending = ""): string */ function stream_isatty($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_isatty($stream); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -297,10 +396,21 @@ function stream_isatty($stream): void */ function stream_resolve_include_path(string $filename): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_resolve_include_path($filename); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -326,10 +436,21 @@ function stream_resolve_include_path(string $filename): string */ function stream_set_blocking($stream, bool $enable): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_set_blocking($stream, $enable); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -351,10 +472,21 @@ function stream_set_blocking($stream, bool $enable): void */ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_set_timeout($stream, $seconds, $microseconds); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -378,7 +510,16 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void */ function stream_socket_accept($socket, float $timeout = null, ?string &$peer_name = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($peer_name !== null) { $result = \stream_socket_accept($socket, $timeout, $peer_name); } elseif ($timeout !== null) { @@ -386,8 +527,10 @@ function stream_socket_accept($socket, float $timeout = null, ?string &$peer_nam } else { $result = \stream_socket_accept($socket); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -445,7 +588,16 @@ function stream_socket_accept($socket, float $timeout = null, ?string &$peer_nam */ function stream_socket_client(string $address, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags, $context); } elseif ($flags !== STREAM_CLIENT_CONNECT) { @@ -455,8 +607,10 @@ function stream_socket_client(string $address, ?int &$error_code = null, ?string } else { $result = \stream_socket_client($address, $error_code, $error_message); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -474,10 +628,21 @@ function stream_socket_client(string $address, ?int &$error_code = null, ?string */ function stream_socket_get_name($socket, bool $remote): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_socket_get_name($socket, $remote); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -508,10 +673,21 @@ function stream_socket_get_name($socket, bool $remote): string */ function stream_socket_pair(int $domain, int $type, int $protocol): iterable { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_socket_pair($domain, $type, $protocol); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -555,10 +731,21 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable */ function stream_socket_recvfrom($socket, int $length, int $flags = 0, ?string &$address = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_socket_recvfrom($socket, $length, $flags, $address); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -595,10 +782,21 @@ function stream_socket_recvfrom($socket, int $length, int $flags = 0, ?string &$ */ function stream_socket_sendto($socket, string $data, int $flags = 0, string $address = ""): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_socket_sendto($socket, $data, $flags, $address); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -648,14 +846,25 @@ function stream_socket_sendto($socket, string $data, int $flags = 0, string $add */ function stream_socket_server(string $address, ?int &$error_code = null, ?string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \stream_socket_server($address, $error_code, $error_message, $flags, $context); } else { $result = \stream_socket_server($address, $error_code, $error_message, $flags); } + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } return $result; } @@ -676,10 +885,21 @@ function stream_socket_server(string $address, ?int &$error_code = null, ?string */ function stream_socket_shutdown($stream, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_socket_shutdown($stream, $mode); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -694,10 +914,21 @@ function stream_socket_shutdown($stream, int $mode): void */ function stream_supports_lock($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_supports_lock($stream); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -718,10 +949,21 @@ function stream_supports_lock($stream): void */ function stream_wrapper_register(string $protocol, string $class, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_wrapper_register($protocol, $class, $flags); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -736,10 +978,21 @@ function stream_wrapper_register(string $protocol, string $class, int $flags = 0 */ function stream_wrapper_restore(string $protocol): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_wrapper_restore($protocol); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } @@ -756,9 +1009,20 @@ function stream_wrapper_restore(string $protocol): void */ function stream_wrapper_unregister(string $protocol): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \stream_wrapper_unregister($protocol); + restore_error_handler(); + if ($result === false) { - throw StreamException::createFromPhpError(); + throw StreamException::createFromPhpError($error); } } diff --git a/generated/strings.php b/generated/strings.php index 2aa72339..8482007f 100644 --- a/generated/strings.php +++ b/generated/strings.php @@ -14,10 +14,21 @@ */ function convert_uudecode(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \convert_uudecode($string); + restore_error_handler(); + if ($result === false) { - throw StringsException::createFromPhpError(); + throw StringsException::createFromPhpError($error); } return $result; } @@ -33,10 +44,21 @@ function convert_uudecode(string $string): string */ function hex2bin(string $string): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \hex2bin($string); + restore_error_handler(); + if ($result === false) { - throw StringsException::createFromPhpError(); + throw StringsException::createFromPhpError($error); } return $result; } @@ -58,10 +80,21 @@ function hex2bin(string $string): string */ function md5_file(string $filename, bool $binary = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \md5_file($filename, $binary); + restore_error_handler(); + if ($result === false) { - throw StringsException::createFromPhpError(); + throw StringsException::createFromPhpError($error); } return $result; } @@ -79,10 +112,21 @@ function md5_file(string $filename, bool $binary = false): string */ function sha1_file(string $filename, bool $binary = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sha1_file($filename, $binary); + restore_error_handler(); + if ($result === false) { - throw StringsException::createFromPhpError(); + throw StringsException::createFromPhpError($error); } return $result; } diff --git a/generated/swoole.php b/generated/swoole.php index a9c3ff3e..bfb86a8f 100644 --- a/generated/swoole.php +++ b/generated/swoole.php @@ -16,10 +16,21 @@ */ function swoole_async_dns_lookup(string $hostname, callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \swoole_async_dns_lookup($hostname, $callback); + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -36,10 +47,21 @@ function swoole_async_dns_lookup(string $hostname, callable $callback): void */ function swoole_async_readfile(string $filename, string $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \swoole_async_readfile($filename, $callback); + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -56,7 +78,16 @@ function swoole_async_readfile(string $filename, string $callback): void */ function swoole_async_write(string $filename, string $content, int $offset = null, callable $callback = null): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callback !== null) { $result = \swoole_async_write($filename, $content, $offset, $callback); } elseif ($offset !== null) { @@ -64,8 +95,10 @@ function swoole_async_write(string $filename, string $content, int $offset = nul } else { $result = \swoole_async_write($filename, $content); } + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -82,7 +115,16 @@ function swoole_async_write(string $filename, string $content, int $offset = nul */ function swoole_async_writefile(string $filename, string $content, callable $callback = null, int $flags = 0): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($flags !== 0) { $result = \swoole_async_writefile($filename, $content, $callback, $flags); } elseif ($callback !== null) { @@ -90,8 +132,10 @@ function swoole_async_writefile(string $filename, string $content, callable $cal } else { $result = \swoole_async_writefile($filename, $content); } + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -105,10 +149,21 @@ function swoole_async_writefile(string $filename, string $content, callable $cal */ function swoole_event_defer(callable $callback): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \swoole_event_defer($callback); + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -122,10 +177,21 @@ function swoole_event_defer(callable $callback): void */ function swoole_event_del(int $fd): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \swoole_event_del($fd); + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } @@ -140,9 +206,20 @@ function swoole_event_del(int $fd): void */ function swoole_event_write(int $fd, string $data): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \swoole_event_write($fd, $data); + restore_error_handler(); + if ($result === false) { - throw SwooleException::createFromPhpError(); + throw SwooleException::createFromPhpError($error); } } diff --git a/generated/uodbc.php b/generated/uodbc.php index 6ac914bd..e96ba1c4 100644 --- a/generated/uodbc.php +++ b/generated/uodbc.php @@ -26,10 +26,21 @@ */ function odbc_autocommit($odbc, bool $enable = false) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_autocommit($odbc, $enable); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -136,10 +147,21 @@ function odbc_autocommit($odbc, bool $enable = false) */ function odbc_binmode(int $statement, int $mode): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_binmode($statement, $mode); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -183,10 +205,21 @@ function odbc_binmode(int $statement, int $mode): void */ function odbc_columnprivileges($odbc, string $catalog, string $schema, string $table, string $column) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_columnprivileges($odbc, $catalog, $schema, $table, $column); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -239,7 +272,16 @@ function odbc_columnprivileges($odbc, string $catalog, string $schema, string $t */ function odbc_columns($odbc, string $catalog = null, string $schema = null, string $table = null, string $column = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($column !== null) { $result = \odbc_columns($odbc, $catalog, $schema, $table, $column); } elseif ($table !== null) { @@ -251,8 +293,10 @@ function odbc_columns($odbc, string $catalog = null, string $schema = null, stri } else { $result = \odbc_columns($odbc); } + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -268,10 +312,21 @@ function odbc_columns($odbc, string $catalog = null, string $schema = null, stri */ function odbc_commit($odbc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_commit($odbc); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -310,10 +365,21 @@ function odbc_commit($odbc): void */ function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_connect($dsn, $user, $password, $cursor_option); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -329,10 +395,21 @@ function odbc_connect(string $dsn, string $user, string $password, int $cursor_o */ function odbc_cursor($statement): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_cursor($statement); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -355,10 +432,21 @@ function odbc_cursor($statement): string */ function odbc_data_source($odbc, int $fetch_type): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_data_source($odbc, $fetch_type); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -377,10 +465,21 @@ function odbc_data_source($odbc, int $fetch_type): array */ function odbc_exec($odbc, string $query) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_exec($odbc, $query); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -404,10 +503,21 @@ function odbc_exec($odbc, string $query) */ function odbc_execute($statement, array $params = []): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_execute($statement, $params); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -428,10 +538,21 @@ function odbc_execute($statement, array $params = []): void */ function odbc_fetch_into($statement, ?array &$array, int $row = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_fetch_into($statement, $array, $row); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -449,10 +570,21 @@ function odbc_fetch_into($statement, ?array &$array, int $row = 0): int */ function odbc_field_len($statement, int $field): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_field_len($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -470,10 +602,21 @@ function odbc_field_len($statement, int $field): int */ function odbc_field_name($statement, int $field): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_field_name($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -492,10 +635,21 @@ function odbc_field_name($statement, int $field): string */ function odbc_field_num($statement, string $field): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_field_num($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -513,10 +667,21 @@ function odbc_field_num($statement, string $field): int */ function odbc_field_scale($statement, int $field): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_field_scale($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -534,10 +699,21 @@ function odbc_field_scale($statement, int $field): int */ function odbc_field_type($statement, int $field): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_field_type($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -581,10 +757,21 @@ function odbc_field_type($statement, int $field): string */ function odbc_foreignkeys($odbc, string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_foreignkeys($odbc, $pk_catalog, $pk_schema, $pk_table, $fk_catalog, $fk_schema, $fk_table); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -624,10 +811,21 @@ function odbc_foreignkeys($odbc, string $pk_catalog, string $pk_schema, string $ */ function odbc_gettypeinfo($odbc, int $data_type = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_gettypeinfo($odbc, $data_type); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -647,10 +845,21 @@ function odbc_gettypeinfo($odbc, int $data_type = 0) */ function odbc_longreadlen($statement, int $length): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_longreadlen($statement, $length); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -678,10 +887,21 @@ function odbc_longreadlen($statement, int $length): void */ function odbc_pconnect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_pconnect($dsn, $user, $password, $cursor_option); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -706,10 +926,21 @@ function odbc_pconnect(string $dsn, string $user, string $password, int $cursor_ */ function odbc_prepare($odbc, string $query) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_prepare($odbc, $query); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -741,10 +972,21 @@ function odbc_prepare($odbc, string $query) */ function odbc_primarykeys($odbc, string $catalog, string $schema, string $table) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_primarykeys($odbc, $catalog, $schema, $table); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -800,7 +1042,16 @@ function odbc_primarykeys($odbc, string $catalog, string $schema, string $table) */ function odbc_procedurecolumns($odbc, string $catalog = null, string $schema = null, string $procedure = null, string $column = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($column !== null) { $result = \odbc_procedurecolumns($odbc, $catalog, $schema, $procedure, $column); } elseif ($procedure !== null) { @@ -812,8 +1063,10 @@ function odbc_procedurecolumns($odbc, string $catalog = null, string $schema = n } else { $result = \odbc_procedurecolumns($odbc); } + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -853,7 +1106,16 @@ function odbc_procedurecolumns($odbc, string $catalog = null, string $schema = n */ function odbc_procedures($odbc, string $catalog = null, string $schema = null, string $procedure = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($procedure !== null) { $result = \odbc_procedures($odbc, $catalog, $schema, $procedure); } elseif ($schema !== null) { @@ -863,8 +1125,10 @@ function odbc_procedures($odbc, string $catalog = null, string $schema = null, s } else { $result = \odbc_procedures($odbc); } + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -886,10 +1150,21 @@ function odbc_procedures($odbc, string $catalog = null, string $schema = null, s */ function odbc_result_all($statement, string $format = ""): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_result_all($statement, $format); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -909,10 +1184,21 @@ function odbc_result_all($statement, string $format = ""): int */ function odbc_result($statement, $field) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_result($statement, $field); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -928,10 +1214,21 @@ function odbc_result($statement, $field) */ function odbc_rollback($odbc): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_rollback($odbc); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -968,10 +1265,21 @@ function odbc_rollback($odbc): void */ function odbc_setoption($odbc, int $which, int $option, int $value): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_setoption($odbc, $which, $option, $value); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } } @@ -1011,10 +1319,21 @@ function odbc_setoption($odbc, int $which, int $option, int $value): void */ function odbc_specialcolumns($odbc, int $type, string $catalog, string $schema, string $table, int $scope, int $nullable) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_specialcolumns($odbc, $type, $catalog, $schema, $table, $scope, $nullable); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -1057,10 +1376,21 @@ function odbc_specialcolumns($odbc, int $type, string $catalog, string $schema, */ function odbc_statistics($odbc, string $catalog, string $schema, string $table, int $unique, int $accuracy) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_statistics($odbc, $catalog, $schema, $table, $unique, $accuracy); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -1099,10 +1429,21 @@ function odbc_statistics($odbc, string $catalog, string $schema, string $table, */ function odbc_tableprivileges($odbc, string $catalog, string $schema, string $table) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \odbc_tableprivileges($odbc, $catalog, $schema, $table); + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } @@ -1183,7 +1524,16 @@ function odbc_tableprivileges($odbc, string $catalog, string $schema, string $ta */ function odbc_tables($odbc, string $catalog = null, string $schema = null, string $table = null, string $types = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($types !== null) { $result = \odbc_tables($odbc, $catalog, $schema, $table, $types); } elseif ($table !== null) { @@ -1195,8 +1545,10 @@ function odbc_tables($odbc, string $catalog = null, string $schema = null, strin } else { $result = \odbc_tables($odbc); } + restore_error_handler(); + if ($result === false) { - throw UodbcException::createFromPhpError(); + throw UodbcException::createFromPhpError($error); } return $result; } diff --git a/generated/uopz.php b/generated/uopz.php index ae0ee8f8..40949b0c 100644 --- a/generated/uopz.php +++ b/generated/uopz.php @@ -14,10 +14,21 @@ */ function uopz_extend(string $class, string $parent): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \uopz_extend($class, $parent); + restore_error_handler(); + if ($result === false) { - throw UopzException::createFromPhpError(); + throw UopzException::createFromPhpError($error); } } @@ -32,9 +43,20 @@ function uopz_extend(string $class, string $parent): void */ function uopz_implement(string $class, string $interface): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \uopz_implement($class, $interface); + restore_error_handler(); + if ($result === false) { - throw UopzException::createFromPhpError(); + throw UopzException::createFromPhpError($error); } } diff --git a/generated/url.php b/generated/url.php index ad5bb175..fb030fef 100644 --- a/generated/url.php +++ b/generated/url.php @@ -19,10 +19,21 @@ */ function base64_decode(string $string, bool $strict = false): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \base64_decode($string, $strict); + restore_error_handler(); + if ($result === false) { - throw UrlException::createFromPhpError(); + throw UrlException::createFromPhpError($error); } return $result; } @@ -45,14 +56,25 @@ function base64_decode(string $string, bool $strict = false): string */ function get_headers(string $url, bool $associative = false, $context = null): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($context !== null) { $result = \get_headers($url, $associative, $context); } else { $result = \get_headers($url, $associative); } + restore_error_handler(); + if ($result === false) { - throw UrlException::createFromPhpError(); + throw UrlException::createFromPhpError($error); } return $result; } @@ -98,10 +120,21 @@ function get_headers(string $url, bool $associative = false, $context = null): a */ function get_meta_tags(string $filename, bool $use_include_path = false): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \get_meta_tags($filename, $use_include_path); + restore_error_handler(); + if ($result === false) { - throw UrlException::createFromPhpError(); + throw UrlException::createFromPhpError($error); } return $result; } @@ -197,10 +230,21 @@ function get_meta_tags(string $filename, bool $use_include_path = false): array */ function parse_url(string $url, int $component = -1) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \parse_url($url, $component); + restore_error_handler(); + if ($result === false) { - throw UrlException::createFromPhpError(); + throw UrlException::createFromPhpError($error); } return $result; } diff --git a/generated/var.php b/generated/var.php index 14609f22..fc19b826 100644 --- a/generated/var.php +++ b/generated/var.php @@ -52,9 +52,20 @@ */ function settype(&$var, string $type): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \settype($var, $type); + restore_error_handler(); + if ($result === false) { - throw VarException::createFromPhpError(); + throw VarException::createFromPhpError($error); } } diff --git a/generated/xdiff.php b/generated/xdiff.php index 27feef39..a8a5ad8f 100644 --- a/generated/xdiff.php +++ b/generated/xdiff.php @@ -18,10 +18,21 @@ */ function xdiff_file_bdiff(string $old_file, string $new_file, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_bdiff($old_file, $new_file, $dest); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -40,10 +51,21 @@ function xdiff_file_bdiff(string $old_file, string $new_file, string $dest): voi */ function xdiff_file_bpatch(string $file, string $patch, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_bpatch($file, $patch, $dest); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -64,10 +86,21 @@ function xdiff_file_bpatch(string $file, string $patch, string $dest): void */ function xdiff_file_diff_binary(string $old_file, string $new_file, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_diff_binary($old_file, $new_file, $dest); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -92,10 +125,21 @@ function xdiff_file_diff_binary(string $old_file, string $new_file, string $dest */ function xdiff_file_diff(string $old_file, string $new_file, string $dest, int $context = 3, bool $minimal = false): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_diff($old_file, $new_file, $dest, $context, $minimal); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -116,10 +160,21 @@ function xdiff_file_diff(string $old_file, string $new_file, string $dest, int $ */ function xdiff_file_patch_binary(string $file, string $patch, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_patch_binary($file, $patch, $dest); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -143,10 +198,21 @@ function xdiff_file_patch_binary(string $file, string $patch, string $dest): voi */ function xdiff_file_rabdiff(string $old_file, string $new_file, string $dest): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_file_rabdiff($old_file, $new_file, $dest); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } } @@ -164,10 +230,21 @@ function xdiff_file_rabdiff(string $old_file, string $new_file, string $dest): v */ function xdiff_string_bpatch(string $str, string $patch): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_string_bpatch($str, $patch); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } return $result; } @@ -188,10 +265,21 @@ function xdiff_string_bpatch(string $str, string $patch): string */ function xdiff_string_patch_binary(string $str, string $patch): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xdiff_string_patch_binary($str, $patch); + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } return $result; } @@ -221,7 +309,16 @@ function xdiff_string_patch_binary(string $str, string $patch): string */ function xdiff_string_patch(string $str, string $patch, int $flags = null, ?string &$error = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($error !== null) { $result = \xdiff_string_patch($str, $patch, $flags, $error); } elseif ($flags !== null) { @@ -229,8 +326,10 @@ function xdiff_string_patch(string $str, string $patch, int $flags = null, ?stri } else { $result = \xdiff_string_patch($str, $patch); } + restore_error_handler(); + if ($result === false) { - throw XdiffException::createFromPhpError(); + throw XdiffException::createFromPhpError($error); } return $result; } diff --git a/generated/xml.php b/generated/xml.php index 6f2679dd..7c744151 100644 --- a/generated/xml.php +++ b/generated/xml.php @@ -13,10 +13,21 @@ */ function xml_parser_free($parser): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_parser_free($parser); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -69,10 +80,21 @@ function xml_parser_free($parser): void */ function xml_set_character_data_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_character_data_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -127,10 +149,21 @@ function xml_set_character_data_handler($parser, callable $handler): void */ function xml_set_default_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_default_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -197,10 +230,21 @@ function xml_set_default_handler($parser, callable $handler): void */ function xml_set_element_handler($parser, callable $start_handler, callable $end_handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_element_handler($parser, $start_handler, $end_handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -254,10 +298,21 @@ function xml_set_element_handler($parser, callable $start_handler, callable $end */ function xml_set_end_namespace_decl_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_end_namespace_decl_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -346,10 +401,21 @@ function xml_set_end_namespace_decl_handler($parser, callable $handler): void */ function xml_set_external_entity_ref_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_external_entity_ref_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -443,10 +509,21 @@ function xml_set_external_entity_ref_handler($parser, callable $handler): void */ function xml_set_notation_decl_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_notation_decl_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -464,10 +541,21 @@ function xml_set_notation_decl_handler($parser, callable $handler): void */ function xml_set_object($parser, object $object): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_object($parser, $object); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -538,10 +626,21 @@ function xml_set_object($parser, object $object): void */ function xml_set_processing_instruction_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_processing_instruction_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -604,10 +703,21 @@ function xml_set_processing_instruction_handler($parser, callable $handler): voi */ function xml_set_start_namespace_decl_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_start_namespace_decl_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } @@ -708,9 +818,20 @@ function xml_set_start_namespace_decl_handler($parser, callable $handler): void */ function xml_set_unparsed_entity_decl_handler($parser, callable $handler): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xml_set_unparsed_entity_decl_handler($parser, $handler); + restore_error_handler(); + if ($result === false) { - throw XmlException::createFromPhpError(); + throw XmlException::createFromPhpError($error); } } diff --git a/generated/xmlrpc.php b/generated/xmlrpc.php index 15364fb4..92543315 100644 --- a/generated/xmlrpc.php +++ b/generated/xmlrpc.php @@ -14,9 +14,20 @@ */ function xmlrpc_set_type(&$value, string $type): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \xmlrpc_set_type($value, $type); + restore_error_handler(); + if ($result === false) { - throw XmlrpcException::createFromPhpError(); + throw XmlrpcException::createFromPhpError($error); } } diff --git a/generated/yaml.php b/generated/yaml.php index fd297aad..b3cd94ea 100644 --- a/generated/yaml.php +++ b/generated/yaml.php @@ -25,14 +25,25 @@ */ function yaml_parse_file(string $filename, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callbacks !== null) { $result = \yaml_parse_file($filename, $pos, $ndocs, $callbacks); } else { $result = \yaml_parse_file($filename, $pos, $ndocs); } + restore_error_handler(); + if ($result === false) { - throw YamlException::createFromPhpError(); + throw YamlException::createFromPhpError($error); } return $result; } @@ -62,14 +73,25 @@ function yaml_parse_file(string $filename, int $pos = 0, ?int &$ndocs = null, ar */ function yaml_parse_url(string $url, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callbacks !== null) { $result = \yaml_parse_url($url, $pos, $ndocs, $callbacks); } else { $result = \yaml_parse_url($url, $pos, $ndocs); } + restore_error_handler(); + if ($result === false) { - throw YamlException::createFromPhpError(); + throw YamlException::createFromPhpError($error); } return $result; } @@ -96,14 +118,25 @@ function yaml_parse_url(string $url, int $pos = 0, ?int &$ndocs = null, array $c */ function yaml_parse(string $input, int $pos = 0, ?int &$ndocs = null, array $callbacks = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($callbacks !== null) { $result = \yaml_parse($input, $pos, $ndocs, $callbacks); } else { $result = \yaml_parse($input, $pos, $ndocs); } + restore_error_handler(); + if ($result === false) { - throw YamlException::createFromPhpError(); + throw YamlException::createFromPhpError($error); } return $result; } diff --git a/generated/yaz.php b/generated/yaz.php index 29c1d33c..ae12bb5b 100644 --- a/generated/yaz.php +++ b/generated/yaz.php @@ -49,10 +49,21 @@ */ function yaz_ccl_parse($id, string $query, ?array &$result): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_ccl_parse($id, $query, $result); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -66,10 +77,21 @@ function yaz_ccl_parse($id, string $query, ?array &$result): void */ function yaz_close($id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_close($id); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -267,14 +289,25 @@ function yaz_close($id): void */ function yaz_connect(string $zurl, $options = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($options !== null) { $result = \yaz_connect($zurl, $options); } else { $result = \yaz_connect($zurl); } + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } return $result; } @@ -294,10 +327,21 @@ function yaz_connect(string $zurl, $options = null) */ function yaz_database($id, string $databases): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_database($id, $databases); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -317,10 +361,21 @@ function yaz_database($id, string $databases): void */ function yaz_element($id, string $elementset): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_element($id, $elementset); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -337,10 +392,21 @@ function yaz_element($id, string $elementset): void */ function yaz_present($id): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_present($id); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -377,10 +443,21 @@ function yaz_present($id): void */ function yaz_search($id, string $type, string $query): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_search($id, $type, $query); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } } @@ -429,10 +506,21 @@ function yaz_search($id, string $type, string $query): void */ function yaz_wait(array &$options = null) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \yaz_wait($options); + restore_error_handler(); + if ($result === false) { - throw YazException::createFromPhpError(); + throw YazException::createFromPhpError($error); } return $result; } diff --git a/generated/zip.php b/generated/zip.php index d4097eb1..b8b68fea 100644 --- a/generated/zip.php +++ b/generated/zip.php @@ -13,10 +13,21 @@ */ function zip_entry_close($zip_entry): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_close($zip_entry); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } } @@ -31,10 +42,21 @@ function zip_entry_close($zip_entry): void */ function zip_entry_compressedsize($zip_entry): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_compressedsize($zip_entry); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } return $result; } @@ -51,10 +73,21 @@ function zip_entry_compressedsize($zip_entry): int */ function zip_entry_compressionmethod($zip_entry): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_compressionmethod($zip_entry); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } return $result; } @@ -70,10 +103,21 @@ function zip_entry_compressionmethod($zip_entry): string */ function zip_entry_filesize($zip_entry): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_filesize($zip_entry); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } return $result; } @@ -89,10 +133,21 @@ function zip_entry_filesize($zip_entry): int */ function zip_entry_name($zip_entry): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_name($zip_entry); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } return $result; } @@ -114,10 +169,21 @@ function zip_entry_name($zip_entry): string */ function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_open($zip_dp, $zip_entry, $mode); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } } @@ -135,10 +201,21 @@ function zip_entry_open($zip_dp, $zip_entry, string $mode = "rb"): void */ function zip_entry_read($zip_entry, int $len = 1024): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zip_entry_read($zip_entry, $len); + restore_error_handler(); + if ($result === false) { - throw ZipException::createFromPhpError(); + throw ZipException::createFromPhpError($error); } return $result; } diff --git a/generated/zlib.php b/generated/zlib.php index 39dc8985..0d818cd1 100644 --- a/generated/zlib.php +++ b/generated/zlib.php @@ -24,10 +24,21 @@ */ function deflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \deflate_add($context, $data, $flush_mode); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -125,10 +136,21 @@ function deflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): */ function deflate_init(int $encoding, array $options = []) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \deflate_init($encoding, $options); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -144,10 +166,21 @@ function deflate_init(int $encoding, array $options = []) */ function gzclose($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzclose($stream); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } } @@ -172,10 +205,21 @@ function gzclose($stream): void */ function gzcompress(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_DEFLATE): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzcompress($data, $level, $encoding); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -193,10 +237,21 @@ function gzcompress(string $data, int $level = -1, int $encoding = ZLIB_ENCODING */ function gzdecode(string $data, int $max_length = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzdecode($data, $max_length); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -221,10 +276,21 @@ function gzdecode(string $data, int $max_length = 0): string */ function gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_RAW): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzdeflate($data, $level, $encoding); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -255,10 +321,21 @@ function gzdeflate(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_ */ function gzencode(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_GZIP): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzencode($data, $level, $encoding); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -277,10 +354,21 @@ function gzencode(string $data, int $level = -1, int $encoding = ZLIB_ENCODING_G */ function gzfile(string $filename, int $use_include_path = 0): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzfile($filename, $use_include_path); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -300,14 +388,25 @@ function gzfile(string $filename, int $use_include_path = 0): array */ function gzgets($stream, int $length = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \gzgets($stream, $length); } else { $result = \gzgets($stream); } + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -329,14 +428,25 @@ function gzgets($stream, int $length = null): string */ function gzgetss($zp, int $length, string $allowable_tags = null): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($allowable_tags !== null) { $result = \gzgetss($zp, $length, $allowable_tags); } else { $result = \gzgetss($zp, $length); } + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -357,10 +467,21 @@ function gzgetss($zp, int $length, string $allowable_tags = null): string */ function gzinflate(string $data, int $max_length = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzinflate($data, $max_length); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -394,10 +515,21 @@ function gzinflate(string $data, int $max_length = 0): string */ function gzopen(string $filename, string $mode, int $use_include_path = 0) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzopen($filename, $mode, $use_include_path); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -416,10 +548,21 @@ function gzopen(string $filename, string $mode, int $use_include_path = 0) */ function gzpassthru($stream): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzpassthru($stream); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -440,10 +583,21 @@ function gzpassthru($stream): int */ function gzread($stream, int $length): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzread($stream, $length); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -460,10 +614,21 @@ function gzread($stream, int $length): string */ function gzrewind($stream): void { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzrewind($stream); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } } @@ -483,10 +648,21 @@ function gzrewind($stream): void */ function gzuncompress(string $data, int $max_length = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \gzuncompress($data, $max_length); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -510,14 +686,25 @@ function gzuncompress(string $data, int $max_length = 0): string */ function gzwrite($stream, string $data, int $length = null): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if ($length !== null) { $result = \gzwrite($stream, $data, $length); } else { $result = \gzwrite($stream, $data); } + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -533,10 +720,21 @@ function gzwrite($stream, string $data, int $length = null): int */ function inflate_get_read_len($context): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inflate_get_read_len($context); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -552,10 +750,21 @@ function inflate_get_read_len($context): int */ function inflate_get_status($context): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inflate_get_status($context); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -584,10 +793,21 @@ function inflate_get_status($context): int */ function inflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inflate_add($context, $data, $flush_mode); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -666,10 +886,21 @@ function inflate_add($context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): */ function inflate_init(int $encoding, array $options = []) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \inflate_init($encoding, $options); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -692,10 +923,21 @@ function inflate_init(int $encoding, array $options = []) */ function readgzfile(string $filename, int $use_include_path = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \readgzfile($filename, $use_include_path); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } @@ -712,10 +954,21 @@ function readgzfile(string $filename, int $use_include_path = 0): int */ function zlib_decode(string $data, int $max_length = 0): string { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \zlib_decode($data, $max_length); + restore_error_handler(); + if ($result === false) { - throw ZlibException::createFromPhpError(); + throw ZlibException::createFromPhpError($error); } return $result; } diff --git a/generator/src/FileCreator.php b/generator/src/FileCreator.php index d7f5dbae..76694c1e 100644 --- a/generator/src/FileCreator.php +++ b/generator/src/FileCreator.php @@ -135,10 +135,20 @@ public function createExceptionFile(string $moduleName): void class {$exceptionName} extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} \$error + * @return \Safe\Exceptions\{$exceptionName} + */ + 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__, + ); } } diff --git a/generator/src/WritePhpFunction.php b/generator/src/WritePhpFunction.php index 3a9fe236..26ef7672 100644 --- a/generator/src/WritePhpFunction.php +++ b/generator/src/WritePhpFunction.php @@ -53,9 +53,30 @@ private function writePhpFunction(): string $moduleName = $this->method->getModuleName(); $phpFunction .= "function {$this->method->getFunctionName()}({$this->displayParamsWithType($this->method->getParams())}){$returnType} -{ - error_clear_last(); -"; +{"; + + $includeErrorHandler = true; + // Certain methods from curl don't need the custom error handler + if ($moduleName !== 'Curl') { + $params = $this->method->getParams(); + if (\count($params) > 0 && in_array($params[0]->getParameter(), ['handle', 'multi_handle', 'share_handle'])) { + $includeErrorHandler = false; + } + } + + if ($includeErrorHandler) { + $phpFunction .= " + \$error = []; + set_error_handler( function(int \$errno, string \$errstr, string \$errfile, int \$errline) use (&\$error) { + \$error = [ + 'type' => \$errno, + 'message' => \$errstr, + 'file' => \$errfile, + 'line' => \$errline, + ]; + return false; + });\n"; + } if (!$this->method->isOverloaded()) { $phpFunction .= ' $result = '.$this->printFunctionCall($this->method); @@ -88,6 +109,7 @@ private function writePhpFunction(): string $phpFunction .= ' $result = '.$this->printFunctionCall($method)."\n"; $phpFunction .= ' }'; } + $phpFunction .= "\n restore_error_handler();\n"; $phpFunction .= $this->generateExceptionCode($moduleName, $this->method).$returnStatement. '} '; @@ -110,23 +132,36 @@ private function generateExceptionCode(string $moduleName, Method $method) : str default: throw new \LogicException("Method doesn't have an error type"); } - // Special case for CURL: we need the first argument of the method if this is a resource. if ($moduleName === 'Curl') { $params = $method->getParams(); - if (\count($params) > 0 && $params[0]->getParameter() === 'ch') { - return " + if (\count($params) > 0) { + if ($params[0]->getParameter() === 'handle') { + return " if (\$result === $errorValue) { - throw CurlException::createFromCurlResource(\$ch); + throw CurlException::createFromCurlHandle(\$handle); } "; + } elseif ($params[0]->getParameter() === 'multi_handle') { + return " + if (\$result === $errorValue) { + throw CurlException::createFromCurlMultiHandle(\$multi_handle); + } +"; + } elseif ($params[0]->getParameter() === 'share_handle') { + return " + if (\$result === $errorValue) { + throw CurlException::createFromCurlShareHandle(\$share_handle); + } +"; + } } } $exceptionName = FileCreator::toExceptionName($moduleName); return " if (\$result === $errorValue) { - throw {$exceptionName}::createFromPhpError(); + throw {$exceptionName}::createFromPhpError(\$error); } "; } diff --git a/generator/tests/SpecialCasesTest.php b/generator/tests/SpecialCasesTest.php index c90a7343..9f14ee14 100644 --- a/generator/tests/SpecialCasesTest.php +++ b/generator/tests/SpecialCasesTest.php @@ -15,7 +15,7 @@ public function testPregReplace() require_once __DIR__.'/../../lib/Exceptions/PcreException.php'; $this->expectException(PcreException::class); - $this->expectExceptionMessage('PREG_BAD_UTF8_ERROR: Invalid UTF8 character'); + $this->expectExceptionMessage('PREG_BAD_UTF8_ERROR: Malformed UTF-8 characters, possibly incorrectly encoded'); preg_replace("/([\s,]+)/u", "foo", "\xc3\x28"); } } diff --git a/lib/DateTime.php b/lib/DateTime.php index 56eb809f..b29afb7a 100644 --- a/lib/DateTime.php +++ b/lib/DateTime.php @@ -24,9 +24,20 @@ private static function createFromRegular(\DateTime $datetime): self */ public static function createFromFormat($format, $time, $timezone = null): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $datetime = \DateTime::createFromFormat($format, $time, $timezone); + restore_error_handler(); if ($datetime === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($datetime); } @@ -39,10 +50,21 @@ public static function createFromFormat($format, $time, $timezone = null): self */ public function diff($datetime2, $absolute = false): DateInterval { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateInterval|false $result */ $result = parent::diff($datetime2, $absolute); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -54,10 +76,21 @@ public function diff($datetime2, $absolute = false): DateInterval */ public function modify($modify): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var DateTime|false $result */ $result = parent::modify($modify); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -71,10 +104,21 @@ public function modify($modify): self */ public function setDate($year, $month, $day): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var DateTime|false $result */ $result = parent::setDate($year, $month, $day); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } diff --git a/lib/DateTimeImmutable.php b/lib/DateTimeImmutable.php index 5cedd24a..78077f3b 100644 --- a/lib/DateTimeImmutable.php +++ b/lib/DateTimeImmutable.php @@ -53,9 +53,20 @@ public function getInnerDateTime(): \DateTimeImmutable */ public static function createFromFormat($format, $time, $timezone = null): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $datetime = \DateTimeImmutable::createFromFormat($format, $time, $timezone); + restore_error_handler(); if ($datetime === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($datetime); } @@ -67,10 +78,21 @@ public static function createFromFormat($format, $time, $timezone = null): self */ public function format($format): string { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var string|false $result */ $result = $this->innerDateTime->format($format); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -83,10 +105,21 @@ public function format($format): string */ public function diff($datetime2, $absolute = false): \DateInterval { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateInterval|false $result */ $result = $this->innerDateTime->diff($datetime2, $absolute); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } @@ -98,10 +131,21 @@ public function diff($datetime2, $absolute = false): \DateInterval */ public function modify($modify): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->modify($modify); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable } @@ -115,10 +159,21 @@ public function modify($modify): self */ public function setDate($year, $month, $day): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->setDate($year, $month, $day); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable } @@ -132,10 +187,21 @@ public function setDate($year, $month, $day): self */ public function setISODate($year, $week, $day = 1): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->setISODate($year, $week, $day); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); //we have to recreate a safe datetime because modify create a new instance of \DateTimeImmutable } @@ -150,10 +216,21 @@ public function setISODate($year, $week, $day = 1): self */ public function setTime($hour, $minute, $second = 0, $microseconds = 0): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->setTime($hour, $minute, $second, $microseconds); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); } @@ -165,10 +242,21 @@ public function setTime($hour, $minute, $second = 0, $microseconds = 0): self */ public function setTimestamp($unixtimestamp): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->setTimestamp($unixtimestamp); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); } @@ -180,10 +268,21 @@ public function setTimestamp($unixtimestamp): self */ public function setTimezone($timezone): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->setTimezone($timezone); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); } @@ -195,10 +294,21 @@ public function setTimezone($timezone): self */ public function sub($interval): self { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var \DateTimeImmutable|false $result */ $result = $this->innerDateTime->sub($interval); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return self::createFromRegular($result); } @@ -208,10 +318,21 @@ public function sub($interval): self */ public function getOffset(): int { + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); /** @var int|false $result */ $result = $this->innerDateTime->getOffset(); + restore_error_handler(); if ($result === false) { - throw DatetimeException::createFromPhpError(); + throw DatetimeException::createFromPhpError($error); } return $result; } diff --git a/lib/Exceptions/CurlException.php b/lib/Exceptions/CurlException.php index d0dbdb69..7060ec82 100644 --- a/lib/Exceptions/CurlException.php +++ b/lib/Exceptions/CurlException.php @@ -3,13 +3,39 @@ namespace Safe\Exceptions; +use CurlHandle; +use CurlMultiHandle; +use CurlShareHandle; + class CurlException extends \Exception implements SafeExceptionInterface { /** - * @param \CurlHandle $ch + * + * @param array $error + * @return \Safe\Exceptions\CurlException + */ + public static function createFromPhpError(array $error = []): self + { + return new self( + $error['message'] ?? 'An error occured', + ); + } + + /** + * @param \CurlHandle $handle */ - public static function createFromPhpError($ch): self + public static function createFromCurlHandle(CurlHandle $handle): self + { + return new self(\curl_error($handle), \curl_errno($handle)); + } + + public static function createFromCurlMultiHandle(CurlMultiHandle $multiHandle) : self + { + return new self(\curl_multi_strerror(\curl_multi_errno($multiHandle)) ?? '', \curl_multi_errno($multiHandle)); + } + + public static function createFromCurlShareHandle(CurlShareHandle $shareHandle) : self { - return new self(\curl_error($ch), \curl_errno($ch)); + return new self(\curl_share_strerror(\curl_share_errno($shareHandle)) ?? '', \curl_share_errno($shareHandle)); } } diff --git a/lib/Exceptions/PcreException.php b/lib/Exceptions/PcreException.php index ee6367ef..4eed8454 100644 --- a/lib/Exceptions/PcreException.php +++ b/lib/Exceptions/PcreException.php @@ -7,15 +7,15 @@ class PcreException extends \Exception implements SafeExceptionInterface { public static function createFromPhpError(): self { - $errorMap = [ - PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR: Internal error', - PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR: Backtrack limit reached', - PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR: Recursion limit reached', - PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR: Invalid UTF8 character', + $errorConstantMap = [ + PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR', + PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR', + PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR', + PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR', PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR', ]; - $errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: '.preg_last_error(); - return new self($errMsg, \preg_last_error()); + + return new self(($errorConstantMap[\preg_last_error()] ?? 'Unknown Error') . ': ' . \preg_last_error_msg(), \preg_last_error()); } } diff --git a/lib/Exceptions/SimplexmlException.php b/lib/Exceptions/SimplexmlException.php index 477a9151..3fd1108a 100644 --- a/lib/Exceptions/SimplexmlException.php +++ b/lib/Exceptions/SimplexmlException.php @@ -3,9 +3,20 @@ class SimplexmlException extends \ErrorException implements SafeExceptionInterface { - public static function createFromPhpError(): self + + /** + * + * @param array{type?: int, message?: string, file?: string, line?: int} $error + * @return \Safe\Exceptions\SimplexmlException + */ + public static function createFromPhpError(array $error = []): 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__, + ); } } diff --git a/lib/special_cases.php b/lib/special_cases.php index b95fe0b7..3fbb36c7 100644 --- a/lib/special_cases.php +++ b/lib/special_cases.php @@ -55,10 +55,20 @@ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $o */ function apc_fetch($key) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apc_fetch($key, $success); + restore_error_handler(); if ($success === false) { - throw ApcException::createFromPhpError(); + throw ApcException::createFromPhpError($error); } return $result; } @@ -75,10 +85,20 @@ function apc_fetch($key) */ function apcu_fetch($key) { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \apcu_fetch($key, $success); + restore_error_handler(); if ($success === false) { - throw ApcuException::createFromPhpError(); + throw ApcuException::createFromPhpError($error); } return $result; } @@ -159,7 +179,6 @@ function apcu_fetch($key) */ function preg_replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null) { - error_clear_last(); $result = \preg_replace($pattern, $replacement, $subject, $limit, $count); if (preg_last_error() !== PREG_NO_ERROR || $result === null) { throw PcreException::createFromPhpError(); @@ -203,7 +222,6 @@ function readdir($dir_handle = null) */ function openssl_encrypt(string $data, string $method, string $key, int $options = 0, string $iv = "", string &$tag = "", string $aad = "", int $tag_length = 16): string { - error_clear_last(); // The $tag parameter is handled in a weird way by openssl_encrypt. It cannot be provided unless encoding is AEAD if (func_num_args() <= 5) { $result = \openssl_encrypt($data, $method, $key, $options, $iv); @@ -218,8 +236,7 @@ function openssl_encrypt(string $data, string $method, string $key, int $options /** * The function socket_write writes to the - * socket from the given - * buffer. + * socket from the given buffer. * * @param \Socket $socket * @param string $buffer The buffer to be written. @@ -237,10 +254,20 @@ function openssl_encrypt(string $data, string $method, string $key, int $options */ function socket_write(\Socket $socket, string $buffer, int $length = 0): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = $length === 0 ? \socket_write($socket, $buffer) : \socket_write($socket, $buffer, $length); + restore_error_handler(); if ($result === false) { - throw SocketsException::createFromPhpError(); + throw SocketsException::createFromPhpError($error); } return $result; } @@ -261,10 +288,21 @@ function socket_write(\Socket $socket, string $buffer, int $length = 0): int */ function simplexml_import_dom(\DOMNode $node, string $class_name = \SimpleXMLElement::class): \SimpleXMLElement { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \simplexml_import_dom($node, $class_name); + restore_error_handler(); if ($result === null) { - throw SimplexmlException::createFromPhpError(); + /** @var array{type?: int, message?: string, file?: string, line?: int} $error */ + throw SimplexmlException::createFromPhpError($error); } return $result; } @@ -289,10 +327,21 @@ function simplexml_import_dom(\DOMNode $node, string $class_name = \SimpleXMLEle */ function simplexml_load_file(string $filename, string $class_name = \SimpleXMLElement::class, int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false): \SimpleXMLElement { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \simplexml_load_file($filename, $class_name, $options, $namespace_or_prefix, $is_prefix); + restore_error_handler(); if ($result === false) { - throw SimplexmlException::createFromPhpError(); + /** @var array{type?: int, message?: string, file?: string, line?: int} $error */ + throw SimplexmlException::createFromPhpError($error); } return $result; } @@ -318,10 +367,21 @@ function simplexml_load_file(string $filename, string $class_name = \SimpleXMLEl */ function simplexml_load_string(string $data, string $class_name = \SimpleXMLElement::class, int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false): \SimpleXMLElement { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \simplexml_load_string($data, $class_name, $options, $namespace_or_prefix, $is_prefix); + restore_error_handler(); if ($result === false) { - throw SimplexmlException::createFromPhpError(); + /** @var array{type?: int, message?: string, file?: string, line?: int} $error */ + throw SimplexmlException::createFromPhpError($error); } return $result; } @@ -338,10 +398,20 @@ function simplexml_load_string(string $data, string $class_name = \SimpleXMLElem */ function sys_getloadavg(): array { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \sys_getloadavg(); + restore_error_handler(); if ($result === false) { - throw MiscException::createFromPhpError(); + throw MiscException::createFromPhpError($error); } return $result; } @@ -357,10 +427,20 @@ function sys_getloadavg(): array */ function posix_getpgid(int $process_id): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); $result = \posix_getpgid($process_id); + restore_error_handler(); if ($result === false) { - throw PosixException::createFromPhpError(); + throw PosixException::createFromPhpError($error); } return $result; } @@ -392,16 +472,25 @@ function posix_getpgid(int $process_id): int */ function fputcsv($stream, array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\", string $eol = "\n"): int { - error_clear_last(); + $error = []; + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) use (&$error) { + $error = [ + 'type' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + ]; + return false; + }); if (PHP_VERSION_ID >= 80100) { /** @phpstan-ignore-next-line */ $result = \fputcsv($stream, $fields, $separator, $enclosure, $escape, $eol); } else { $result = \fputcsv($stream, $fields, $separator, $enclosure, $escape); } - + restore_error_handler(); if ($result === false) { - throw FilesystemException::createFromPhpError(); + throw FilesystemException::createFromPhpError($error); } return $result; } diff --git a/rector-migrate.php b/rector-migrate.php index d6d92b6c..cedb3668 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -24,7 +24,6 @@ 'apcu_inc' => 'Safe\apcu_inc', 'apcu_sma_info' => 'Safe\apcu_sma_info', 'apc_fetch' => 'Safe\apc_fetch', - 'array_combine' => 'Safe\array_combine', 'array_replace' => 'Safe\array_replace', 'array_replace_recursive' => 'Safe\array_replace_recursive', 'array_walk_recursive' => 'Safe\array_walk_recursive',