parent = parent->parent;
inherited = 1;
}
- if (!parent) { /* this must never happen */
- php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of ArrayObject or ArrayIterator");
- }
+
+ ZEND_ASSERT(parent);
+
if (inherited) {
intern->fptr_offset_get = zend_hash_str_find_ptr(&class_type->function_table, "offsetget", sizeof("offsetget") - 1);
if (intern->fptr_offset_get->common.scope == parent) {
intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (intern->_path) {
/* object is already initialized */
- php_error_docref(NULL, E_WARNING, "Directory object is already initialized");
+ zend_throw_error(NULL, "Directory object is already initialized");
return;
}
intern->flags = flags;
}
#if defined(PHP_WIN32) || defined(HAVE_SYMLINK)
if (intern->file_name == NULL) {
- zend_restore_error_handling(&error_handling);
- php_error_docref(NULL, E_WARNING, "Empty filename");
- RETURN_FALSE;
- } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
+ zend_value_error("Filename cannot be empty");
+ RETURN_THROWS();
+ }
+ if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
char expanded_path[MAXPATHLEN];
if (!expand_filepath_with_mode(intern->file_name, expanded_path, NULL, 0, CWD_EXPAND )) {
zend_restore_error_handling(&error_handling);
RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
} else {
/* should not happen */
+ // TODO ZEND_ASSERT ?
php_error_docref(NULL, E_ERROR, "GlobIterator lost glob state");
}
}
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
+ // TODO Align behaviour on normal fgetcsv()
switch(ZEND_NUM_ARGS())
{
case 3:
zval *fields = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|sss", &fields, &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
+
+ // TODO Align behaviour on normal fputcsv()
switch(ZEND_NUM_ARGS())
{
case 4:
size_t d_len = 0, e_len = 0, esc_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
+ // TODO Align behaviour on normal fgetcsv()
switch(ZEND_NUM_ARGS())
{
case 3:
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
if (length <= 0) {
- php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be greater than 0");
+ RETURN_THROWS();
}
str = php_stream_read_to_str(intern->u.file.stream, length);
inherited = 1;
}
- if (!parent) { /* this must never happen */
- php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplDoublyLinkedList");
- }
+ ZEND_ASSERT(parent);
+
if (inherited) {
intern->fptr_offset_get = zend_hash_str_find_ptr(&class_type->function_table, "offsetget", sizeof("offsetget") - 1);
if (intern->fptr_offset_get->common.scope == parent) {
inherited = 1;
}
- if (!parent) { /* this must never happen */
- php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplFixedArray");
- }
+ ZEND_ASSERT(parent);
funcs_ptr = class_type->iterator_funcs_ptr;
if (!funcs_ptr->zf_current) {
inherited = 1;
}
- if (!parent) { /* this must never happen */
- php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplHeap");
- }
+ ZEND_ASSERT(parent);
if (inherited) {
intern->fptr_cmp = zend_hash_str_find_ptr(&class_type->function_table, "compare", sizeof("compare") - 1);
iterator = emalloc(sizeof(spl_recursive_it_iterator));
object = Z_SPLRECURSIVE_IT_P(zobject);
if (object->iterators == NULL) {
- zend_error(E_ERROR, "The object to be iterated is in an invalid state: "
- "the parent constructor has not been called");
+ zend_throw_error(NULL, "Object is not initialized");
+ return NULL;
}
zend_iterator_init((zend_object_iterator*)iterator);
}
if ((value = zend_symtable_find(Z_ARRVAL(intern->u.caching.zcache), key)) == NULL) {
- zend_error(E_NOTICE, "Undefined array key \"%s\"", ZSTR_VAL(key));
+ zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(key));
return;
}
--FILE--
<?php
$x = new DirectoryIterator('.');
-$x->__construct('/tmp');
-echo "Okey";
+
+try {
+ $x->__construct('/tmp');
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
?>
---EXPECTF--
-Warning: DirectoryIterator::__construct(): Directory object is already initialized in %sbug61828.php on line 3
-Okey
+--EXPECT--
+Directory object is already initialized
$data = $obj->fread(5);
var_dump($data);
-$data = $obj->fread(0);
-var_dump($data);
+try {
+ $data = $obj->fread(0);
+ var_dump($data);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
// read more data than is available
$data = $obj->fread(filesize(__FILE__) + 32);
var_dump(strlen($data) === filesize(__FILE__) - 5);
?>
---EXPECTF--
+--EXPECT--
string(5) "<?php"
-
-Warning: SplFileObject::fread(): Length parameter must be greater than 0 in %s on line %d
-bool(false)
+SplFileObject::fread(): Argument #1 ($length) must be greater than 0
bool(true)
int(0)
bool(false)
-Notice: Undefined array key "0" in %s on line %d
+Warning: Undefined array key "0" in %s on line %d
NULL
===1===
object(stdClass)#%d (0) {
}
bool(false)
-Notice: Undefined array key "foo" in %s on line %d
+Warning: Undefined array key "foo" in %s on line %d
NULL
===3===
NULL
bool(false)
-Notice: Undefined array key "" in %s on line %d
+Warning: Undefined array key "" in %s on line %d
NULL
===4===
int(2)
bool(false)
-Notice: Undefined array key "2" in %s on line %d
+Warning: Undefined array key "2" in %s on line %d
NULL
===5===
string(3) "foo"
bool(false)
-Notice: Undefined array key "foo" in %s on line %d
+Warning: Undefined array key "foo" in %s on line %d
NULL
===6===
int(3)
bool(false)
-Notice: Undefined array key "3" in %s on line %d
+Warning: Undefined array key "3" in %s on line %d
NULL
===FILL===
===0===
NULL
bool(false)
-Notice: Undefined array key "" in %s on line %d
+Warning: Undefined array key "" in %s on line %d
NULL
===4===
int(2)
int(3)
bool(false)
-Notice: Undefined array key "3" in %s on line %d
+Warning: Undefined array key "3" in %s on line %d
NULL