PHPAPI zend_class_entry *spl_ce_SplFileObject;
PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
-// TODO Use standard Error
#define CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(spl_filesystem_object_pointer) \
if (!(spl_filesystem_object_pointer)->u.file.stream) { \
- zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized"); \
+ zend_throw_error(NULL, "Object not initialized"); \
RETURN_THROWS(); \
}
case SPL_FS_INFO:
case SPL_FS_FILE:
if (!intern->file_name) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
+ zend_throw_error(NULL, "Object not initialized");
return FAILURE;
}
break;
/* {{{ */
PHP_METHOD(SplFileInfo, _bad_state_ex)
{
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The parent constructor was not called: the object is in an "
- "invalid state ");
+ zend_throw_error(NULL, "The parent constructor was not called: the object is in an invalid state");
}
/* }}} */
static void spl_filesystem_file_rewind(zval * this_ptr, spl_filesystem_object *intern) /* {{{ */
{
if (!intern->u.file.stream) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
+ zend_throw_error(NULL, "Object not initialized");
return;
}
if (-1 == php_stream_rewind(intern->u.file.stream)) {
do { \
spl_dual_it_object *it = Z_SPLDUAL_IT_P(objzval); \
if (it->dit_type == DIT_Unknown) { \
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
- "The object is in an invalid state as the parent constructor was not called"); \
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
RETURN_THROWS(); \
} \
(var) = it; \
#define SPL_FETCH_SUB_ELEMENT(var, object, element) \
do { \
if(!(object)->iterators) { \
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
- "The object is in an invalid state as the parent constructor was not called"); \
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
return; \
} \
(var) = (object)->iterators[(object)->level].element; \
#define SPL_FETCH_SUB_ELEMENT_ADDR(var, object, element) \
do { \
if(!(object)->iterators) { \
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
- "The object is in an invalid state as the parent constructor was not called"); \
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
RETURN_THROWS(); \
} \
(var) = &(object)->iterators[(object)->level].element; \
}
if(!object->iterators) {
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The object is in an invalid state as the parent constructor was not called");
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called");
RETURN_THROWS();
}
}
if(!object->iterators) {
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The object is in an invalid state as the parent constructor was not called");
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called");
RETURN_THROWS();
}
}
if(!object->iterators) {
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The object is in an invalid state as the parent constructor was not called");
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called");
RETURN_THROWS();
}
}
if(!object->iterators) {
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The object is in an invalid state as the parent constructor was not called");
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called");
RETURN_THROWS();
}
}
if(!object->iterators) {
- zend_throw_exception_ex(spl_ce_LogicException, 0,
- "The object is in an invalid state as the parent constructor was not called");
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called");
RETURN_THROWS();
}
?>
--EXPECTF--
-Fatal error: Uncaught LogicException: The object is in an invalid state as the parent constructor was not called in %s:%d
+Fatal error: Uncaught Error: The object is in an invalid state as the parent constructor was not called in %s:%d
Stack trace:
#0 %s%ebug54281.php(8): RecursiveIteratorIterator->rewind()
#1 {main}
try {
$f();
echo "ran normally (unexpected)\n\n";
- } catch (LogicException $e) {
- echo "exception (expected)\n";
+ } catch (\Error $e) {
+ echo "Error (expected)\n";
}
}
} );
?>
--EXPECT--
-IteratorIterator... exception (expected)
-FilterIterator... exception (expected)
-RecursiveFilterIterator... exception (expected)
-ParentIterator... exception (expected)
-LimitIterator... exception (expected)
-CachingIterator... exception (expected)
-RecursiveCachingIterator... exception (expected)
-NoRewindIterator... exception (expected)
-RegexIterator... exception (expected)
-RecursiveRegexIterator... exception (expected)
-GlobIterator... exception (expected)
-SplFileObject... exception (expected)
-SplTempFileObject... exception (expected)
-AppendIterator... exception (expected)
-InfiniteIterator... exception (expected)
+IteratorIterator... Error (expected)
+FilterIterator... Error (expected)
+RecursiveFilterIterator... Error (expected)
+ParentIterator... Error (expected)
+LimitIterator... Error (expected)
+CachingIterator... Error (expected)
+RecursiveCachingIterator... Error (expected)
+NoRewindIterator... Error (expected)
+RegexIterator... Error (expected)
+RecursiveRegexIterator... Error (expected)
+GlobIterator... Error (expected)
+SplFileObject... Error (expected)
+SplTempFileObject... Error (expected)
+AppendIterator... Error (expected)
+InfiniteIterator... Error (expected)
} catch (RuntimeException $e) {
// Throwing a RuntimeException is the correct behaviour for some methods
echo "ran normally (expected)\n";
- } catch (LogicException $e) {
+ } catch (\Error $e) {
// Throwing a LogicException is not correct
echo "threw LogicException (unexpected)\n";
}
try {
$f();
echo "didn't throw (unexpected)\n";
- } catch (LogicException $e) {
- echo "threw LogicException (expected)\n";
+ } catch (\Error $e) {
+ echo "threw Error (expected)\n";
} catch (Exception $e) {
echo "threw other exception (unexpected)\n";
}
======================= test there are no regressions =======================
SplFileObject existent file... ran normally (expected)
SplFileObject non-existent file... ran normally (expected)
-extends GlobIterator... threw LogicException (expected)
-extends SplFileObject... threw LogicException (expected)
-extends SplTempFileObject... threw LogicException (expected)
+extends GlobIterator... threw Error (expected)
+extends SplFileObject... threw Error (expected)
+extends SplTempFileObject... threw Error (expected)
?>
--EXPECTF--
-Fatal error: Uncaught RuntimeException: Object not initialized in %s:%d
+Fatal error: Uncaught Error: Object not initialized in %s:%d
Stack trace:
#0 %s(%d): SplFileObject->flock(2)
#1 [internal function]: Target->__destruct()
{
$ap->append($it);
}
-catch(LogicException $e)
+catch(\Error $e)
{
echo $e->getMessage() . "\n";
}