Beispiel #1
0
TypedValue* HHVM_FN(getdate)(ActRec* ar) {
  try {
    int64_t timestamp = getArgStrict<KindOfInt64>(ar, 0, TimeStamp::Current());
    return arReturn(ar, getdateImpl(timestamp));
  } catch (const IncoercibleArgumentException& e) {
    return arReturn(ar, false);
  }
}
Beispiel #2
0
TypedValue* HHVM_FN(localtime)(ActRec* ar) {
  try {
    int64_t timestamp = getArgStrict<KindOfInt64>(ar, 0, TimeStamp::Current());
    bool associative = getArgStrict<KindOfBoolean>(ar, 1, false);
    return arReturn(ar, localtimeImpl(timestamp, associative));
  } catch (const IncoercibleArgumentException& e) {
    return arReturn(ar, false);
  }
}
Beispiel #3
0
static TypedValue* serialize_vars_helper(ActRec* ar) {
  auto wddxPacket = req::make<WddxPacket>(empty_string_variant_ref,
                                             true, true);
  int start_index = 0;
  for (int i = start_index; i < ar->numArgs(); i++) {
    auto const tv = getArg(ar, i);
    find_var_recursive(tv, wddxPacket);
  }
  Variant packet = wddxPacket->packet_end();
  return arReturn(ar, std::move(packet));
}
Beispiel #4
0
static TypedValue* add_vars_helper(ActRec* ar) {
  int start_index = 1;
  Resource packet_id{getArg<KindOfResource>(ar, 0)};
  auto wddxPacket = cast<WddxPacket>(packet_id);

  for (int i = start_index; i < ar->numArgs(); i++) {
    auto const tv = getArg(ar, i);
    find_var_recursive(tv, wddxPacket);
  }
  return arReturn(ar, true);
}
Beispiel #5
0
static TypedValue* serialize_vars_helper(ActRec* ar) {
  WddxPacket* wddxPacket = NEWOBJ(WddxPacket)(empty_string_variant_ref,
                                              true, true);
  int start_index = 0;
  for (int i = start_index; i < ar->numArgs(); i++) {
    auto const tv = getArg(ar, i);
    find_var_recursive(tv, wddxPacket);
  }
  const std::string packet = wddxPacket->packet_end();
  Variant strHolder = makeStaticString(packet);
  return arReturn(ar, strHolder);
}
Beispiel #6
0
TypedValue* HHVM_FUNCTION(pack, ActRec* ar) {
  int num = ar->numArgs();
  String format(getArg<KindOfString>(ar,0));
  Array extra = Array::Create();
  for (int i = 1; i<num; i++) {
    extra.append(getArgVariant(ar,i));
  }
  Variant result = ZendPack().pack(format, extra);
  // pack() returns false if there was an error
  if (!result.isBoolean()) {
    tvCastToStringInPlace(result.asTypedValue());
  }
  return arReturn(ar, std::move(result));
}