Beispiel #1
0
CVarRef Globals::declareConstant(CStrRef name, Variant &constant,
                                 CVarRef value) {
  if (!value.isAllowedAsConstantValue()) {
    raise_warning("Constants may only evaluate to scalar values");
    // TODO don't actually define, and return false
  }
  if (!m_dynamicConstants.exists(name)) {
    m_dynamicConstants.set(name, value);
    constant = value;
  }
  return value;
}
Beispiel #2
0
bool Globals::declareConstant(CStrRef name, Variant &constant,
                              CVarRef value) {
  if (!value.isAllowedAsConstantValue()) {
    raise_warning("Constants may only evaluate to scalar values");
    return false;
  }
  if (!m_dynamicConstants.exists(name)) {
    m_dynamicConstants.set(name, value);
    constant = value;
    return true;
  }
  raise_warning("Constant %s already defined", name.data());
  return false;
}
Beispiel #3
0
bool f_define(CStrRef name, CVarRef value,
              bool case_insensitive /* = false */) {
  if (!has_eval_support) {
    ASSERT(false); // define() should be turned into constant definition by HPHP
    return false;
  }
  if (!value.isAllowedAsConstantValue()) {
    raise_warning("Constants may only evaluate to scalar values");
    return false;
  }
  if (!f_defined(name)) {
    return Eval::RequestEvalState::declareConstant(name, value);
  }
  raise_notice("Constant %s already defined", name.data());
  return false;
}