diff options
author | Aaron Piotrowski <aaron@trowski.com> | 2015-10-17 14:30:41 -0500 |
---|---|---|
committer | Aaron Piotrowski <aaron@trowski.com> | 2015-10-17 14:30:41 -0500 |
commit | 51953423ee391c8e002d0ef7ac21c5243a097135 (patch) | |
tree | 77444425fcaa4b76ae93a114eb31ff96b626a1c6 | |
parent | e2d6090043aed271d18a4d157cbb64138481c9ed (diff) | |
download | php-git-51953423ee391c8e002d0ef7ac21c5243a097135.tar.gz |
Fix assert() implementation to match docs
-rw-r--r-- | ext/standard/assert.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/assert/assert_custom_exception.phpt | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/ext/standard/assert.c b/ext/standard/assert.c index 545c099877..22f4759af4 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -245,7 +245,7 @@ PHP_FUNCTION(assert) if (!description) { zend_throw_exception(assertion_error_ce, NULL, E_ERROR); } else if (Z_TYPE_P(description) == IS_OBJECT && - instanceof_function(Z_OBJCE_P(description), assertion_error_ce)) { + instanceof_function(Z_OBJCE_P(description), zend_ce_throwable)) { Z_ADDREF_P(description); zend_throw_exception_object(description); } else { diff --git a/ext/standard/tests/assert/assert_custom_exception.phpt b/ext/standard/tests/assert/assert_custom_exception.phpt new file mode 100644 index 0000000000..caec222d1a --- /dev/null +++ b/ext/standard/tests/assert/assert_custom_exception.phpt @@ -0,0 +1,15 @@ +--TEST-- +Throwing custom exception object from assert() throws given object +--INI-- +zend.assertions = 1 +assert.exception = 1 +--FILE-- +<?php +class CustomException extends Exception {} +assert(false, new CustomException('Exception message')); +?> +--EXPECTF-- +Fatal error: Uncaught CustomException: Exception message in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d |