diff --git a/Makefile b/Makefile index 4ae210e..f45d540 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,8 @@ INSTALL_LIB = ${INSTALL_PREFIX}/lib # Otherwise only release verions changes. (version is MAJOR.MINOR.RELEASE) # -SONAME = 1.6 -VERSION = 1.6.5 +SONAME = 1.7 +VERSION = 1.7.0 # diff --git a/include/array.h b/include/array.h index 126cd58..5b164ae 100644 --- a/include/array.h +++ b/include/array.h @@ -31,7 +31,7 @@ class PHPCPP_EXPORT Array : public Value Array(const Value &value) : Value(value) { // type must be valid - if (value.type() != Type::Array) throw FatalError("Assigning a non-array to an array variable"); + if (value.type() != Type::Array) throw Error("Assigning a non-array to an array variable"); } /** @@ -41,7 +41,7 @@ class PHPCPP_EXPORT Array : public Value Array(Value &&value) : Value(std::move(value)) { // type must be valid - if (value.type() != Type::Array) throw FatalError("Moving a non-array to an array variable"); + if (value.type() != Type::Array) throw Error("Moving a non-array to an array variable"); } /** @@ -82,7 +82,7 @@ class PHPCPP_EXPORT Array : public Value virtual Value &setType(Type type) override { // throw exception if things are going wrong - if (type != Type::Array) throw FatalError("Changing type of a fixed array variable"); + if (type != Type::Array) throw Error("Changing type of a fixed array variable"); // call base return Value::setType(Type::Array); @@ -99,7 +99,7 @@ class PHPCPP_EXPORT Array : public Value if (this == &value) return *this; // type must be valid - if (value.type() != Type::Array) throw FatalError("Assigning a non-array to a fixed array variable"); + if (value.type() != Type::Array) throw Error("Assigning a non-array to a fixed array variable"); // call base Value::operator=(value); @@ -119,7 +119,7 @@ class PHPCPP_EXPORT Array : public Value if (this == &value) return *this; // type must be valid - if (value.type() != Type::Array) throw FatalError("Moving a non-array to a fixed array variable"); + if (value.type() != Type::Array) throw Error("Moving a non-array to a fixed array variable"); // call base Value::operator=(std::move(value)); diff --git a/include/call.h b/include/call.h index 9b1725a..6a63fe1 100644 --- a/include/call.h +++ b/include/call.h @@ -47,8 +47,8 @@ inline PHPCPP_EXPORT Value require(const std::string &filename) { return requ extern PHPCPP_EXPORT Value require_once(const char *filename); inline PHPCPP_EXPORT Value require_once(const std::string &filename) { return require_once(filename.c_str()); } extern PHPCPP_EXPORT Value set_exception_handler(const std::function &handler); -extern PHPCPP_EXPORT Value set_error_handler(const std::function &handler, Error error = Error::All); -extern PHPCPP_EXPORT Value error_reporting(Error error); +extern PHPCPP_EXPORT Value set_error_handler(const std::function &handler, Message message = Message::All); +extern PHPCPP_EXPORT Value error_reporting(Message message); extern PHPCPP_EXPORT const char *sapi_name(); /** diff --git a/include/error.h b/include/error.h new file mode 100644 index 0000000..e8629ec --- /dev/null +++ b/include/error.h @@ -0,0 +1,69 @@ +/** + * Error.h + * + * In PHP7 errors are thrown as Error objects, while in PHP5 errors immediately + * cause a fatal crash. Because the PHP-CPP-LEGACY class only supports PHP5, + * the Error class in this file is thus never thrown from PHP space to C++ space. + * + * But to ensure that an extension can be compiled on PHP5 and PHP7, we have + * still added it to the source code, so that it will not cause compile + * errors. + * + * But you can use it to throw fatal errors. + * + * @author Emiel Bruijntjes + * @copyright 2019 Copernica BV + */ + +/** + * Include guard + */ +#pragma once + +/** + * Begin of namespace + */ +namespace Php { + +/** + * Class definition + */ +class PHPCPP_EXPORT Error : public Throwable +{ +public: + /** + * Constructor + * @param message + * @param code + */ + Error(const std::string &message, int code = 0) : Throwable(message, code) {} + + /** + * Destructor + */ + virtual ~Error() = default; + + /** + * Is this a native exception (one that was thrown from C++ code) + * @return bool + */ + virtual bool native() const + { + // although it is native, we return 0 because it should not persist + // as exception, but it should live on as zend_error() in stead + return false; + } + + /** + * Report this error as a fatal error + * @return bool + */ + virtual bool report() const override; + +}; + +/** + * End of namespace + */ +} + diff --git a/include/exception.h b/include/exception.h index 55601c2..dba5283 100644 --- a/include/exception.h +++ b/include/exception.h @@ -1,93 +1,44 @@ /** * Exception.h - * Implementation of Php Exceptions. * - * @author Jasper van Eck - * @copyright 2013, 2014 Copernica BV + * Exception class that can be thrown and caught in C++ space and that + * will end up in or can originate from PHP space. + * + * @author Emiel Bruijntjes + * @copyright 2019 Copernica BV + */ + +/** + * Include guard */ -#include +#pragma once /** - * Set up namespace + * Begin of namespace */ namespace Php { /** * Class definition */ -class PHPCPP_EXPORT Exception : public std::exception +class PHPCPP_EXPORT Exception : public Throwable { -private: - /** - * The exception message - * @var char* - */ - std::string _message; - - /** - * The PHP exception code - * @var int - */ - int _code; - - /** - * Has this exception been processed by native C++ code? - * @var bool - */ - bool _processed = false; - public: /** * Constructor - * @param &string + * @param message + * @param code */ - Exception(const std::string &message, int code = 0) : std::exception(), _message(message), _code(code) {} - + Exception(const std::string &message, int code = 0) : Throwable(message, code) {} + /** * Destructor */ - virtual ~Exception() throw() {} - - /** - * Overridden what method - * @return const char * - */ - virtual const char *what() const _NOEXCEPT override - { - return _message.c_str(); - } - - /** - * Returns the message of the exception. - * @return &string - */ - const std::string &message() const throw() - { - return _message; - } - - /** - * Is this a native exception (one that was thrown from C++ code) - * @return bool - */ - virtual bool native() const - { - // yes, it is native - return true; - } - - /** - * Report this error as a fatal error - * @return bool - */ - virtual bool report() const - { - // this is not done here - return false; - } + virtual ~Exception() = default; }; /** * End of namespace */ } + diff --git a/include/fatalerror.h b/include/fatalerror.h deleted file mode 100644 index a5fd25c..0000000 --- a/include/fatalerror.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * FatalError.h - * - * - * Normally, fatal errors are reported with a call to zend_error(). - * - * However, this will trigger a longjmp(), which will cause objects - * constructed in the extension not to be destructed. We use therefore - * this FatalError class, which is a normal exception that _does_ - * cause objects to be destructed. - * - * When it is caught, right before control is handed back to the Zend - * engine, it will turn the exception into a zend_error() call and - * thus a longjmp. - * - * @author Emiel Bruijntjes - * @copyright 2014 Copernica BV - */ - -/** - * Set up namespace - */ -namespace Php { - -/** - * Class definition - */ -class PHPCPP_EXPORT FatalError : public Exception -{ -public: - /** - * Constructor - * @param message - */ - FatalError(const std::string &message) : Exception(message) {} - - /** - * Destructor - */ - virtual ~FatalError() throw() - { - } - - /** - * Is this a native exception (one that was thrown from C++ code) - * @return bool - */ - virtual bool native() const - { - // although it is native, we return 0 because it should not persist - // as exception, but it should live on as zend_error() in stead - return false; - } - - /** - * Report this error as a fatal error - * @return bool - */ - virtual bool report() const override; -}; - -/** - * End of namespace - */ -} diff --git a/include/errors.h b/include/message.h similarity index 96% rename from include/errors.h rename to include/message.h index e1a95d8..ce07e5e 100644 --- a/include/errors.h +++ b/include/message.h @@ -15,7 +15,7 @@ namespace Php { /** * Supported types of errors, this is mostly a copy from Zend/zend_errors.h */ -enum class PHPCPP_EXPORT Error : int { +enum class PHPCPP_EXPORT Message : int { Error = (1 << 0L), Warning = (1 << 1L), Parse = (1 << 2L), diff --git a/include/object.h b/include/object.h index 745b7c6..5747204 100644 --- a/include/object.h +++ b/include/object.h @@ -109,7 +109,7 @@ class PHPCPP_EXPORT Object : public Value virtual Value &setType(Type type) override { // throw exception if things are going wrong - if (type != Type::Object) throw FatalError("Changing type of a fixed object variable"); + if (type != Type::Object) throw Error("Changing type of a fixed object variable"); // call base return Value::setType(type); @@ -126,7 +126,7 @@ class PHPCPP_EXPORT Object : public Value if (this == &value) return *this; // type must be valid - if (value.type() != Type::Object) throw FatalError("Assigning a non-object to an object variable"); + if (value.type() != Type::Object) throw Error("Assigning a non-object to an object variable"); // call base Value::operator=(value); @@ -146,7 +146,7 @@ class PHPCPP_EXPORT Object : public Value if (this == &value) return *this; // type must be valid - if (value.type() != Type::Object) throw FatalError("Moving a non-object to an object variable"); + if (value.type() != Type::Object) throw Error("Moving a non-object to an object variable"); // call base Value::operator=(std::move(value)); diff --git a/include/throwable.h b/include/throwable.h new file mode 100644 index 0000000..b4bef55 --- /dev/null +++ b/include/throwable.h @@ -0,0 +1,95 @@ +/** + * Throwable + * + * Base class for Php Exceptions. + * + * @author Jasper van Eck + * @copyright 2013 - 2019 Copernica BV + */ +#include + +/** + * Set up namespace + */ +namespace Php { + +/** + * Class definition + */ +class PHPCPP_EXPORT Throwable : public std::exception +{ +private: + /** + * The exception message + * @var char* + */ + std::string _message; + + /** + * The PHP exception code + * @var int + */ + int _code; + + /** + * Has this exception been processed by native C++ code? + * @var bool + */ + bool _processed = false; + +protected: + /** + * Constructor + * @param &string + */ + Throwable(const std::string &message, int code = 0) : std::exception(), _message(message), _code(code) {} + +public: + /** + * Destructor + */ + virtual ~Throwable() throw() {} + + /** + * Overridden what method + * @return const char * + */ + virtual const char *what() const _NOEXCEPT override + { + return _message.c_str(); + } + + /** + * Returns the message of the exception. + * @return &string + */ + const std::string &message() const throw() + { + return _message; + } + + /** + * Is this a native exception (one that was thrown from C++ code) + * @return bool + */ + virtual bool native() const + { + // yes, it is native + return true; + } + + /** + * Report this error as a fatal error + * @return bool + */ + virtual bool report() const + { + // this is not done here + return false; + } +}; + +/** + * End of namespace + */ +} diff --git a/include/value.h b/include/value.h index 9fb0ff1..c0a4eed 100644 --- a/include/value.h +++ b/include/value.h @@ -1217,7 +1217,7 @@ class PHPCPP_EXPORT Value : private HashParent * Friend functions which have to access that zval directly */ friend Value set_exception_handler(const std::function &handler); - friend Value set_error_handler(const std::function &handler, Error error); + friend Value set_error_handler(const std::function &handler, Message message); }; /** diff --git a/include/zendcallable.h b/include/zendcallable.h index fd0d2ed..146c328 100644 --- a/include/zendcallable.h +++ b/include/zendcallable.h @@ -62,7 +62,7 @@ class PHPCPP_EXPORT ZendCallable * * @param exception The exception to handle */ - static void handle(Exception &exception); + static void handle(Throwable &exception); /** * Yield (return) the given value @@ -94,7 +94,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just return null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -119,7 +119,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just return null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -144,7 +144,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -169,7 +169,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -200,7 +200,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just reutrn null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -231,7 +231,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just return null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -262,7 +262,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -293,7 +293,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -318,7 +318,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just return null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -343,7 +343,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -374,7 +374,7 @@ class PHPCPP_EXPORT ZendCallable // there is no return value, so we just return null yield(return_value, nullptr); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); @@ -405,7 +405,7 @@ class PHPCPP_EXPORT ZendCallable // store the return value in the return_value yield(return_value, std::move(result)); } - catch (Exception &exception) + catch (Throwable &exception) { // handle the exception handle(exception); diff --git a/phpcpp.h b/phpcpp.h index 9fcd0cb..a3180ff 100644 --- a/phpcpp.h +++ b/phpcpp.h @@ -34,10 +34,11 @@ #include #include #include +#include #include -#include +#include #include -#include +#include #include #include #include diff --git a/zend/callable.cpp b/zend/callable.cpp index 51853d3..0d652bd 100644 --- a/zend/callable.cpp +++ b/zend/callable.cpp @@ -60,7 +60,7 @@ void Callable::invoke(INTERNAL_FUNCTION_PARAMETERS) // return a full copy of the zval, and do not destruct it RETVAL_ZVAL(result._val, 1, 0); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception process(exception TSRMLS_CC); diff --git a/zend/classimpl.cpp b/zend/classimpl.cpp index f637a55..c756c0e 100644 --- a/zend/classimpl.cpp +++ b/zend/classimpl.cpp @@ -148,7 +148,7 @@ void ClassImpl::callMethod(INTERNAL_FUNCTION_PARAMETERS) // because of the two-step nature, we are going to report the error ourselves zend_error(E_ERROR, "Undefined method %s", name); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception process(exception TSRMLS_CC); @@ -194,7 +194,7 @@ void ClassImpl::callInvoke(INTERNAL_FUNCTION_PARAMETERS) // because of the two-step nature, we are going to report the error ourselves zend_error(E_ERROR, "Function name must be a string"); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception process(exception TSRMLS_CC); @@ -456,7 +456,7 @@ int ClassImpl::compare(zval *val1, zval *val2 TSRMLS_DC) // call default return std_object_handlers.compare_objects(val1, val2 TSRMLS_CC); } - catch (Exception &exception) + catch (Throwable &exception) { // a Php::Exception was thrown by the extension __compare function, // pass this on to user space @@ -527,7 +527,7 @@ int ClassImpl::cast(zval *val, zval *retval, int type TSRMLS_DC) // call default return std_object_handlers.cast_object(val, retval, type TSRMLS_CC); } - catch (Exception &exception) + catch (Throwable &exception) { // pass on the exception to php userspace process(exception TSRMLS_CC); @@ -614,7 +614,7 @@ int ClassImpl::countElements(zval *object, long *count TSRMLS_DC) // done return SUCCESS; } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception process(exception TSRMLS_CC); @@ -677,7 +677,7 @@ zval *ClassImpl::readDimension(zval *object, zval *offset, int type TSRMLS_DC) // ArrayAccess is implemented, call function return toZval(arrayaccess->offsetGet(offset), type); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception (send it to user space) process(exception TSRMLS_CC); @@ -722,7 +722,7 @@ void ClassImpl::writeDimension(zval *object, zval *offset, zval *value TSRMLS_DC // set the value arrayaccess->offsetSet(offset, value); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception (send it to user space process(exception TSRMLS_CC); @@ -771,7 +771,7 @@ int ClassImpl::hasDimension(zval *object, zval *member, int check_empty TSRMLS_D // the user wants to know if the property is empty return empty(arrayaccess->offsetGet(member)); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception (send it to user space) process(exception TSRMLS_CC); @@ -814,7 +814,7 @@ void ClassImpl::unsetDimension(zval *object, zval *member TSRMLS_DC) // remove the member arrayaccess->offsetUnset(member); } - catch (Exception &exception) + catch (Throwable &exception) { // process the exception (send it to user space) process(exception TSRMLS_CC); @@ -956,7 +956,7 @@ zval *ClassImpl::readProperty(zval *object, zval *name, int type, const zend_lit return std_object_handlers.read_property(object, name, type, key TSRMLS_CC); #endif } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its magic method // implementation, send it to user space @@ -1062,7 +1062,7 @@ void ClassImpl::writeProperty(zval *object, zval *name, zval *value, const zend_ std_object_handlers.write_property(object, name, value, key TSRMLS_CC); #endif } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its magic method // implementation, send it to user space @@ -1182,7 +1182,7 @@ int ClassImpl::hasProperty(zval *object, zval *name, int has_set_exists, const z return std_object_handlers.has_property(object, name, has_set_exists, key TSRMLS_CC); #endif } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its magic method // implementation, send it to user space @@ -1263,7 +1263,7 @@ void ClassImpl::unsetProperty(zval *object, zval *member, const zend_literal *ke std_object_handlers.unset_property(object, member, key TSRMLS_CC); #endif } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its magic method // implementation, send it to user space @@ -1297,7 +1297,7 @@ void ClassImpl::destructObject(zend_object *object, zend_object_handle handle TS // fallback on the default destructor call zend_objects_destroy_object(object, handle TSRMLS_CC); } - catch (Exception &exception) + catch (Throwable &exception) { // a regular Php::Exception was thrown by the extension, pass it on // to PHP user space @@ -1382,7 +1382,7 @@ zend_object_iterator *ClassImpl::getIterator(zend_class_entry *entry, zval *obje // return the implementation return iterator->implementation(); } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its method // implementation, send it to user space @@ -1419,7 +1419,7 @@ int ClassImpl::serialize(zval *object, unsigned char **buffer, zend_uint *buf_le *buffer = (unsigned char*)estrndup(value.c_str(), value.size()); *buf_len = value.size(); } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its method // implementation, send it to user space @@ -1456,7 +1456,7 @@ int ClassImpl::unserialize(zval **object, zend_class_entry *entry, const unsigne // call the unserialize method on it serializable->unserialize((const char *)buffer, buf_len); } - catch (Exception &exception) + catch (Throwable &exception) { // user threw an exception in its method // implementation, send it to user space diff --git a/zend/fatalerror.cpp b/zend/error.cpp similarity index 81% rename from zend/fatalerror.cpp rename to zend/error.cpp index e57be73..33b547f 100644 --- a/zend/fatalerror.cpp +++ b/zend/error.cpp @@ -1,8 +1,8 @@ /** - * FatalError.cpp + * Error.cpp * * @author Emiel Bruijntjes - * @copyright 2014 Copernica BV + * @copyright 2014 - 2019 Copernica BV */ #include "includes.h" @@ -15,7 +15,7 @@ namespace Php { * Report this error as a fatal error * @return bool */ -bool FatalError::report() const +bool Error::report() const { // report the error zend_error(E_ERROR, "%s", what()); diff --git a/zend/exception_handler.cpp b/zend/exception_handler.cpp index 75faef9..8767d5f 100644 --- a/zend/exception_handler.cpp +++ b/zend/exception_handler.cpp @@ -49,7 +49,7 @@ Value set_exception_handler(const std::function &hand /** * Set a std::function as a php error handler */ -Value set_error_handler(const std::function &handler, Error error) +Value set_error_handler(const std::function &handler, Message message) { // we need the tsrm_ls variable TSRMLS_FETCH(); @@ -71,7 +71,7 @@ Value set_error_handler(const std::function &handler, // copy our zval into the user_error_handler MAKE_COPY_ZVAL(&value, EG(user_error_handler)); - EG(user_error_handler_error_reporting) = (int) error; + EG(user_error_handler_error_reporting) = (int) message; // return the original handler return output; @@ -80,7 +80,7 @@ Value set_error_handler(const std::function &handler, /** * Modify the error reporting level, will return the old error reporting level. */ -Value error_reporting(Error error) +Value error_reporting(Message message) { // we need the tsrm_ls variable TSRMLS_FETCH(); @@ -92,7 +92,7 @@ Value error_reporting(Error error) char str[21]; // write the level into this buffer - int size = sprintf(str, "%d", (int) error); + int size = sprintf(str, "%d", (int) message); // if we failed for some reason we bail out if (size < 0) return false; diff --git a/zend/includes.h b/zend/includes.h index 4fa4648..3e9ffe9 100644 --- a/zend/includes.h +++ b/zend/includes.h @@ -70,11 +70,12 @@ #include "../include/version.h" #include "../include/inivalue.h" #include "../include/ini.h" +#include "../include/throwable.h" #include "../include/exception.h" -#include "../include/fatalerror.h" +#include "../include/error.h" #include "../include/streams.h" #include "../include/type.h" -#include "../include/errors.h" +#include "../include/message.h" #include "../include/hashparent.h" #include "../include/value.h" #include "../include/valueiterator.h" diff --git a/zend/object.cpp b/zend/object.cpp index 7da8339..740572e 100644 --- a/zend/object.cpp +++ b/zend/object.cpp @@ -32,12 +32,12 @@ Object::Object(const char *name, Base *base) : Value() // this is a brand new object that should be allocated, the C++ instance // is already there (created by the extension) but it is not yet stored - // in PHP, find out the classname first (we use the FatalError class + // in PHP, find out the classname first (we use the Error class // here because this function is called from C++ context, and zend_error() // would cause a longjmp() which does not clean up C++ objects created // by the extension). auto *entry = zend_fetch_class(name, ::strlen(name), ZEND_FETCH_CLASS_SILENT TSRMLS_CC); - if (!entry) throw FatalError(std::string("Unknown class name ") + name); + if (!entry) throw Error(std::string("Unknown class name ") + name); // construct an implementation (this will also set the implementation // member in the base object), this is a self-destructing object that @@ -117,12 +117,12 @@ bool Object::instantiate(const char *name) // we need the tsrm_ls variable TSRMLS_FETCH(); - // convert the name into a class_entry (we use the FatalError class + // convert the name into a class_entry (we use the Error class // here because this function is called from C++ context, and zend_error() // would cause a longjmp() which does not clean up C++ objects created // by the extension). auto *entry = zend_fetch_class(name, ::strlen(name), ZEND_FETCH_CLASS_SILENT TSRMLS_CC); - if (!entry) throw FatalError(std::string("Unknown class name ") + name); + if (!entry) throw Error(std::string("Unknown class name ") + name); // initiate the zval (which was already allocated in the base constructor) object_init_ex(_val, entry); diff --git a/zend/origexception.h b/zend/origexception.h index 55f89cf..1b7975c 100644 --- a/zend/origexception.h +++ b/zend/origexception.h @@ -119,7 +119,7 @@ class OrigException : public Value, public Exception * @param exception * @param tsrm_ls */ -inline void process(Exception &exception TSRMLS_DC) +inline void process(Throwable &exception TSRMLS_DC) { // is this a native exception? if (exception.native()) diff --git a/zend/value.cpp b/zend/value.cpp index 4966d04..f2fd001 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -192,7 +192,7 @@ Value::Value(const Base *object) auto *impl = object->implementation(); // do we have a handle? - if (!impl) throw FatalError("Assigning an unassigned object to a variable"); + if (!impl) throw Error("Assigning an unassigned object to a variable"); // make a regular zval, and set it to an object MAKE_STD_ZVAL(_val); @@ -1068,7 +1068,7 @@ Value &Value::setType(Type type) SEPARATE_ZVAL_IF_NOT_REF(&_val); // run the conversion, when it fails we throw a fatal error which will - // in the end result in a zend_error() call. This FatalError class is necessary + // in the end result in a zend_error() call. This Error class is necessary // because a direct call to zend_error() will do a longjmp() which may not // clean up the C++ objects created by the extension switch (type) { @@ -1079,10 +1079,10 @@ Value &Value::setType(Type type) case Type::Array: convert_to_array(_val); break; case Type::Object: convert_to_object(_val); break; case Type::String: convert_to_string(_val); break; - case Type::Resource: throw FatalError("Resource types can not be handled by the PHP-CPP library"); break; - case Type::Constant: throw FatalError("Constant types can not be assigned to a PHP-CPP library variable"); break; - case Type::ConstantArray: throw FatalError("Constant types can not be assigned to a PHP-CPP library variable"); break; - case Type::Callable: throw FatalError("Callable types can not be assigned to a PHP-CPP library variable"); break; + case Type::Resource: throw Error("Resource types can not be handled by the PHP-CPP library"); break; + case Type::Constant: throw Error("Constant types can not be assigned to a PHP-CPP library variable"); break; + case Type::ConstantArray: throw Error("Constant types can not be assigned to a PHP-CPP library variable"); break; + case Type::Callable: throw Error("Callable types can not be assigned to a PHP-CPP library variable"); break; } // done diff --git a/zend/zendcallable.cpp b/zend/zendcallable.cpp index 4db3a60..12b872a 100644 --- a/zend/zendcallable.cpp +++ b/zend/zendcallable.cpp @@ -82,7 +82,7 @@ Parameters ZendCallable::parameters(int provided, struct _zval_struct *this_ptr) * * @param exception The exception to handle */ -void ZendCallable::handle(Exception &exception) +void ZendCallable::handle(Throwable &exception) { // we need the tsrm_ls variable TSRMLS_FETCH();