Search in sources :

Example 36 with ClassEntity

use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.

the class WrapEnvironment method importClass.

@Signature(@Arg("className"))
public Memory importClass(Environment env, Memory... args) throws Throwable {
    ClassEntity classEntity = env.fetchClass(args[0].toString());
    if (classEntity == null) {
        env.exception(Messages.ERR_CLASS_NOT_FOUND.fetch(args[0]));
        return Memory.NULL;
    }
    environment.registerClass(classEntity);
    return Memory.NULL;
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity)

Example 37 with ClassEntity

use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.

the class ReflectionClass method getProperties.

@Signature(@Arg(value = "filter", optional = @Optional("NULL")))
public Memory getProperties(Environment env, Memory... args) {
    int mod = args[0].isNull() ? -1 : args[0].toInteger();
    ArrayMemory result = new ArrayMemory();
    ClassEntity classEntity = env.fetchClass("ReflectionProperty");
    if (mod == -1 || (mod & ReflectionProperty.IS_STATIC) == ReflectionProperty.IS_STATIC) {
        for (PropertyEntity e : entity.getStaticProperties()) {
            ReflectionProperty prop = new ReflectionProperty(env, classEntity);
            prop.setEntity(e);
            result.add(new ObjectMemory(prop));
        }
    }
    for (PropertyEntity e : entity.getProperties()) {
        if (checkModifiers(e, mod)) {
            ReflectionProperty prop = new ReflectionProperty(env, classEntity);
            prop.setEntity(e);
            result.add(new ObjectMemory(prop));
        }
    }
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ClassEntity(php.runtime.reflection.ClassEntity) PropertyEntity(php.runtime.reflection.PropertyEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 38 with ClassEntity

use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.

the class ReflectionClass method getProperty.

@Signature(@Arg("name"))
public Memory getProperty(Environment env, Memory... args) {
    String name = args[0].toString();
    PropertyEntity e = entity.findProperty(name);
    if (e == null)
        e = entity.findStaticProperty(name);
    if (e == null)
        return Memory.NULL;
    ClassEntity classEntity = env.fetchClass("ReflectionProperty");
    ReflectionProperty prop = new ReflectionProperty(env, classEntity);
    prop.setEntity(e);
    return new ObjectMemory(prop);
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) PropertyEntity(php.runtime.reflection.PropertyEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 39 with ClassEntity

use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.

the class ReflectionClass method getStaticProperties.

@Signature
public Memory getStaticProperties(Environment env, Memory... args) {
    ArrayMemory result = new ArrayMemory();
    ClassEntity classEntity = env.fetchClass("ReflectionProperty");
    for (PropertyEntity e : entity.getStaticProperties()) {
        ReflectionProperty prop = new ReflectionProperty(env, classEntity);
        prop.setEntity(e);
        result.add(new ObjectMemory(prop));
    }
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ClassEntity(php.runtime.reflection.ClassEntity) PropertyEntity(php.runtime.reflection.PropertyEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 40 with ClassEntity

use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.

the class ReflectionClass method implementsInterface.

@Signature(@Arg("interface"))
public Memory implementsInterface(Environment env, Memory... args) {
    String name = args[0].toString();
    ClassEntity e = env.fetchClass(name, true);
    if (!e.isInterface())
        exception(env, "Interface %s is a Class", name);
    if (!entity.isInstanceOf(e))
        return Memory.FALSE;
    return env.fetchClass(name).isInterface() ? Memory.TRUE : Memory.FALSE;
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity)

Aggregations

ClassEntity (php.runtime.reflection.ClassEntity)54 ObjectMemory (php.runtime.memory.ObjectMemory)21 Memory (php.runtime.Memory)14 ArrayMemory (php.runtime.memory.ArrayMemory)14 PropertyEntity (php.runtime.reflection.PropertyEntity)10 MethodEntity (php.runtime.reflection.MethodEntity)9 StringMemory (php.runtime.memory.StringMemory)8 ConstantEntity (php.runtime.reflection.ConstantEntity)5 FunctionEntity (php.runtime.reflection.FunctionEntity)5 CriticalException (php.runtime.exceptions.CriticalException)4 Closure (php.runtime.lang.Closure)4 IObject (php.runtime.lang.IObject)4 ReferenceMemory (php.runtime.memory.ReferenceMemory)4 ClosureEntity (php.runtime.reflection.helper.ClosureEntity)4 GeneratorEntity (php.runtime.reflection.helper.GeneratorEntity)4 ForeachIterator (php.runtime.lang.ForeachIterator)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2