@@ -535,38 +535,14 @@ describe('Wrapped PHP arrays accessed from JavaScript', function() {
535535 } ) ;
536536 it ( 'can be passed by reference' , function ( ) {
537537 return test ( function ( arr ) {
538- arr . offsetSet ( 1 , 2 ) ;
539- arr . offsetSet ( 'foo' , 'bar' ) ;
540- // XXX make the below work.
541- // `arr[1] = 2;`
542- // `arr['foo'] = 'bar';`
538+ arr [ 1 ] = 2 ;
539+ arr . set ( 'foo' , 'bar' ) ;
543540 } , [
544541 'call_user_func(function() {' ,
545- // XXX this `wrap` class should be built-in as Js\ArrayByRef
546- ' class wrap implements ArrayAccess, Countable {' ,
547- ' private $a;' ,
548- ' public function __construct(&$a) { $this->a =& $a; }' ,
549- ' public function offsetSet($offset, $value) {' ,
550- ' if (is_null($offset)) { $this->a[] = $value; }' ,
551- ' else { $this->a[$offset] = $value; }' ,
552- ' }' ,
553- ' public function offsetExists($offset) {' ,
554- ' return isset($this->a[$offset]);' ,
555- ' }' ,
556- ' public function offsetUnset($offset) {' ,
557- ' unset($this->a[$offset]);' ,
558- ' }' ,
559- ' public function offsetGet($offset) {' ,
560- ' return isset($this->a[$offset]) ? $this->a[$offset] : null;' ,
561- ' }' ,
562- ' public function count() {' ,
563- ' return count($this->a);' ,
564- ' }' ,
565- ' }' ,
566542 ' $a = array("a" => "b");' ,
567543 ' $b = $a;' ,
568544 ' $ctxt = $_SERVER["CONTEXT"];' ,
569- ' $ctxt->jsfunc(new wrap ($a));' ,
545+ ' $ctxt->jsfunc(new Js\\ByRef ($a));' ,
570546 ' var_dump($a);' ,
571547 ' var_dump($b);' ,
572548 '})' ,
0 commit comments