@Override @Signature({@Arg("name")}) public Memory load(Environment env, Memory... args) throws Throwable { String name = args[0].toString();
if (!arg.value().isEmpty()) { param.setName(arg.value()); param.setType(arg.type()); param.setReference(arg.reference()); if (arg.nativeType() != IObject.class) { param.setTypeNativeClass(arg.nativeType()); if (!arg.typeClass().isEmpty()) { param.setTypeClass(arg.typeClass()); if (arg.optional().exists() || !arg.optional().value().isEmpty() || (arg.type() != HintType.STRING && !arg.optional().value().isEmpty())){ param.setDefaultValue(MemoryUtils.valueOf(arg.optional().value(), arg.optional().type()));
@Signature public PMarkdownOptions addWikiLinkExtension(@Arg(type = HintType.ARRAY) @Optional("null") Memory options) { parserExtensions.add(WikiLinkExtension.create());
@Signature public PMarkdownOptions addEmojiExtension(@Arg(type = HintType.ARRAY) @Optional("null") Memory options) { parserExtensions.add(EmojiExtension.create()); Memory imageType = options.valueOfIndex("imageType"); if (!imageType.isNull()) { this.options.set(EmojiExtension.USE_IMAGE_TYPE, EmojiImageType.valueOf(imageType.toString())); } Memory shortcutType = options.valueOfIndex("shortcutType"); if (!shortcutType.isNull()) { this.options.set(EmojiExtension.USE_SHORTCUT_TYPE, EmojiShortcutType.valueOf(shortcutType.toString())); } Memory imagePath = options.valueOfIndex("imagePath"); if (!shortcutType.isNull()) { this.options.set(EmojiExtension.ROOT_IMAGE_PATH, imagePath.toString()); } Memory imageClass = options.valueOfIndex("imageClass"); if (!shortcutType.isNull()) { this.options.set(EmojiExtension.ATTR_IMAGE_CLASS, imageClass.toString()); } Memory imageSize = options.valueOfIndex("imageSize"); if (!shortcutType.isNull()) { this.options.set(EmojiExtension.ATTR_IMAGE_SIZE, imageSize.toString()); } return this; }
protected void onWrapArgument(ParameterEntity param, Reflection.Arg arg) { param.setReference(arg.reference()); param.setType(arg.type()); param.setName(arg.value()); param.setNullable(arg.nullable()); if (arg.typeEnum() != Enum.class) { param.setTypeEnum(arg.typeEnum()); } param.setDefaultValue(null); if (arg.optional().exists() || !arg.optional().value().isEmpty() || (arg.type() != HintType.STRING && !arg.optional().value().isEmpty())){ param.setDefaultValue(MemoryUtils.valueOf(arg.optional().value(), arg.optional().type())); } if (!arg.typeClass().isEmpty()) param.setTypeClass(arg.typeClass()); else if (arg.nativeType() != IObject.class) { param.setTypeClass(ReflectionUtils.getClassName(arg.nativeType())); } }
@Signature({ @Arg("class"), @Arg("name"), }) public Memory __construct(Environment env, Memory... args) { String className = args[0].toString(); String constName = args[1].toString(); setProp("class", className); setProp("name", constName); ClassEntity classEntity = env.fetchClass(className); entity = classEntity.findConstant(constName); if (entity == null) { env.exception(ReflectionException.class, "Class Constant %s::%s does not exist", className, constName); } return Memory.UNDEFINED; }
@Signature({@Arg("name")}) abstract public Memory load(Environment env, Memory... args) throws Throwable;
@Signature({ @Arg(value = "inserts", type = HintType.ARRAY), @Arg("allCountLines") }) public Memory insertLines(Environment env, Memory... args) { ArrayMemory _inserts = args[0].toValue(ArrayMemory.class); int[][] inserts = new int[_inserts.size()][]; ForeachIterator iterator = _inserts.getNewIterator(env); int i = 0; while (iterator.next()) { Memory value = iterator.getValue(); inserts[i++] = new int[] {value.valueOfIndex(0).toInteger(), value.valueOfIndex(1).toInteger()}; } getWrappedObject().insertLines(inserts, args[1].toInteger()); return Memory.NULL; }
@Signature public static void setOut(Environment env, @Arg(typeClass = "php\\io\\Stream", nullable = true) Memory stream, Memory encoding) throws UnsupportedEncodingException { if (stream.isNull()) { System.setOut(null); } else { if (encoding.isNotNull()) { System.setOut(new PrintStream(Stream.getOutputStream(env, stream), true, encoding.toString())); } else { System.setOut(new PrintStream(Stream.getOutputStream(env, stream), true)); } } }
@Signature(@Arg("name")) public Memory addClass(Environment env, Memory... args) { return pkg.addClass(args[0].toString()) ? Memory.TRUE : Memory.FALSE; }
@Signature(@Arg("name")) public Memory hasFunction(Environment env, Memory... args) { return pkg.hasFunction(args[0].toString()) ? Memory.TRUE : Memory.FALSE; }
@Signature(@Arg(value = "flags", optional = @Optional("0"))) public Memory __construct(Environment env, Memory... args) { return Memory.NULL; }
@Signature(@Arg("name")) public Memory hasConstant(Environment env, Memory... args) { return pkg.hasConstant(args[0].toString()) ? Memory.TRUE : Memory.FALSE; }
@Signature(@Arg("name")) public Memory hasClass(Environment env, Memory... args) { return pkg.hasClass(args[0].toString()) ? Memory.TRUE : Memory.FALSE; }
@Signature public PMarkdownOptions addSubscriptExtension(@Arg(type = HintType.ARRAY) @Optional("null") Memory options) { parserExtensions.add(SubscriptExtension.create()); Memory htmlOpen = options.valueOfIndex("htmlOpen"); if (htmlOpen.isNotNull()) { this.options.set(SubscriptExtension.SUBSCRIPT_STYLE_HTML_OPEN, htmlOpen.toString()); } Memory htmlClose = options.valueOfIndex("htmlClose"); if (htmlOpen.isNotNull()) { this.options.set(SubscriptExtension.SUBSCRIPT_STYLE_HTML_CLOSE, htmlClose.toString()); } return this; }
@Signature(@Arg(value = "flags", optional = @Optional("0"))) public Memory __construct(Environment env, Memory... args) { DumperOptions options = new DumperOptions(); int flags = args[0].toInteger(); options.setPrettyFlow((flags & SERIALIZE_PRETTY_FLOW) == SERIALIZE_PRETTY_FLOW); options.setDefaultFlowStyle((flags & SERIALIZE_PRETTY_FLOW) == SERIALIZE_PRETTY_FLOW ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.AUTO); options.setCanonical((flags & SERIALIZE_CANONICAL) == SERIALIZE_CANONICAL); options.setExplicitStart((flags & SERIALIZE_EXPLICIT_START) == SERIALIZE_EXPLICIT_START); options.setExplicitEnd((flags & SERIALIZE_EXPLICIT_END) == SERIALIZE_EXPLICIT_END); options.setSplitLines(!((flags & SERIALIZE_NOT_SPLIT_LINES) == SERIALIZE_NOT_SPLIT_LINES)); yaml = new Yaml(options); return Memory.NULL; }
@Signature private void makeReject(Environment env, @Arg(typeClass = "Throwable") Memory error) throws Exception { if (this.state != State.PENDING) { throw new IllegalStateException("This promise is already resolved, and you\'re not allowed to resolve a promise more than once"); } this.state = State.REJECTED; this.value = error; for (Subscriber subscriber : subscribers) { this.invokeCallback(env, subscriber.subPromise, subscriber.onRejected); } }