use of php.runtime.lang.ForeachIterator in project jphp by jphp-compiler.
the class ContextValueProvider method processArray.
protected void processArray(Element property, ArrayMemory array, Set<Integer> used, boolean forObjects) {
if (array.size() != 0) {
property.setAttribute("children", "1");
}
property.setAttribute("numchildren", String.valueOf(array.size()));
ForeachIterator iterator = array.foreachIterator(false, false);
int count = 0;
while (iterator.next()) {
if (iterator.getValue().isUndefined()) {
continue;
}
Element value = getProperty(null, iterator.getValue().toValue(), used);
String key = iterator.getKey().toString();
if (forObjects) {
key = key.replace('\0', '*');
if (key.startsWith("***")) {
key = key.substring(3);
}
}
value.setAttribute("name", key);
property.appendChild(value);
count++;
if (maxChildren > 0 && count >= maxChildren) {
break;
}
}
}
use of php.runtime.lang.ForeachIterator in project jphp by jphp-compiler.
the class PHttpResponse method setRawCookies.
@Signature
public void setRawCookies(ArrayMemory rawCookies) {
this.rawCookies = rawCookies;
ArrayMemory cookies = new ArrayMemory();
ForeachIterator iterator = rawCookies.foreachIterator(false, false);
while (iterator.next()) {
cookies.putAsKeyString(iterator.getStringKey(), iterator.getValue().valueOfIndex("value").toImmutable());
}
this.cookies = cookies;
}
use of php.runtime.lang.ForeachIterator in project jphp by jphp-compiler.
the class ArrayFunctions method recursive_count.
private static int recursive_count(Environment env, TraceInfo trace, ArrayMemory array, Set<Integer> used) {
ForeachIterator iterator = array.foreachIterator(false, false);
int size = array.size();
while (iterator.next()) {
Memory el = iterator.getValue();
if (el.isArray()) {
if (used == null)
used = new HashSet<>();
int pointer = el.getPointer();
if (!used.add(pointer)) {
env.warning(trace, "recursion detected");
} else {
size += recursive_count(env, trace, array, used);
}
used.remove(pointer);
}
}
return size;
}
use of php.runtime.lang.ForeachIterator in project jphp by jphp-compiler.
the class ContextGetCommand method run.
@Override
public void run(Debugger context, CommandArguments args, Document result) {
Element response = createResponse(args, result);
String contextId = args.get("c");
response.setAttribute("context", contextId);
ContextValueProvider contextValueProvider = new ContextValueProvider(context, result);
switch(contextId) {
case "0":
DebugTick tick = context.getRegisteredTick();
ForeachIterator iterator = tick.getLocals().foreachIterator(true, false);
while (iterator.next()) {
Memory value = iterator.getValue().toValue();
if (value.isUndefined()) {
continue;
}
response.appendChild(contextValueProvider.getProperty(iterator.getKey().toString(), value));
}
break;
}
}
use of php.runtime.lang.ForeachIterator in project jphp by jphp-compiler.
the class ItemsUtils method has.
@Signature({ @Arg(value = "collection", type = HintType.TRAVERSABLE), @Arg(value = "value"), @Arg(value = "strict", optional = @Optional("false")) })
public static Memory has(Environment env, Memory... args) {
ForeachIterator iterator = args[0].getNewIterator(env);
if (iterator == null) {
return Memory.NULL;
}
Memory needle = args[1];
boolean strict = args[2].toBoolean();
while (iterator.next()) {
if (strict) {
if (needle.identical(iterator.getValue()))
return Memory.TRUE;
} else {
if (needle.equal(iterator.getValue()))
return Memory.TRUE;
}
}
return Memory.FALSE;
}
Aggregations