- Timestamp:
- 10/04/2007 17:54:50 (14 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/CHANGELOG
r274 r275 9 9 - added support for loading explicitly typed DateTime (with timestamp-compatible value) 10 10 - fixed loading of maps with numeric keys 11 - added support for loading sequences into classes which implement ArrayAccess 11 12 12 13 - version: 0.9.1 -
trunk/ext/php/TODO
r274 r275 8 8 load: 9 9 - objects: 10 - "!php/hash:YAML::ClassName" 11 - "!php/array:YAML::ClassName" 12 - "!php:YAML::ClassName (?)" 10 - "!php/hash:ClassName" 11 - "!php:ClassName (?)" 13 12 - allow user to assign custom handler for loading any other type of objects (java, ruby, etc.) 14 13 dump: … … 17 16 - Iterator: 18 17 as: map 19 label: "!php/hash: YAML::ClassName"18 label: "!php/hash:ClassName" 20 19 - ArrayAccess: 21 20 as: sequence 22 label: "!php/array: YAML::ClassName"21 label: "!php/array:ClassName" 23 22 - Generic object (?) -
trunk/ext/php/phpext.c
r274 r275 396 396 } 397 397 } else if (strncmp(n->type_id, "php/array:", 10) == 0) { 398 /* some classm which implements ArrayAccess */ 398 /* some class which implements ArrayIterator */ 399 size_t i; 399 400 size_t classname_len = strlen(n->type_id) - 10; 400 401 char *classname = emalloc(classname_len + 1); … … 410 411 } 411 412 412 if (0 == instanceof_function_ex(*ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { 413 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "Class %s doesn't implement ArrayAccess on line %d, col %d: '%s'", classname, p->linect, p->cursor - p->lineptr, p->lineptr); 413 if (0 != instanceof_function_ex(*ce, zend_ce_arrayaccess, 1 TSRMLS_CC)) { 414 object_init_ex(o, *ce); 415 416 for (i = 0; i < n->data.list->idx; i++) { 417 SYMID oid = syck_seq_read(n, i); 418 zval *o2; 419 zval *key; 420 421 syck_lookup_sym(p, oid, (char **) &o2); /* retrieving child-node */ 422 423 MAKE_STD_ZVAL(key); 424 ZVAL_LONG(key, i); 425 426 zend_call_method_with_2_params(&o, *ce, NULL, "offsetset", NULL, key, o2); 427 zval_ptr_dtor(&o2); 428 efree(key); 429 } 430 } else { 431 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "Class %s doesn't implement ArrayIterator on line %d, col %d: '%s'", classname, p->linect, p->cursor - p->lineptr, p->lineptr); 414 432 efree(classname); 415 433 break; 416 434 } 417 435 418 /* 419 * TODO: add filling of ArrayAccess object with values 420 */ 421 array_init(o); 436 422 437 423 438 efree(classname); -
trunk/ext/php/phpunit-tests/TestLoad.php
r274 r275 151 151 152 152 // ArrayObject implements ArrayAccess: OK 153 $this->assertEquals(syck_load('!php/array:ArrayObject []'), array()); 153 $this->assertEquals(syck_load('!php/array:ArrayObject []'), new ArrayObject()); 154 $this->assertEquals(syck_load('!php/array:ArrayObject [1, 2, 3]'), new ArrayObject(array(1, 2, 3))); 154 155 155 156 // SyckTestSomeClass doesn't implement ArrayAccess: FAILURE