php.runtime.Memory.toString()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中php.runtime.Memory.toString()方法的一些代码示例,展示了Memory.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.toString()方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:toString

Memory.toString介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Override
  public boolean apply(Memory keyValue, Memory value, Memory keyComparable, Memory comparable) {
    return value.toString().equals(comparable.toString());
  }
});

代码示例来源:origin: jphp-group/jphp

@FastMethod
@Signature({@Arg("string"), @Arg("target"), @Arg("replacement")})
public static Memory replace(Environment env, Memory... args) {
  String target = args[1].toString();
  String replacement = args[2].toString();
  if (target.length() == 1 && replacement.length() == 1) {
    return StringMemory.valueOf(args[0].toString().replace(target.charAt(0), replacement.charAt(0)));
  } else {
    return StringMemory.valueOf(args[0].toString().replace(target, replacement));
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
  public String toString() {
    if (__class__.methodMagicToString != null) {
      Environment environment = getEnvironment();

      if (environment != null) {
        return environment.invokeMethodNoThrow(this, "__toString").toString();
      }
    }

    return super.toString();
  }
}

代码示例来源:origin: jphp-group/jphp

@FastMethod
@Signature({@Arg("string")})
public static Memory upperFirst(Environment env, Memory... args) {
  String s = args[0].toString();
  if (s.length() > 0) {
    s = Character.toUpperCase(s.charAt(0)) + s.substring(1);
  }
  return StringMemory.valueOf(s);
}

代码示例来源:origin: jphp-group/jphp

@FastMethod
@Signature({@Arg("string")})
public static Memory lowerFirst(Environment env, Memory... args) {
  String s = args[0].toString();
  if (s.length() > 0) {
    s = Character.toLowerCase(s.charAt(0)) + s.substring(1);
  }
  return StringMemory.valueOf(s);
}

代码示例来源:origin: jphp-group/jphp

@Override
@Signature(@Arg("offset"))
synchronized public Memory offsetUnset(Environment env, Memory... args) {
  userEnv.remove(args[0].toString());
  return Memory.NULL;
}

代码示例来源:origin: jphp-group/jphp

@FastMethod
@Signature({@Arg("string")})
public static Memory lower(Environment env, Memory... args) {
  return StringMemory.valueOf(args[0].toString().toLowerCase());
}

代码示例来源:origin: jphp-group/jphp

@FastMethod
@Signature({
    @Arg("string"),
    @Arg("search"),
    @Arg(value = "fromIndex", optional = @Optional("NULL"))
})
public static Memory lastPosIgnoreCase(Environment env, Memory... args) {
  String string = args[0].toString();
  int from = args[2].isNull() ? string.length() : args[2].toInteger();
  return LongMemory.valueOf(StringUtils.lastIndexOfIgnoreCase(string, args[1].toString(), from));
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testScalar(){
  URL src = Thread.currentThread().getContextClassLoader().getResource(".");
  Memory memory = includeResource("cast/scalar.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg("functionName"))
public Memory importFunction(Environment env, Memory... args){
  FunctionEntity functionEntity = env.fetchFunction(args[0].toString());
  if (functionEntity == null) {
    env.exception(Messages.ERR_FUNCTION_NOT_FOUND.fetch(args[0]));
    return Memory.NULL;
  }
  environment.registerFunction(functionEntity);
  return Memory.NULL;
}

代码示例来源:origin: jphp-group/jphp

@Signature({
  @Arg("name"), @Arg(value = "package", nativeType = WrapPackage.class)
})
public Memory setPackage(Environment env, Memory... args) {
  PackageManager packageManager = this.environment.getPackageManager();
  packageManager.set(args[0].toString(), args[1].toObject(WrapPackage.class).getPackage());
  return Memory.NULL;
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testUses() {
  assertEquals("success", includeResource("lambdas/lambda_uses_001.php").toString());
  assertEquals("success", includeResource("lambdas/lambda_uses_002.php").toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testRequire(){
  Memory memory = includeResource("include/require.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testRequireOnce(){
  Memory memory = includeResource("include/require_once.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testToString(){
  Memory memory = includeResource("classes/__toString.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testComplex(){
  Memory memory = includeResource("expressions/complex.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testSwitchCase(){
  Memory memory = includeResource("conditions/switch_case.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testSimple(){
  Memory memory = includeResource("eval/simple.php");
  Assert.assertEquals("success", memory.toString());
}

代码示例来源:origin: jphp-group/jphp

@Signature({
    @Arg("name"), @Arg("value"),
    @Arg(value = "caseSensitive", optional = @Optional(value = "true", type = HintType.BOOLEAN))
})
public Memory defineConstant(Environment env, Memory... args){
  Memory val = args[1].toValue();
  if (val.isArray() || val.isObject())
    env.exception("Argument 2 must be a scalar value");
  if (!environment.defineConstant(args[0].toString(), val, args[2].toBoolean()))
    env.exception("Constant '%s' already registered", args[0]);
  return Memory.NULL;
}

代码示例来源:origin: jphp-group/jphp

@Test
public void testTypeHinting() {
  assertEquals("2", Invoker.create(environment, run("fn(): int => 2.0;")).callAny().toString());
  assertEquals("2", Invoker.create(environment, run("fn(int $x) => $x;")).callAny(DoubleMemory.valueOf(2.0)).toString());
}

相关文章