use of php.runtime.reflection.PropertyEntity in project jphp by jphp-compiler.
the class ReflectionClass method getStaticPropertyValue.
@Signature(@Arg("name"))
public Memory getStaticPropertyValue(Environment env, Memory... args) {
String name = args[0].toString();
PropertyEntity e = entity.findStaticProperty(name);
if (e == null) {
exception(env, Messages.ERR_UNDEFINED_PROPERTY.fetch(entity.getName(), name));
return Memory.NULL;
}
if (!e.isDefault())
return Memory.FALSE;
return e.getDefaultValue(env).toImmutable();
}
use of php.runtime.reflection.PropertyEntity in project jphp by jphp-compiler.
the class PropertyDumper method load.
@Override
public PropertyEntity load(InputStream input) throws IOException {
PropertyEntity property = new PropertyEntity(context);
DumpInputStream data = new DumpInputStream(input);
String docComment = data.readUTF();
if (!docComment.isEmpty()) {
property.setDocComment(new DocumentComment(docComment));
}
property.setStatic(data.readBoolean());
property.setModifier(data.readModifier());
property.setName(data.readName());
property.setTrace(data.readTrace(context));
// typed
property.setNullable(data.readBoolean());
property.setType(data.readHintType());
String typeClass = data.readName();
if (typeClass != null && !typeClass.isEmpty()) {
property.setTypeClass(typeClass);
}
property.setDefault(data.readBoolean());
property.setDefaultValue(data.readMemory());
byte[] raw = data.readRawData();
return property;
}
use of php.runtime.reflection.PropertyEntity 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);
}
use of php.runtime.reflection.PropertyEntity 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();
}
use of php.runtime.reflection.PropertyEntity 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();
}
Aggregations