}
}
if ( is_array( $value ) ) {
+ // Work around PHP bug 45959 by copying to a temporary
+ // (in this case, foreach gets $k === "1" but $tmp[$k] assigns as if $k === 1)
+ $tmp = array();
foreach ( $value as $k => $v ) {
- $value[$k] = self::validateValue( $v );
+ $tmp[$k] = self::validateValue( $v );
}
+ $value = $tmp;
} elseif ( is_float( $value ) && !is_finite( $value ) ) {
throw new InvalidArgumentException( "Cannot add non-finite floats to ApiResult" );
} elseif ( is_string( $value ) ) {
0 => "foo\xef\xbf\xbdbar",
1 => "\xc3\xa1",
), $arr );
+
+ $obj = new stdClass;
+ $obj->{'1'} = 'one';
+ $arr = array();
+ ApiResult::setValue( $arr, 'foo', $obj );
+ $this->assertSame( array(
+ 'foo' => array(
+ 1 => 'one',
+ ApiResult::META_TYPE => 'assoc',
+ )
+ ), $arr );
}
/**
1 => "\xc3\xa1",
ApiResult::META_TYPE => 'assoc',
), $result->getResultData() );
+
+ $result = new ApiResult( 8388608 );
+ $obj = new stdClass;
+ $obj->{'1'} = 'one';
+ $arr = array();
+ $result->addValue( $arr, 'foo', $obj );
+ $this->assertSame( array(
+ 'foo' => array(
+ 1 => 'one',
+ ApiResult::META_TYPE => 'assoc',
+ ),
+ ApiResult::META_TYPE => 'assoc',
+ ), $result->getResultData() );
}
/**