use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class SPLFunctions method class_implements.
public static Memory class_implements(Environment env, TraceInfo trace, Memory object, boolean autoLoad) {
ClassEntity entity;
if (object.isObject()) {
entity = object.toValue(ObjectMemory.class).getReflection();
} else {
entity = env.fetchClass(object.toString(), autoLoad);
}
if (entity == null) {
env.warning(trace, "class_implements(): Class %s does not exist and could not be loaded", object.toString());
return Memory.FALSE;
}
ArrayMemory result = new ArrayMemory();
do {
for (ClassEntity el : entity.getInterfaces().values()) {
result.refOfIndex(el.getName()).assign(el.getName());
}
entity = entity.getParent();
if (entity == null)
break;
} while (true);
return result.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ReflectionFunction method invokeArgs.
@Signature(@Arg(value = "args", type = HintType.ARRAY))
public Memory invokeArgs(Environment env, Memory... args) throws Throwable {
ArrayMemory value = args[0].toValue(ArrayMemory.class);
Memory[] passed = value.values();
return invoke(env, passed);
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class InvokeArgumentHelper method makeVariadic.
public static void makeVariadic(ForeachIterator iterator, ArrayMemory variadicArray, ParameterEntity param, Environment env, TraceInfo trace, int index, String originClassName, String originMethodName) {
while (iterator.next()) {
Memory arg = iterator.getValue();
if (!param.checkTypeHinting(env, arg)) {
invalidType(env, trace, param, index + 1, arg, originClassName, originMethodName);
}
variadicArray.add(makeValue(param, iterator.getValue(), env, trace));
}
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class WrapLocale method __debugInfo.
@Signature
public Memory __debugInfo(Environment env, Memory... args) {
ArrayMemory r = new ArrayMemory();
r.refOfIndex("*language").assign(locale.getLanguage());
r.refOfIndex("*country").assign(locale.getCountry());
r.refOfIndex("*variant").assign(locale.getVariant());
return r.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class MultipleIterator method current.
@Override
@Signature
public Memory current(Environment env, Memory... args) {
if (iterators.size() == 0) {
return Memory.FALSE;
}
ArrayMemory result = new ArrayMemory();
ForeachIterator iterator = iterators.getNewIterator(env);
while (iterator.next()) {
Iterator el = iterator.getValue().toObject(Iterator.class);
if (env.invokeMethodNoThrow(el, "valid").toBoolean()) {
Memory current = env.invokeMethodNoThrow(el, "current");
if ((flags & MIT_KEYS_ASSOC) == MIT_KEYS_ASSOC) {
result.put(iterator.getKey(), current);
} else {
result.add(current);
}
} else {
if ((flags & MIT_NEED_ALL) == MIT_NEED_ALL) {
env.exception(InvalidArgumentException.class, "One of iterators is not valid");
}
}
}
return result.toConstant();
}
Aggregations