use of php.runtime.lang.StdClass in project jphp by jphp-compiler.
the class JsonFunctionsTest method testObjectJsonDecode.
@Test
public void testObjectJsonDecode() {
Memory r = JsonFunctions.json_decode(env, "{\"x\":100, \"y\":500}");
assertTrue(r.instanceOf(StdClass.class));
StdClass stdClass = r.toObject(StdClass.class);
assertEquals(2, stdClass.getProperties().size());
assertEquals(100, stdClass.getProperties().valueOfIndex("x").toLong());
assertEquals(500, stdClass.getProperties().valueOfIndex("y").toLong());
}
use of php.runtime.lang.StdClass in project jphp by jphp-compiler.
the class ArrayMemory method toObject.
@Override
public Memory toObject(Environment env) {
StdClass stdClass = new StdClass(env);
ArrayMemory props = stdClass.getProperties();
ForeachIterator iterator = getNewIterator(env, false, false);
while (iterator.next()) {
props.refOfIndex(null, iterator.getMemoryKey()).assign(iterator.getValue());
}
return new ObjectMemory(stdClass);
}
Aggregations