From: Marcus Boerger Date: Wed, 26 Nov 2003 23:28:35 +0000 (+0000) Subject: Cleanup X-Git-Tag: php-5.0.0b3RC1~581 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f2f745393096c27e0aa501d6076f770e9792333;p=php Cleanup --- diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 3ed11067cd..0f8ca2da62 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -62,11 +62,6 @@ zend_module_entry spl_module_entry = { }; /* }}} */ -zend_class_entry *spl_ce_recursive_it; -zend_class_entry *spl_ce_recursive_it_it; -zend_class_entry *spl_ce_array_read; -zend_class_entry *spl_ce_array_access; - /* {{{ spl_functions_none */ function_entry spl_functions_none[] = { @@ -117,22 +112,6 @@ PHP_MSHUTDOWN_FUNCTION(spl) { SPL_DEBUG(fprintf(stderr, "%s\n", "Shutting down SPL");) -#ifdef SPL_FOREACH - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FE_RESET); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FE_FETCH); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_SWITCH_FREE); -#endif - -#if defined(SPL_ARRAY_READ) | defined(SPL_ARRAY_WRITE) - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_R); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_W); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_RW); -#endif - -#ifdef SPL_ARRAY_WRITE - ZEND_EXECUTE_HOOK_RESTORE(ZEND_ASSIGN_DIM); -#endif /* SPL_ARRAY_WRITE */ - return SUCCESS; } /* }}} */ @@ -141,30 +120,8 @@ PHP_MSHUTDOWN_FUNCTION(spl) */ PHP_MINFO_FUNCTION(spl) { -#ifdef SPL_FOREACH - char *foreach = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *foreach = "beta, not hooked"; -#endif -#ifdef SPL_ARRAY_READ - char *array_read = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *array_read = "beta, not hooked"; -#endif -#ifdef SPL_ARRAY_WRITE - char *array_write = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *array_write = "beta, not hooked"; -#endif /* SPL_ARRAY_WRITE */ - php_info_print_table_start(); php_info_print_table_header(2, "SPL support", "enabled"); - php_info_print_table_row(2, "iterator", foreach); - php_info_print_table_row(2, "forward", foreach); - php_info_print_table_row(2, "sequence", foreach); - php_info_print_table_row(2, "assoc", foreach); - php_info_print_table_row(2, "ArrayRead", array_read); - php_info_print_table_row(2, "ArrayAccess", array_write); php_info_print_table_end(); } /* }}} */ diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index 474da85c01..b2fd7709cb 100755 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -42,37 +42,8 @@ PHP_RINIT_FUNCTION(spl); PHP_RSHUTDOWN_FUNCTION(spl); PHP_MINFO_FUNCTION(spl); -#define ZEND_EXECUTE_HOOK_PTR(name) \ - opcode_handler_t handler_ ## name - -#define ZEND_EXECUTE_HOOK(name) \ - spl_globals->handler_ ## name = zend_opcode_handlers[name]; \ - zend_opcode_handlers[name] = spl_handler_ ## name - -#define ZEND_EXECUTE_HOOK_RESTORE(name) \ - zend_opcode_handlers[name] = SPL_G(handler_ ## name) - -#define ZEND_EXECUTE_HOOK_ORIGINAL(name) \ - return SPL_G(handler_ ## name)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) - -#define ZEND_EXECUTE_HOOK_FUNCTION(name) \ - int spl_handler_ ## name(ZEND_OPCODE_HANDLER_ARGS) ZEND_BEGIN_MODULE_GLOBALS(spl) -#ifdef SPL_FOREACH - ZEND_EXECUTE_HOOK_PTR(ZEND_FE_RESET); - ZEND_EXECUTE_HOOK_PTR(ZEND_FE_FETCH); - ZEND_EXECUTE_HOOK_PTR(ZEND_SWITCH_FREE); -#endif -#if defined(SPL_ARRAY_READ) | defined(SPL_ARRAY_WRITE) - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_R); - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_W); - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_RW); -#endif -#ifdef SPL_ARRAY_WRITE - ZEND_EXECUTE_HOOK_PTR(ZEND_ASSIGN_DIM); - ZEND_EXECUTE_HOOK_PTR(ZEND_UNSET_DIM_OBJ); -#endif ZEND_END_MODULE_GLOBALS(spl) #ifdef ZTS diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 9ae571c477..42b9252aea 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -303,8 +303,8 @@ PHP_MINIT_FUNCTION(spl_array) } /* }}} */ -/* {{{ proto void spl_array::__construct(array|object ar = array()) - proto void spl_array_it::__construct(array|object ar = array()) +/* {{{ proto void ArrayObject::__construct(array|object ar = array()) + proto void ArrayIterator::__construct(array|object ar = array()) Cronstructs a new array iterator from a path. */ SPL_METHOD(Array, __construct) { @@ -338,7 +338,7 @@ SPL_METHOD(Array, __construct) } /* }}} */ -/* {{{ proto spl_array_it|NULL ArrayObject::getIterator() +/* {{{ proto ArrayIterator ArrayObject::getIterator() Create a new iterator from a ArrayObject instance */ SPL_METHOD(Array, getIterator) { @@ -381,7 +381,7 @@ ZEND_API int spl_hash_pos_exists(spl_array_object * intern TSRMLS_DC) } /* }}} */ -/* {{{ proto void spl_array_it::rewind() +/* {{{ proto void ArrayIterator::rewind() Rewind array back to the start */ SPL_METHOD(Array, rewind) { @@ -398,7 +398,7 @@ SPL_METHOD(Array, rewind) } /* }}} */ -/* {{{ proto mixed|false spl_array_it::current() +/* {{{ proto mixed|false ArrayIterator::current() Return current array entry */ SPL_METHOD(Array, current) { @@ -425,7 +425,7 @@ SPL_METHOD(Array, current) } /* }}} */ -/* {{{ proto mixed|false spl_array_it::key() +/* {{{ proto mixed|false ArrayIterator::key() Return current array key */ SPL_METHOD(Array, key) { @@ -459,7 +459,7 @@ SPL_METHOD(Array, key) } /* }}} */ -/* {{{ proto void spl_array_it::next() +/* {{{ proto void ArrayIterator::next() Move to next entry */ SPL_METHOD(Array, next) { @@ -480,7 +480,7 @@ SPL_METHOD(Array, next) } /* }}} */ -/* {{{ proto bool spl_array_it::hasMore() +/* {{{ proto bool ArrayIterator::hasMore() Check whether array contains more entries */ SPL_METHOD(Array, hasMore) { diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h index a753a9339e..40e887e6b0 100755 --- a/ext/spl/spl_engine.h +++ b/ext/spl/spl_engine.h @@ -33,15 +33,6 @@ static inline zend_class_entry *spl_get_class_entry(zval *obj TSRMLS_DC) } /* }}} */ -#define spl_call_method_0(obj, obj_ce, fn_proxy, function_name, fname_len, retval) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 0, NULL, NULL TSRMLS_CC) - -#define spl_call_method_1(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 1, arg1, NULL TSRMLS_CC) - -#define spl_call_method_2(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1, arg2) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 2, arg1, arg2 TSRMLS_CC) - void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRMLS_DC); int spl_instantiate_arg_ex1(zend_class_entry *pce, zval **retval, int alloc, zval *arg1 TSRMLS_DC); int spl_instantiate_arg_ex2(zend_class_entry *pce, zval **retval, int alloc, zval *arg1, zval *arg2 TSRMLS_DC); diff --git a/ext/spl/tests/array_access_001.phpt b/ext/spl/tests/array_access_001.phpt deleted file mode 100755 index 2c81204f54..0000000000 --- a/ext/spl/tests/array_access_001.phpt +++ /dev/null @@ -1,163 +0,0 @@ ---TEST-- -SPL: array_access ---SKIPIF-- - ---FILE-- -'3rd', '4th'=>4); - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - return $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -echo "===unset===\n"; -var_dump($obj->a); -unset($obj[2]); -unset($obj['4th']); -unset($obj[7]); -unset($obj['8th']); -var_dump($obj->a); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_001.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_001.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -===unset=== -array(6) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - [2]=> - string(3) "3rd" - ["4th"]=> - string(11) "Changed 4th" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -c::del(2) -c::del(4th) -c::del(7) -c::del(8th) -array(4) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -Done diff --git a/ext/spl/tests/array_access_002.phpt b/ext/spl/tests/array_access_002.phpt deleted file mode 100755 index 133e6f3f4a..0000000000 --- a/ext/spl/tests/array_access_002.phpt +++ /dev/null @@ -1,137 +0,0 @@ ---TEST-- -SPL: array_access without return in set() ---SKIPIF-- - ---FILE-- -'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - /* return */ $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_002.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_002.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -Done diff --git a/ext/spl/tests/array_iterator.phpt b/ext/spl/tests/array_iterator.phpt index 751e623d1c..ef5a79819d 100755 --- a/ext/spl/tests/array_iterator.phpt +++ b/ext/spl/tests/array_iterator.phpt @@ -1,5 +1,5 @@ --TEST-- -SPL: spl_array_iterator +SPL: ArrayIterator --SKIPIF-- --FILE-- @@ -8,7 +8,7 @@ SPL: spl_array_iterator echo "==Normal==\n"; $arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array($arr); +$obj = new ArrayObject($arr); foreach($obj as $ak=>$av) { foreach($obj as $bk=>$bv) { @@ -22,7 +22,7 @@ foreach($obj as $ak=>$av) { echo "==UseRef==\n"; $arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); +$obj = new ArrayObject(&$arr); foreach($obj as $ak=>$av) { foreach($obj as $bk=>$bv) { @@ -33,7 +33,7 @@ foreach($obj as $ak=>$av) { echo "==Modify==\n"; $arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); +$obj = new ArrayObject(&$arr); foreach($obj as $ak=>$av) { foreach($obj as $bk=>$bv) { @@ -47,7 +47,7 @@ foreach($obj as $ak=>$av) { echo "==Delete==\n"; $arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); +$obj = new ArrayObject(&$arr); foreach($obj as $ak=>$av) { foreach($obj as $bk=>$bv) { @@ -61,7 +61,7 @@ foreach($obj as $ak=>$av) { echo "==Change==\n"; $arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); +$obj = new ArrayObject(&$arr); foreach($obj as $ak=>$av) { foreach($obj as $bk=>$bv) { @@ -112,11 +112,11 @@ echo "Done\n"; 1=>1 - 0=>0 1=>1 - 1=>1 -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d +Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d 1=>1 - 0=>0 1=>1 - 2=>2 -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d +Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d 0=>0 - 0=>0 0=>0 - 2=>2 2=>2 - 0=>0 @@ -128,11 +128,11 @@ Notice: spl_array_it::next(): Array was modified outside object and internal pos 1=>1 - 0=>0 1=>1 - 1=>1 -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d +Notice: ArrayIterator::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d +Notice: ArrayIterator::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d +Notice: ArrayIterator::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d +Notice: ArrayIterator::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d Done diff --git a/ext/spl/tests/array.phpt b/ext/spl/tests/array_object.phpt similarity index 77% rename from ext/spl/tests/array.phpt rename to ext/spl/tests/array_object.phpt index fcaaa65ee5..1ba6101036 100755 --- a/ext/spl/tests/array.phpt +++ b/ext/spl/tests/array_object.phpt @@ -1,5 +1,5 @@ --TEST-- -SPL: array +SPL: ArrayObject --SKIPIF-- --FILE-- @@ -70,15 +70,15 @@ object(ArrayObject)#1 (5) { } int(0) -Notice: Undefined offset: 6 in %sarray.php on line %d +Notice: Undefined offset: 6 in %sarray_object.php on line %d NULL -Notice: Undefined index: b in %sarray.php on line %d +Notice: Undefined index: b in %sarray_object.php on line %d NULL -Notice: Undefined offset: 7 in %sarray.php on line %d +Notice: Undefined offset: 7 in %sarray_object.php on line %d -Notice: Undefined index: c in %sarray.php on line %d +Notice: Undefined index: c in %sarray_object.php on line %d object(ArrayObject)#1 (2) { [0]=> int(0) diff --git a/ext/spl/tests/array_read.phpt b/ext/spl/tests/array_read.phpt deleted file mode 100755 index 032373d52d..0000000000 --- a/ext/spl/tests/array_read.phpt +++ /dev/null @@ -1,208 +0,0 @@ ---TEST-- -SPL: array_read ---SKIPIF-- - ---FILE-- -'3rd', '4th'=>4); -var_dump($a); - -class external implements spl_array_read { - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new external(); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -echo "INTERNAL\n"; - -class internal implements spl_array_read { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new internal(); - -var_dump($obj->a); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -print "Done\n"; -?> ---EXPECTF-- -EXTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -external::get(0) -string(3) "1st" -external::get(1) -int(1) -external::get(2) -string(3) "3rd" -external::get(4th) -int(4) -external::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -string(3) "1st" -external::exists(1) -external::get(1) -int(1) -external::exists(2) -external::get(2) -string(3) "3rd" -external::exists(4th) -external::get(4th) -int(4) -external::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -1st -external::exists(1) -external::get(1) -1 -external::exists(2) -external::get(2) -3rd -external::exists(4th) -external::get(4th) -4 -INTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -internal::get(0) -string(3) "1st" -internal::get(1) -int(1) -internal::get(2) -string(3) "3rd" -internal::get(4th) -int(4) -internal::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -string(3) "1st" -internal::exists(1) -internal::get(1) -int(1) -internal::exists(2) -internal::get(2) -string(3) "3rd" -internal::exists(4th) -internal::get(4th) -int(4) -internal::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -1st -internal::exists(1) -internal::get(1) -1 -internal::exists(2) -internal::get(2) -3rd -internal::exists(4th) -internal::get(4th) -4 -Done diff --git a/ext/spl/tests/foreach.phpt b/ext/spl/tests/foreach.phpt deleted file mode 100755 index 0a4cd91fb7..0000000000 --- a/ext/spl/tests/foreach.phpt +++ /dev/null @@ -1,202 +0,0 @@ ---TEST-- -SPL: foreach and iterator ---SKIPIF-- - ---FILE-- -num = 0; - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -for ($iter = $t->newIterator(); $iter->hasMore(); $iter->next()) { - echo $iter->current() . "\n"; -} - -$a = array(0,1,2); -foreach($a as $v) { - echo "array:$v\n"; -} - -foreach($t as $v) { - echo "object:$v\n"; -} - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - } -} - -foreach($t as $i => $v) { - echo "object:$i=>$v\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -0 -c_iter::next -c_iter::hasMore = true -c_iter::current -1 -c_iter::next -c_iter::hasMore = true -c_iter::current -2 -c_iter::next -c_iter::hasMore = false -array:0 -array:1 -array:2 -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_break.phpt b/ext/spl/tests/foreach_break.phpt deleted file mode 100755 index 184b762b84..0000000000 --- a/ext/spl/tests/foreach_break.phpt +++ /dev/null @@ -1,90 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- - ---FILE-- -obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_continue.phpt b/ext/spl/tests/foreach_continue.phpt deleted file mode 100755 index 289f67e0a6..0000000000 --- a/ext/spl/tests/foreach_continue.phpt +++ /dev/null @@ -1,102 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- - ---FILE-- -obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } -} - -class c implements spl_iterator { - - public $max = 4; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - if ($v == 0) { - echo "continue outer\n"; - continue; - } - foreach($t as $w) { - if ($w == 1) { - echo "continue inner\n"; - continue; - } - if ($w == 2) { - echo "break inner\n"; - break; - } - echo "double:$v:$w\n"; - } - if ($v == 2) { - echo "break outer\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -continue outer -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -break outer -Done diff --git a/ext/spl/tests/foreach_non_spl.phpt b/ext/spl/tests/foreach_non_spl.phpt deleted file mode 100755 index 71a7cb7f4d..0000000000 --- a/ext/spl/tests/foreach_non_spl.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -SPL: foreach non spl classes ---SKIPIF-- - ---FILE-- -num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$obj = new c2(); - -foreach($obj as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECTF-- -1st try -2nd try -object:max=>3 -object:num=>0 -Done diff --git a/ext/spl/tests/forward.phpt b/ext/spl/tests/forward.phpt deleted file mode 100755 index 8a14a52fe8..0000000000 --- a/ext/spl/tests/forward.phpt +++ /dev/null @@ -1,138 +0,0 @@ ---TEST-- -SPL: forward ---SKIPIF-- - ---FILE-- -num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$i = new c(); - -$implements = class_implements($i); -asort($implements); -$c_info = array(get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements)); -print_r($c_info); -$methods = get_class_methods("spl_forward_assoc"); -sort($methods); -print_r($methods); -$methods = get_class_methods($i); -sort($methods); -print_r($methods); - - -echo "1st try\n"; -foreach($i as $w) { - echo "object:$w\n"; -} - -echo "2nd try\n"; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -echo "3rd try\n"; -$i->num = 0; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - ) - - ) - -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -1st try -c::hasMore -c::current -c::key -object:0 -c::next -c::hasMore -c::current -c::key -object:1 -c::next -c::hasMore -c::current -c::key -object:2 -c::next -c::hasMore -2nd try -c::hasMore -3rd try -c::hasMore -c::current -c::key -object:1st=>0 -c::next -c::hasMore -c::current -c::key -object:2nd=>1 -c::next -c::hasMore -c::current -c::key -object:3rd=>2 -c::next -c::hasMore -Done diff --git a/ext/spl/tests/sequence.phpt b/ext/spl/tests/sequence.phpt deleted file mode 100755 index 34ea7fd8d5..0000000000 --- a/ext/spl/tests/sequence.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -SPL: sequence ---SKIPIF-- - ---FILE-- -obj = $obj; - } - function rewind() { - echo __METHOD__ . "\n"; - $this->num = 0; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->obj->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$t = new c(); -$i = $t->newIterator(); - -$implements_t = class_implements($t); -asort($implements_t); -$implements_i = class_implements($i); -asort($implements_i); - -$c_info = array(get_class($t) => array('inheits' => class_parents($t), 'implements' => $implements_t), - get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements_i)); -print_r($c_info); - -foreach($i as $w) { - echo "object:$w\n"; -} - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_iterator] => spl_iterator - ) - - ) - - [c_iter] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - [spl_sequence] => spl_sequence - [spl_sequence_assoc] => spl_sequence_assoc - ) - - ) - -) -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore -Done \ No newline at end of file