-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:CopernicaMarketingSoftware/PHP-CP…
…P-LEGACY
- Loading branch information
Showing
21 changed files
with
252 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
* @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 | ||
*/ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,44 @@ | ||
/** | ||
* Exception.h | ||
* Implementation of Php Exceptions. | ||
* | ||
* @author Jasper van Eck <[email protected]> | ||
* @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 <[email protected]> | ||
* @copyright 2019 Copernica BV | ||
*/ | ||
|
||
/** | ||
* Include guard | ||
*/ | ||
#include <exception> | ||
#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 | ||
*/ | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.