Skip to content

Commit ac44eff

Browse files
committed
SPL Double Linked List
1 parent 12be3fb commit ac44eff

14 files changed

+28
-27
lines changed

ext/spl/spl_dllist.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
770770
spl_dllist_object *intern;
771771
spl_ptr_llist_element *element;
772772

773+
/* TODO Change this to int? */
773774
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) {
774775
RETURN_THROWS();
775776
}
@@ -778,7 +779,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
778779
index = spl_offset_convert_to_long(zindex);
779780

780781
if (index < 0 || index >= intern->llist->count) {
781-
zend_value_error("Offset invalid or out of range");
782+
zend_argument_value_error(1, "is out of range");
782783
RETURN_THROWS();
783784
}
784785

@@ -789,7 +790,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
789790

790791
ZVAL_COPY_DEREF(return_value, value);
791792
} else {
792-
zend_value_error("Offset invalid");
793+
zend_argument_value_error(1, "is invalid");
793794
RETURN_THROWS();
794795
}
795796
} /* }}} */
@@ -818,7 +819,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
818819
index = spl_offset_convert_to_long(zindex);
819820

820821
if (index < 0 || index >= intern->llist->count) {
821-
zend_value_error("Offset invalid or out of range");
822+
zend_argument_value_error(1, "is out of range");
822823
RETURN_THROWS();
823824
}
824825

@@ -841,7 +842,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
841842
}
842843
} else {
843844
zval_ptr_dtor(value);
844-
zend_value_error("Offset invalid");
845+
zend_argument_value_error(1, "is invalid");
845846
RETURN_THROWS();
846847
}
847848
}
@@ -866,7 +867,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetUnset)
866867
llist = intern->llist;
867868

868869
if (index < 0 || index >= intern->llist->count) {
869-
zend_value_error("Offset out of range");
870+
zend_argument_value_error(1, "is out of range");
870871
RETURN_THROWS();
871872
}
872873

@@ -907,7 +908,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetUnset)
907908

908909
SPL_LLIST_DELREF(element);
909910
} else {
910-
zend_value_error("Offset invalid");
911+
zend_argument_value_error(1, "is invalid");
911912
RETURN_THROWS();
912913
}
913914
} /* }}} */
@@ -1210,6 +1211,7 @@ SPL_METHOD(SplDoublyLinkedList, unserialize)
12101211

12111212
error:
12121213
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
1214+
/* TODO Convert to standard Error ? */
12131215
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Error at offset %zd of %zd bytes", ((char*)p - buf), buf_len);
12141216
RETURN_THROWS();
12151217

@@ -1263,8 +1265,7 @@ SPL_METHOD(SplDoublyLinkedList, __unserialize) {
12631265
if (!flags_zv || !storage_zv || !members_zv ||
12641266
Z_TYPE_P(flags_zv) != IS_LONG || Z_TYPE_P(storage_zv) != IS_ARRAY ||
12651267
Z_TYPE_P(members_zv) != IS_ARRAY) {
1266-
zend_throw_exception(spl_ce_UnexpectedValueException,
1267-
"Incomplete or ill-typed serialization data", 0);
1268+
zend_throw_error(NULL, "Incomplete or ill-typed serialization data");
12681269
RETURN_THROWS();
12691270
}
12701271

@@ -1294,7 +1295,7 @@ SPL_METHOD(SplDoublyLinkedList, add)
12941295
index = spl_offset_convert_to_long(zindex);
12951296

12961297
if (index < 0 || index > intern->llist->count) {
1297-
zend_value_error("Offset invalid or out of range");
1298+
zend_argument_value_error(1, "is out of range");
12981299
RETURN_THROWS();
12991300
}
13001301

@@ -1358,7 +1359,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
13581359
spl_dllist_object *dllist_object = Z_SPLDLLIST_P(object);
13591360

13601361
if (by_ref) {
1361-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1362+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
13621363
return NULL;
13631364
}
13641365

ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
$value *= $value;
1818
echo $value, PHP_EOL;
1919
}
20-
} catch (Exception $e) {
20+
} catch (\Error $e) {
2121
echo $e->getMessage(), PHP_EOL;
2222
}
2323

ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ try {
1010
}
1111
?>
1212
--EXPECT--
13-
Offset invalid or out of range
13+
SplDoublyLinkedList::add(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ try {
1010
}
1111
?>
1212
--EXPECT--
13-
Offset invalid or out of range
13+
SplDoublyLinkedList::add(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ try {
1515

1616
?>
1717
--EXPECT--
18-
Offset invalid or out of range
18+
SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ try {
1515

1616
?>
1717
--EXPECT--
18-
Offset invalid or out of range
18+
SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ try {
1919

2020
?>
2121
--EXPECT--
22-
Offset out of range
22+
SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
1919
}
2020
?>
2121
--EXPECT--
22-
Offset out of range
22+
SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range

ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
1919
}
2020
?>
2121
--EXPECT--
22-
Offset out of range
22+
SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range

ext/spl/tests/bug46160.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ try {
1010
}
1111
?>
1212
--EXPECT--
13-
Offset invalid or out of range
13+
SplDoublyLinkedList::offsetSet(): Argument #1 ($index) is out of range

ext/spl/tests/bug71735.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ try {
1010
}
1111
?>
1212
--EXPECT--
13-
Offset invalid or out of range
13+
SplDoublyLinkedList::offsetSet(): Argument #1 ($index) is out of range

ext/spl/tests/dllist_006.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ Unsetting..
4444
int(3)
4545
int(4)
4646
int(2)
47-
Offset invalid or out of range
47+
SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range
4848
int(1)
49-
Offset invalid or out of range
49+
SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range

ext/spl/tests/dllist_013.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ echo $dll->pop()."\n";
3131
echo $dll->pop()."\n";
3232
?>
3333
--EXPECT--
34-
Offset invalid or out of range
34+
SplDoublyLinkedList::add(): Argument #1 ($index) is out of range
3535
7
3636
7
3737
6

ext/spl/tests/unserialize_errors.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,25 @@ echo "SplDoublyLinkedList:\n";
5959

6060
try {
6161
unserialize('O:19:"SplDoublyLinkedList":0:{}');
62-
} catch (Exception $e) {
62+
} catch (Error $e) {
6363
echo $e->getMessage(), "\n";
6464
}
6565

6666
try {
6767
unserialize('O:19:"SplDoublyLinkedList":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
68-
} catch (Exception $e) {
68+
} catch (Error $e) {
6969
echo $e->getMessage(), "\n";
7070
}
7171

7272
try {
7373
unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
74-
} catch (Exception $e) {
74+
} catch (Error $e) {
7575
echo $e->getMessage(), "\n";
7676
}
7777

7878
try {
7979
unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
80-
} catch (Exception $e) {
80+
} catch (Error $e) {
8181
echo $e->getMessage(), "\n";
8282
}
8383

0 commit comments

Comments
 (0)