Delete Variant's implicit conversion operators

Esse commit está contido em:
Jordan DeLong
2013-06-23 13:26:02 -07:00
commit de Sara Golemon
commit f3d2185982
80 arquivos alterados com 522 adições e 496 exclusões
@@ -523,7 +523,7 @@ ExpressionPtr BinaryOpExpression::foldConst(AnalysisResultConstPtr ar) {
Variant result;
switch (m_op) {
case T_LOGICAL_XOR:
result = logical_xor(v1, v2); break;
result = static_cast<bool>(v1.toBoolean() ^ v2.toBoolean()); break;
case '|':
result = bitwise_or(v1, v2); break;
case '&':
@@ -531,7 +531,7 @@ ExpressionPtr BinaryOpExpression::foldConst(AnalysisResultConstPtr ar) {
case '^':
result = bitwise_xor(v1, v2); break;
case '.':
result = concat(v1, v2); break;
result = concat(v1.toString(), v2.toString()); break;
case T_IS_IDENTICAL:
result = same(v1, v2); break;
case T_IS_NOT_IDENTICAL:
@@ -563,19 +563,19 @@ ExpressionPtr BinaryOpExpression::foldConst(AnalysisResultConstPtr ar) {
if ((v2.isIntVal() && v2.toInt64() == 0) || v2.toDouble() == 0.0) {
return ExpressionPtr();
}
result = modulo(v1, v2); break;
result = modulo(v1.toInt64(), v2.toInt64()); break;
case T_SL:
result = shift_left(v1, v2); break;
result = shift_left(v1.toInt64(), v2.toInt64()); break;
case T_SR:
result = shift_right(v1, v2); break;
result = shift_right(v1.toInt64(), v2.toInt64()); break;
case T_BOOLEAN_OR:
result = v1 || v2; break;
result = v1.toBoolean() || v2.toBoolean(); break;
case T_BOOLEAN_AND:
result = v1 && v2; break;
result = v1.toBoolean() && v2.toBoolean(); break;
case T_LOGICAL_OR:
result = v1 || v2; break;
result = v1.toBoolean() || v2.toBoolean(); break;
case T_LOGICAL_AND:
result = v1 && v2; break;
result = v1.toBoolean() && v2.toBoolean(); break;
case T_INSTANCEOF: {
if (v1.isArray() && v2.isString() &&
interface_supports_array(v2.getStringData())) {
+2 -2
Ver Arquivo
@@ -687,7 +687,7 @@ ExpressionPtr Expression::MakeScalarExpression(AnalysisResultConstPtr ar,
ExpressionListPtr el(new ExpressionList(scope, loc,
ExpressionList::ListKindParam));
for (ArrayIter iter(value); iter; ++iter) {
for (ArrayIter iter(value.toArray()); iter; ++iter) {
ExpressionPtr k(MakeScalarExpression(ar, scope, loc, iter.first()));
ExpressionPtr v(MakeScalarExpression(ar, scope, loc, iter.second()));
if (!k || !v) return ExpressionPtr();
@@ -701,7 +701,7 @@ ExpressionPtr Expression::MakeScalarExpression(AnalysisResultConstPtr ar,
} else if (value.isNull()) {
return MakeConstant(ar, scope, loc, "null");
} else if (value.isBoolean()) {
return MakeConstant(ar, scope, loc, value ? "true" : "false");
return MakeConstant(ar, scope, loc, value.toBoolean() ? "true" : "false");
} else {
return ScalarExpressionPtr
(new ScalarExpression(scope, loc, value));
+1 -1
Ver Arquivo
@@ -171,7 +171,7 @@ bool ArrayIter::endHelper() {
}
default: {
ObjectData* obj = getIteratorObj();
return !obj->o_invoke_few_args(s_valid, 0);
return !obj->o_invoke_few_args(s_valid, 0).toBoolean();
}
}
}
+1 -1
Ver Arquivo
@@ -811,7 +811,7 @@ void ArrayUtil::InitScalarArrays(Array arrs[], int nArrs,
}
Variant v(unserialize_from_buffer(uncompressed, len));
assert(v.isArray());
Array scalarArrays = v;
Array scalarArrays = v.toArray();
assert(scalarArrays.size() == nArrs);
for (int i = 0; i < nArrs; i++) {
arrs[i] = scalarArrays[i];
+1 -1
Ver Arquivo
@@ -810,7 +810,7 @@ ArrayData* PolicyArray::pop(Variant &value) {
// Match PHP 5.3.1 semantics
if (!hasStrKey(pos)
&& Store::nextKey() == 1 + static_cast<int64_t>(key(pos))) {
&& Store::nextKey() == 1 + key(pos).toInt64()) {
nextKeyPop();
}
+4 -2
Ver Arquivo
@@ -37,10 +37,12 @@ inline Variant operator+(double n, CVarRef v) { return Variant(v) += n;}
// String + Variant means string concatenation
inline Variant operator+(String&& n, CVarRef v) {
return Variant(std::move(n += v));
return Variant(std::move(n += v.toString()));
}
inline Variant operator+(CStrRef n, CVarRef v) { return String(n) += v;}
inline Variant operator+(CStrRef n, CVarRef v) {
return String(n) += v.toString();
}
// Array + Variant is already defined in type_array.h
inline Variant operator+(CObjRef n, CVarRef v) { return Variant(v) += n;}
+2 -2
Ver Arquivo
@@ -929,7 +929,7 @@ String resolve_include(CStrRef file, const char* currentDir,
for (int i = 0; i < (int)path_count; i++) {
String path("");
String includePath = includePaths[i];
String includePath = includePaths[i].toString();
if (includePath[0] != '/') {
path += (g_context->getCwd() + "/");
@@ -1223,7 +1223,7 @@ String AutoloadHandler::getSignature(CVarRef handler) {
if (!f_is_callable(handler, false, ref(name))) {
return null_string;
}
String lName = StringUtil::ToLower(name);
String lName = StringUtil::ToLower(name.toString());
if (handler.isArray()) {
Variant first = handler.getArrayData()->get(int64_t(0));
if (first.isObject()) {
-12
Ver Arquivo
@@ -91,12 +91,6 @@ bool empty(CVarRef v, CStrRef, bool = false) = delete;
///////////////////////////////////////////////////////////////////////////////
// operators
/**
* These functions are rarely performance bottlenecks, so we are not fully
* type-specialized, although we could.
*/
inline bool logical_xor(bool v1, bool v2) { return (v1 ? 1:0) ^ (v2 ? 1:0);}
inline Variant bitwise_or (CVarRef v1, CVarRef v2) { return v1 | v2;}
inline Variant bitwise_and(CVarRef v1, CVarRef v2) { return v1 & v2;}
inline Variant bitwise_xor(CVarRef v1, CVarRef v2) { return v1 ^ v2;}
@@ -127,12 +121,6 @@ inline Variant negate(CVarRef v) { return -(Variant)v; }
inline String concat(CStrRef s1, CStrRef s2) {
return s1 + s2;
}
inline String &concat_assign(String &s1, litstr s2) {
return s1 += s2;
}
inline String &concat_assign(String &s1, CStrRef s2) {
return s1 += s2;
}
String concat3(CStrRef s1, CStrRef s2, CStrRef s3);
String concat4(CStrRef s1, CStrRef s2, CStrRef s3, CStrRef s4);
+9 -9
Ver Arquivo
@@ -506,14 +506,14 @@ void BaseExecutionContext::onRequestShutdown() {
void BaseExecutionContext::executeFunctions(CArrRef funcs) {
for (ArrayIter iter(funcs); iter; ++iter) {
Array callback = iter.second();
vm_call_user_func(callback[s_name], callback[s_args]);
Array callback = iter.second().toArray();
vm_call_user_func(callback[s_name], callback[s_args].toArray());
}
}
void BaseExecutionContext::onShutdownPreSend() {
if (!m_shutdowns.isNull() && m_shutdowns.exists(ShutDown)) {
executeFunctions(m_shutdowns[ShutDown]);
executeFunctions(m_shutdowns[ShutDown].toArray());
m_shutdowns.remove(ShutDown);
}
obFlushAll(); // in case obStart was called without obFlush
@@ -526,11 +526,11 @@ void BaseExecutionContext::onShutdownPostSend() {
ServerStatsHelper ssh("psp", ServerStatsHelper::TRACK_HWINST);
if (!m_shutdowns.isNull()) {
if (m_shutdowns.exists(PostSend)) {
executeFunctions(m_shutdowns[PostSend]);
executeFunctions(m_shutdowns[PostSend].toArray());
m_shutdowns.remove(PostSend);
}
if (m_shutdowns.exists(CleanUp)) {
executeFunctions(m_shutdowns[CleanUp]);
executeFunctions(m_shutdowns[CleanUp].toArray());
m_shutdowns.remove(CleanUp);
}
}
@@ -632,7 +632,7 @@ void BaseExecutionContext::handleError(const std::string &msg,
if (!bt.empty()) {
Array top = bt.rvalAt(0).toArray();
if (top.exists(s_file)) file = top.rvalAt(s_file).toString();
if (top.exists(s_line)) line = top.rvalAt(s_line);
if (top.exists(s_line)) line = top.rvalAt(s_line).toInt64();
}
}
@@ -659,7 +659,7 @@ bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
Array arr = ee->getBackTrace();
if (!arr.isNull()) {
backtrace = arr;
Array top = backtrace.rvalAt(0);
Array top = backtrace.rvalAt(0).toArray();
if (!top.isNull()) {
errfile = top.rvalAt(s_file);
errline = top.rvalAt(s_line).toInt64();
@@ -699,7 +699,7 @@ bool BaseExecutionContext::onFatalError(const Exception &e) {
if (!bt.empty()) {
Array top = bt.rvalAt(0).toArray();
if (top.exists(s_file)) file = top.rvalAt(s_file).toString();
if (top.exists(s_line)) line = top.rvalAt(s_line);
if (top.exists(s_line)) line = top.rvalAt(s_line).toInt32();
}
}
}
@@ -792,7 +792,7 @@ void BaseExecutionContext::setenv(CStrRef name, CStrRef value) {
String BaseExecutionContext::getenv(CStrRef name) const {
if (m_envs.exists(name)) {
return m_envs[name];
return m_envs[name].toString();
}
char *value = ::getenv(name.data());
if (value) {
+11 -5
Ver Arquivo
@@ -50,16 +50,18 @@ File* HttpStreamWrapper::open(CStrRef filename, CStrRef mode,
if (!ctx || ctx->m_options.isNull() || ctx->m_options[s_http].isNull()) {
file = std::unique_ptr<UrlFile>(NEWOBJ(UrlFile)());
} else {
Array opts = ctx->m_options[s_http];
Array opts = ctx->m_options[s_http].toArray();
String method = s_GET;
if (opts.exists(s_method)) {
method = opts[s_method].toString();
}
Array headers;
if (opts.exists(s_header)) {
Array lines = StringUtil::Explode(opts[s_header].toString(), "\r\n");
Array lines = StringUtil::Explode(
opts[s_header].toString(), "\r\n").toArray();
for (ArrayIter it(lines); it; ++it) {
Array parts = StringUtil::Explode(it.second().toString(), ": ");
Array parts = StringUtil::Explode(
it.second().toString(), ": ").toArray();
headers.set(parts.rvalAt(0), parts.rvalAt(1));
}
}
@@ -69,9 +71,13 @@ File* HttpStreamWrapper::open(CStrRef filename, CStrRef mode,
headers.set(s_User_Agent, opts[s_user_agent]);
}
int max_redirs = 20;
if (opts.exists(s_max_redirects)) max_redirs = opts[s_max_redirects];
if (opts.exists(s_max_redirects)) {
max_redirs = opts[s_max_redirects].toInt64();
}
int timeout = -1;
if (opts.exists(s_timeout)) timeout = opts[s_timeout];
if (opts.exists(s_timeout)) {
timeout = opts[s_timeout].toInt64();
}
file = std::unique_ptr<UrlFile>(NEWOBJ(UrlFile)(method.data(), headers,
opts[s_content].toString(),
max_redirs, timeout));
+3 -3
Ver Arquivo
@@ -81,7 +81,7 @@ const StaticString s_passphrase("passphrase");
static int passwd_callback(char *buf, int num, int verify, void *data) {
/* TODO: could expand this to make a callback into PHP user-space */
SSLSocket *stream = (SSLSocket *)data;
String passphrase = stream->getContext()[s_passphrase];
String passphrase = stream->getContext()[s_passphrase].toString();
if (!passphrase.empty() && passphrase.size() < num - 1) {
memcpy(buf, passphrase.data(), passphrase.size() + 1);
return passphrase.size();
@@ -105,8 +105,8 @@ SSL *SSLSocket::createSSL(SSL_CTX *ctx) {
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, verify_callback);
/* CA stuff */
String cafile = m_context[s_cafile];
String capath = m_context[s_capath];
String cafile = m_context[s_cafile].toString();
String capath = m_context[s_capath].toString();
if (!cafile.empty() || !capath.empty()) {
if (!SSL_CTX_load_verify_locations(ctx, cafile.data(), capath.data())) {
+2 -2
Ver Arquivo
@@ -204,7 +204,7 @@ int64_t UserFile::writeImpl(const char *buffer, int64_t length) {
bool success = false;
int64_t didWrite = invoke(m_StreamWrite, s_stream_write,
CREATE_VECTOR1(String(buffer, length, CopyString)),
success);
success).toInt64();
if (!success) {
raise_warning("%s::stream_write is not implemented",
m_cls->name()->data());
@@ -228,7 +228,7 @@ bool UserFile::seek(int64_t offset, int whence /* = SEEK_SET */) {
// bool stream_seek($offset, $whence)
bool success = false;
bool sought = invoke(m_StreamSeek, s_stream_seek,
CREATE_VECTOR2(offset, whence), success);
CREATE_VECTOR2(offset, whence), success).toBoolean();
return success ? sought : false;
}
+1 -1
Ver Arquivo
@@ -522,7 +522,7 @@ void execute_command_line_begin(int argc, char **argv, int xhprof) {
}
if (xhprof) {
f_xhprof_enable(xhprof, uninit_null());
f_xhprof_enable(xhprof, uninit_null().toArray());
}
}
+1 -1
Ver Arquivo
@@ -47,7 +47,7 @@ SourceRootInfo::SourceRootInfo(const char *host)
String sandboxName = matches.rvalAt(1).toString();
createFromCommonRoot(sandboxName);
} else {
Array pair = StringUtil::Explode(matches.rvalAt(1), "-", 2);
Array pair = StringUtil::Explode(matches.rvalAt(1), "-", 2).toArray();
m_user = pair.rvalAt(0).toString();
bool defaultSb = pair.size() == 1;
if (defaultSb) {
+2 -2
Ver Arquivo
@@ -662,7 +662,7 @@ void Transport::prepareHeaders(bool compressed, bool chunked,
String ip = RuntimeOption::ServerPrimaryIP;
String key = RuntimeOption::XFBDebugSSLKey;
String cipher("AES-256-CBC");
int iv_len = f_openssl_cipher_iv_length(cipher);
int iv_len = f_openssl_cipher_iv_length(cipher).toInt32();
String iv = f_openssl_random_pseudo_bytes(iv_len);
String encrypted =
f_openssl_encrypt(ip, cipher, key, k_OPENSSL_RAW_DATA, iv);
@@ -729,7 +729,7 @@ String Transport::prepareResponse(const void *data, int size, bool &compressed,
}
bool Transport::setHeaderCallback(CVarRef callback) {
if (m_headerCallback) {
if (m_headerCallback.toBoolean()) {
// return false if a callback has already been set.
return false;
}
+4 -2
Ver Arquivo
@@ -13,8 +13,8 @@
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/base/server/virtual_host.h"
#include "hphp/runtime/base/comparisons.h"
#include "hphp/runtime/base/preg.h"
#include "hphp/runtime/base/runtime_option.h"
@@ -312,7 +312,9 @@ bool VirtualHost::rewriteURL(CStrRef host, String &url, bool &qsa,
}
if (!passed) continue;
Variant matches;
int count = preg_match(rule.pattern.c_str(), normalized, matches);
int count = preg_match(rule.pattern.c_str(),
normalized,
matches).toInt64();
if (count > 0) {
const char *s = rule.to.c_str();
StringBuffer ret;
+4 -4
Ver Arquivo
@@ -301,7 +301,7 @@ Array &Array::mergeImpl(ArrayData *data) {
Array Array::slice(int offset, int length, bool preserve_keys) const {
if (m_px == nullptr) return Array();
return ArrayUtil::Slice(m_px, offset, length, preserve_keys);
return ArrayUtil::Slice(m_px, offset, length, preserve_keys).toArray();
}
///////////////////////////////////////////////////////////////////////////////
@@ -761,7 +761,7 @@ Variant Array::appendOpEqual(int op, CVarRef v) {
if (escalated != m_px) ArrayBase::operator=(escalated);
assert(cv);
switch (op) {
case T_CONCAT_EQUAL: return concat_assign((*cv), v);
case T_CONCAT_EQUAL: return concat_assign((*cv), v.toString());
case T_PLUS_EQUAL: return ((*cv) += v);
case T_MINUS_EQUAL: return ((*cv) -= v);
case T_MUL_EQUAL: return ((*cv) *= v);
@@ -770,8 +770,8 @@ Variant Array::appendOpEqual(int op, CVarRef v) {
case T_AND_EQUAL: return ((*cv) &= v);
case T_OR_EQUAL: return ((*cv) |= v);
case T_XOR_EQUAL: return ((*cv) ^= v);
case T_SL_EQUAL: return ((*cv) <<= v);
case T_SR_EQUAL: return ((*cv) >>= v);
case T_SL_EQUAL: return ((*cv) <<= v.toInt64());
case T_SR_EQUAL: return ((*cv) >>= v.toInt64());
default:
throw FatalErrorException(0, "invalid operator %d", op);
}
-12
Ver Arquivo
@@ -1513,18 +1513,6 @@ VarNR Variant::toKey() const {
return null_varNR;
}
Variant::operator String() const {
return toString();
}
Variant::operator Array() const {
return toArray();
}
Variant::operator Object() const {
return toObject();
}
///////////////////////////////////////////////////////////////////////////////
// offset functions
+18 -16
Ver Arquivo
@@ -614,23 +614,25 @@ class Variant : private TypedValue {
// Called before iteration to give array a chance to escalate.
void escalate();
/**
* Implicit type conversions. In general, we prefer explicit type conversion
* functions. These are needed simply because Variant is a coerced type from
* other types, and we need implicit type conversions to make our type
* inference coding simpler (Expression::m_expectedType handling).
/*
* Variant used to implicitly convert to all these types. (It still
* implicitly converts *from* most of them.)
*
* We're leaving these functions deleted for now because we fear the
* possibility of changes to overload resolution by not declaring
* them. Eventually when fewer of these types have implicit
* conversions we'll remove them.
*/
/* implicit */ operator bool () const { return toBoolean();}
operator char () const { return toByte();}
operator short () const { return toInt16();}
operator int () const { return toInt32();}
operator int64_t () const { return toInt64();}
operator double () const { return toDouble();}
operator String () const;
operator Array () const;
operator Object () const;
template<typename T> operator SmartObject<T>() const { return toObject();}
/* implicit */ operator bool () const = delete;
/* implicit */ operator char () const = delete;
/* implicit */ operator short () const = delete;
/* implicit */ operator int () const = delete;
/* implicit */ operator int64_t () const = delete;
/* implicit */ operator double () const = delete;
/* implicit */ operator String () const = delete;
/* implicit */ operator Array () const = delete;
/* implicit */ operator Object () const = delete;
template<typename T> /* implicit */ operator SmartObject<T>() const = delete;
/**
* Explicit type conversions
+2 -1
Ver Arquivo
@@ -76,7 +76,8 @@ bool VariableUnserializer::isWhitelistedClass(CStrRef cls_name) const {
if (!m_classWhiteList.isNull() && !m_classWhiteList.empty()) {
for (ArrayIter iter(m_classWhiteList); iter; ++iter) {
CVarRef value(iter.secondRef());
if (f_is_subclass_of(cls_name, value) || same(value, cls_name)) {
if (f_is_subclass_of(cls_name, value.toString()) ||
same(value, cls_name)) {
return true;
}
}
+4 -4
Ver Arquivo
@@ -362,7 +362,7 @@ static void collator_convert_array_from_utf16_to_utf8(Array &array,
CVarRef value = iter.secondRef();
/* Process string values only. */
if (!value.isString()) continue;
String str = intl_convert_str_utf16_to_utf8(value, status);
String str = intl_convert_str_utf16_to_utf8(value.toString(), status);
if (U_FAILURE(*status)) {
return;
}
@@ -377,7 +377,7 @@ static void collator_convert_array_from_utf8_to_utf16(Array &array,
CVarRef value = iter.secondRef();
/* Process string values only. */
if (!value.isString()) continue;
String str = intl_convert_str_utf8_to_utf16(value, status);
String str = intl_convert_str_utf8_to_utf16(value.toString(), status);
if (U_FAILURE(*status)) {
return;
}
@@ -394,7 +394,7 @@ static Variant collator_normalize_sort_argument(CVarRef arg) {
if (same(n_arg, false)) {
/* Conversion to number failed. */
UErrorCode status;
n_arg = intl_convert_str_utf16_to_utf8(arg, &status);
n_arg = intl_convert_str_utf16_to_utf8(arg.toString(), &status);
if (U_FAILURE(status)) {
raise_warning("Error converting utf16 to utf8 in "
"collator_normalize_sort_argument()");
@@ -436,7 +436,7 @@ static int collator_regular_compare_function(CVarRef v1, CVarRef v2,
if (same(num1, false)) {
/* str1 is string but not numeric string just convert it to utf8. */
UErrorCode status;
norm1 = intl_convert_str_utf16_to_utf8(str1, &status);
norm1 = intl_convert_str_utf16_to_utf8(str1.toString(), &status);
if (U_FAILURE(status)) {
raise_warning("Error converting utf16 to utf8 in "
"collator_regular_compare_function()");
+1 -1
Ver Arquivo
@@ -1633,7 +1633,7 @@ char *string_numeric_to_base(CVarRef value, int base) {
}
if (value.isDouble()) {
double fvalue = floor(value); /* floor it just in case */
double fvalue = floor(value.toDouble()); /* floor it just in case */
char *ptr, *end;
char buf[(sizeof(double) << 3) + 1];
+21 -17
Ver Arquivo
@@ -173,7 +173,7 @@ void CmdInfo::onClientImpl(DebuggerClient &client) {
} else {
for (ArrayIter iter(info); iter; ++iter) {
StringBuffer sb;
PrintInfo(client, sb, iter.second(), subsymbol);
PrintInfo(client, sb, iter.second().toArray(), subsymbol);
client.code(sb.detach());
}
}
@@ -204,7 +204,8 @@ String CmdInfo::GetProtoType(DebuggerClient &client, const std::string &cls,
sb.printf("function %s%s(%s);\n",
info[s_ref].toBoolean() ? "&" : "",
info[s_name].toString().data(),
GetParams(info[s_params], info[s_varg]).data());
GetParams(info[s_params].toArray(),
info[s_varg].toBoolean()).data());
return sb.detach();
}
}
@@ -340,7 +341,7 @@ String CmdInfo::GetParams(CArrRef params, bool varg,
if (arg.exists(s_default)) {
args.append(" = ");
Variant defValue = arg[s_default];
String defText = arg[s_defaultText];
String defText = arg[s_defaultText].toString();
if (!defText.empty()) {
args.append(defText);
} else if (defValue.isObject()) {
@@ -384,7 +385,7 @@ String CmdInfo::FindSubSymbol(CArrRef symbols, const std::string &symbol) {
bool CmdInfo::TryConstant(StringBuffer &sb, CArrRef info,
const std::string &subsymbol) {
String key = FindSubSymbol(info[s_constants], subsymbol);
String key = FindSubSymbol(info[s_constants].toArray(), subsymbol);
if (!key.isNull()) {
sb.printf(" const %s = %s;\n", key.data(),
DebuggerClient::FormatVariable
@@ -396,11 +397,11 @@ bool CmdInfo::TryConstant(StringBuffer &sb, CArrRef info,
bool CmdInfo::TryProperty(StringBuffer &sb, CArrRef info,
const std::string &subsymbol) {
String key = FindSubSymbol(info[s_properties],
String key = FindSubSymbol(info[s_properties].toArray(),
subsymbol[0] == '$' ?
subsymbol.substr(1) : subsymbol);
if (!key.isNull()) {
Array prop = info[s_properties][key];
Array prop = info[s_properties][key].toArray();
PrintDocComments(sb, prop);
sb.printf(" %s %s$%s;\n",
prop[s_access].toString().data(),
@@ -408,11 +409,11 @@ bool CmdInfo::TryProperty(StringBuffer &sb, CArrRef info,
prop[s_name].toString().data());
return true;
}
key = FindSubSymbol(info[s_private_properties],
key = FindSubSymbol(info[s_private_properties].toArray(),
subsymbol[0] == '$' ?
subsymbol.substr(1) : subsymbol);
if (!key.isNull()) {
Array prop = info[s_private_properties][key];
Array prop = info[s_private_properties][key].toArray();
PrintDocComments(sb, prop);
sb.printf(" private %s$%s;\n",
GetModifier(prop, s_static).data(),
@@ -428,7 +429,7 @@ bool CmdInfo::TryMethod(DebuggerClient &client, StringBuffer &sb, CArrRef info,
subsymbol = subsymbol.substr(0, subsymbol.size() - 2);
}
String key = FindSubSymbol(info[s_methods], subsymbol);
String key = FindSubSymbol(info[s_methods].toArray(), subsymbol);
if (!key.isNull()) {
Array func = info[s_methods][key].toArray();
PrintHeader(client, sb, func);
@@ -440,7 +441,8 @@ bool CmdInfo::TryMethod(DebuggerClient &client, StringBuffer &sb, CArrRef info,
info[s_name].toString().data(),
func[s_ref].toBoolean() ? "&" : "",
func[s_name].toString().data(),
GetParams(func[s_params], func[s_varg], true).data());
GetParams(func[s_params].toArray(),
func[s_varg].toBoolean(), true).data());
return true;
}
return false;
@@ -453,7 +455,8 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
sb.printf("function %s%s(%s);\n",
info[s_ref].toBoolean() ? "&" : "",
info[s_name].toString().data(),
GetParams(info[s_params], info[s_varg]).data());
GetParams(info[s_params].toArray(),
info[s_varg].toBoolean()).data());
return;
}
@@ -478,7 +481,7 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
if (!info[s_interfaces].toArray().empty()) {
parents.append("implements ");
bool first = true;
for (ArrayIter iter(info[s_interfaces]); iter; ++iter) {
for (ArrayIter iter(info[s_interfaces].toArray()); iter; ++iter) {
if (first) {
first = false;
} else {
@@ -499,7 +502,7 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
if (!info[s_constants].toArray().empty()) {
sb.printf(" // constants\n");
for (ArrayIter iter(info[s_constants]); iter; ++iter) {
for (ArrayIter iter(info[s_constants].toArray()); iter; ++iter) {
sb.printf(" const %s = %s;\n",
iter.first().toString().data(),
DebuggerClient::FormatVariable(iter.second()).data());
@@ -509,7 +512,7 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
if (!info[s_properties].toArray().empty() ||
!info[s_private_properties].toArray().empty()) {
sb.printf(" // properties\n");
for (ArrayIter iter(info[s_properties]); iter; ++iter) {
for (ArrayIter iter(info[s_properties].toArray()); iter; ++iter) {
Array prop = iter.second().toArray();
sb.printf(" %s%s %s$%s;\n",
prop[s_doc].toBoolean() ? "[doc] " : "",
@@ -517,7 +520,7 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
GetModifier(prop, s_static).data(),
prop[s_name].toString().data());
}
for (ArrayIter iter(info[s_private_properties]); iter; ++iter) {
for (ArrayIter iter(info[s_private_properties].toArray()); iter; ++iter) {
Array prop = iter.second().toArray();
sb.printf(" %sprivate %s$%s;\n",
prop[s_doc].toBoolean() ? "[doc] " : "",
@@ -528,7 +531,7 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
if (!info[s_methods].toArray().empty()) {
sb.printf(" // methods\n");
for (ArrayIter iter(info[s_methods]); iter; ++iter) {
for (ArrayIter iter(info[s_methods].toArray()); iter; ++iter) {
Array func = iter.second().toArray();
sb.printf(" %s%s %s%s%sfunction %s%s(%s);\n",
func[s_doc].toBoolean() ? "[doc] " : "",
@@ -538,7 +541,8 @@ void CmdInfo::PrintInfo(DebuggerClient &client, StringBuffer &sb, CArrRef info,
GetModifier(func, s_abstract).data(),
func[s_ref].toBoolean() ? "&" : "",
func[s_name].toString().data(),
GetParams(func[s_params], func[s_varg]).data());
GetParams(func[s_params].toArray(),
func[s_varg].toBoolean()).data());
}
}
+7 -6
Ver Arquivo
@@ -145,8 +145,8 @@ bool CmdList::listFileRange(DebuggerClient &client,
CmdListPtr res = client.xend<CmdList>(this);
if (res->m_code.isString()) {
if (!client.code(res->m_code, m_line1, m_line2, lineFocus0, charFocus0,
lineFocus1, charFocus1)) {
if (!client.code(res->m_code.toString(), m_line1, m_line2,
lineFocus0, charFocus0, lineFocus1, charFocus1)) {
client.info("No more lines in %s to display.", m_file.c_str());
}
client.setListLocation(m_file, m_line2, false);
@@ -179,9 +179,10 @@ bool CmdList::listFunctionOrClass(DebuggerClient &client) {
if (info.empty()) return false;
always_assert(info.size() == 1);
ArrayIter iter(info);
Array funcInfo = iter.second();
Array funcInfo = iter.second().toArray();
if (!subsymbol.empty()) {
String key = CmdInfo::FindSubSymbol(funcInfo[s_methods], subsymbol);
String key = CmdInfo::FindSubSymbol(funcInfo[s_methods].toArray(),
subsymbol);
if (key.isNull()) return false;
funcInfo = funcInfo[s_methods][key].toArray();
}
@@ -338,7 +339,7 @@ bool CmdList::onServer(DebuggerProxy &proxy) {
auto savedWarningFrequency = RuntimeOption::WarningFrequency;
RuntimeOption::WarningFrequency = 0;
m_code = f_file_get_contents(m_file.c_str());
if (!proxy.isLocal() && !m_code && m_file[0] != '/') {
if (!proxy.isLocal() && !m_code.toBoolean() && m_file[0] != '/') {
DSandboxInfo info = proxy.getSandbox();
if (info.m_path.empty()) {
raise_warning("path for sandbox %s is not setup, run a web request",
@@ -349,7 +350,7 @@ bool CmdList::onServer(DebuggerProxy &proxy) {
}
}
RuntimeOption::WarningFrequency = savedWarningFrequency;
if (!m_code && m_file == "systemlib.php") {
if (!m_code.toBoolean() && m_file == "systemlib.php") {
m_code = SystemLib::s_source;
}
return proxy.sendToClient((DebuggerCommand*)this);
+1 -1
Ver Arquivo
@@ -281,7 +281,7 @@ void CmdPrint::handleReply(DebuggerClient &client) {
if (!m_output.empty()) {
client.output(m_output);
}
client.output(m_ret);
client.output(m_ret.toString());
}
void CmdPrint::onClientImpl(DebuggerClient &client) {
+4 -4
Ver Arquivo
@@ -94,7 +94,7 @@ void CmdWhere::onClientImpl(DebuggerClient &client) {
if (client.argCount() == 0) {
int i = 0;
for (ArrayIter iter(st); iter; ++iter) {
client.printFrame(i, iter.second());
client.printFrame(i, iter.second().toArray());
++i;
if (!client.isApiMode() &&
i % DebuggerClient::ScrollBlockSize == 0 &&
@@ -115,11 +115,11 @@ void CmdWhere::onClientImpl(DebuggerClient &client) {
}
if (num > 0) {
for (int i = 0; i < num && i < st.size(); i++) {
client.printFrame(i, st[i]);
client.printFrame(i, st[i].toArray());
}
} else if (num < 0) {
for (int i = st.size() + num; i < st.size(); i++) {
client.printFrame(i, st[i]);
client.printFrame(i, st[i].toArray());
}
} else {
client.error("0 was specified for the number of frames");
@@ -141,7 +141,7 @@ void CmdWhere::processStackTrace() {
static StaticString s_args("args");
Array smallST;
for (ArrayIter iter(m_stacktrace); iter; ++iter) {
CArrRef frame(iter.secondRef());
CArrRef frame(iter.secondRef().toArray());
Array smallFrame;
for (ArrayIter iter2(frame); iter2; ++iter2) {
if (equal(iter2.first(), s_args)) {
+5 -5
Ver Arquivo
@@ -1298,7 +1298,7 @@ void DebuggerClient::shortCode(BreakPointInfoPtr bp) {
}
}
code(source, firstLine, lastLine,
code(source.toString(), firstLine, lastLine,
beginHighlightLine,
beginHighlightColumn,
endHighlightLine,
@@ -1507,7 +1507,7 @@ void DebuggerClient::helpCmds(const std::vector<const char *> &cmds) {
StringBuffer line;
line.append(" ");
if (n) line.append(" ");
line.append(StringUtil::Pad(lines1[n], leftMax));
line.append(StringUtil::Pad(lines1[n].toString(), leftMax));
if (n == 0) line.append(" ");
line.append(" ");
line.append(lines2[n].toString());
@@ -2103,9 +2103,9 @@ void DebuggerClient::moveToFrame(int index, bool display /* = true */) {
if (m_frame < 0) {
m_frame = 0;
}
CArrRef frame = m_stacktrace[m_frame];
CArrRef frame = m_stacktrace[m_frame].toArray();
if (!frame.isNull()) {
String file = frame[s_file];
String file = frame[s_file].toString();
int line = frame[s_line].toInt32();
if (!file.empty() && line) {
if (m_frame == 0) {
@@ -2131,7 +2131,7 @@ const StaticString
void DebuggerClient::printFrame(int index, CArrRef frame) {
TRACE(2, "DebuggerClient::printFrame\n");
StringBuffer args;
for (ArrayIter iter(frame[s_args]); iter; ++iter) {
for (ArrayIter iter(frame[s_args].toArray()); iter; ++iter) {
if (!args.empty()) args.append(", ");
String value = FormatVariable(iter.second());
args.append(value);
@@ -122,7 +122,7 @@ int DebuggerWireHelpers::WireUnserialize(String& sdata, Object& data) {
sdata = s_type_mismatch;
return TypeMismatch;
}
data = v;
data = v.toObject();
return NoError;
}
+4 -4
Ver Arquivo
@@ -596,7 +596,7 @@ bool f_array_walk_recursive(VRefParam input, CVarRef funcname,
CallerFrame cf;
vm_decode_function(funcname, cf(), false, ctx);
if (ctx.func == NULL) {
return uninit_null();
return false;
}
PointerSet seen;
ArrayUtil::Walk(input, walk_func, &ctx, true, &seen, userdata);
@@ -612,7 +612,7 @@ bool f_array_walk(VRefParam input, CVarRef funcname,
CallerFrame cf;
vm_decode_function(funcname, cf(), false, ctx);
if (ctx.func == NULL) {
return uninit_null();
return false;
}
ArrayUtil::Walk(input, walk_func, &ctx, false, NULL, userdata);
return true;
@@ -671,7 +671,7 @@ int64_t f_count(CVarRef var, bool recursive /* = false */) {
{
Object obj = var.toObject();
if (obj.instanceof(SystemLib::s_CountableClass)) {
return obj->o_invoke_few_args(s_count, 0);
return obj->o_invoke_few_args(s_count, 0).toInt64();
}
}
break;
@@ -781,7 +781,7 @@ Variant f_range(CVarRef low, CVarRef high, CVarRef step /* = 1 */) {
static int cmp_func(CVarRef v1, CVarRef v2, const void *data) {
Variant *callback = (Variant *)data;
return vm_call_user_func(*callback, CREATE_VECTOR2(v1, v2));
return vm_call_user_func(*callback, CREATE_VECTOR2(v1, v2)).toInt32();
}
#define COMMA ,
+1 -1
Ver Arquivo
@@ -51,7 +51,7 @@ Variant f_bzopen(CVarRef filename, CStrRef mode) {
return false;
}
bz = NEWOBJ(BZ2File)();
bool ret = bz->open(File::TranslatePath(filename), mode);
bool ret = bz->open(File::TranslatePath(filename.toString()), mode);
if (!ret) {
raise_warning("%s", Util::safe_strerror(errno).c_str());
return false;
+1 -1
Ver Arquivo
@@ -1057,7 +1057,7 @@ public:
Object find(CURL *cp) {
for (ArrayIter iter(m_easyh); iter; ++iter) {
if (iter.second().toObject().getTyped<CurlResource>()->get(true) == cp) {
return iter.second();
return iter.second().toObject();
}
}
return Object();
+2 -2
Ver Arquivo
@@ -207,7 +207,7 @@ static String format_string(DebuggerClient &client,
TRACE(5, "c_DebuggerClientCmdUser::format_string\n");
Variant ret = f_sprintf(_argc, format, _argv);
if (ret.isString()) {
return ret;
return ret.toString();
}
client.error("Debugger extension failed to format string: %s",
format.data());
@@ -391,7 +391,7 @@ int64_t c_DebuggerClientCmdUser::t_getframe() {
void c_DebuggerClientCmdUser::t_printframe(int index) {
TRACE(5, "c_DebuggerClientCmdUser::t_printframe\n");
m_client->printFrame(index, m_client->getStackTrace()[index]);
m_client->printFrame(index, m_client->getStackTrace()[index].toArray());
}
void c_DebuggerClientCmdUser::t_addcompletion(CVarRef list) {
+15 -15
Ver Arquivo
@@ -1925,7 +1925,7 @@ Variant c_DOMNode::t___set(Variant name, Variant value) {
}
bool c_DOMNode::t___isset(Variant name) {
return domnode_properties_map.isset(this, name);
return domnode_properties_map.isset(this, name.toString());
}
Variant c_DOMNode::t_appendchild(CObjRef newnode) {
@@ -2492,7 +2492,7 @@ Variant c_DOMAttr::t___set(Variant name, Variant value) {
}
bool c_DOMAttr::t___isset(Variant name) {
return domattr_properties_map.isset(this, name);
return domattr_properties_map.isset(this, name.toString());
}
bool c_DOMAttr::t_isid() {
@@ -2560,7 +2560,7 @@ Variant c_DOMCharacterData::t___set(Variant name, Variant value) {
}
bool c_DOMCharacterData::t___isset(Variant name) {
return domcharacterdata_properties_map.isset(this, name);
return domcharacterdata_properties_map.isset(this, name.toString());
}
bool c_DOMCharacterData::t_appenddata(CStrRef arg) {
@@ -2771,7 +2771,7 @@ Variant c_DOMText::t___set(Variant name, Variant value) {
}
bool c_DOMText::t___isset(Variant name) {
return domtext_properties_map.isset(this, name);
return domtext_properties_map.isset(this, name.toString());
}
bool c_DOMText::t_iswhitespaceinelementcontent() {
@@ -3069,7 +3069,7 @@ Variant c_DOMDocument::t___set(Variant name, Variant value) {
}
bool c_DOMDocument::t___isset(Variant name) {
return domdocument_properties_map.isset(this, name);
return domdocument_properties_map.isset(this, name.toString());
}
Variant c_DOMDocument::t_createattribute(CStrRef name) {
@@ -3732,7 +3732,7 @@ Variant c_DOMDocumentType::t___set(Variant name, Variant value) {
}
bool c_DOMDocumentType::t___isset(Variant name) {
return domdocumenttype_properties_map.isset(this, name);
return domdocumenttype_properties_map.isset(this, name.toString());
}
///////////////////////////////////////////////////////////////////////////////
@@ -3843,7 +3843,7 @@ Variant c_DOMElement::t___set(Variant name, Variant value) {
}
bool c_DOMElement::t___isset(Variant name) {
return domelement_properties_map.isset(this, name);
return domelement_properties_map.isset(this, name.toString());
}
String c_DOMElement::t_getattribute(CStrRef name) {
@@ -4438,7 +4438,7 @@ Variant c_DOMEntity::t___set(Variant name, Variant value) {
}
bool c_DOMEntity::t___isset(Variant name) {
return domentity_properties_map.isset(this, name);
return domentity_properties_map.isset(this, name.toString());
}
///////////////////////////////////////////////////////////////////////////////
@@ -4522,7 +4522,7 @@ Variant c_DOMNotation::t___set(Variant name, Variant value) {
}
bool c_DOMNotation::t___isset(Variant name) {
return domnotation_properties_map.isset(this, name);
return domnotation_properties_map.isset(this, name.toString());
}
///////////////////////////////////////////////////////////////////////////////
@@ -4593,7 +4593,7 @@ Variant c_DOMProcessingInstruction::t___set(Variant name, Variant value) {
}
bool c_DOMProcessingInstruction::t___isset(Variant name) {
return domprocessinginstruction_properties_map.isset(this, name);
return domprocessinginstruction_properties_map.isset(this, name.toString());
}
///////////////////////////////////////////////////////////////////////////////
@@ -4766,7 +4766,7 @@ Variant c_DOMNamedNodeMap::t___set(Variant name, Variant value) {
}
bool c_DOMNamedNodeMap::t___isset(Variant name) {
return domnamednodemap_properties_map.isset(this, name);
return domnamednodemap_properties_map.isset(this, name.toString());
}
Variant c_DOMNamedNodeMap::t_getiterator() {
@@ -4846,7 +4846,7 @@ Variant c_DOMNodeList::t___set(Variant name, Variant value) {
}
bool c_DOMNodeList::t___isset(Variant name) {
return domnodelist_properties_map.isset(this, name);
return domnodelist_properties_map.isset(this, name.toString());
}
Variant c_DOMNodeList::t_item(int64_t index) {
@@ -5233,7 +5233,7 @@ Variant c_DOMXPath::t___set(Variant name, Variant value) {
}
bool c_DOMXPath::t___isset(Variant name) {
return domxpath_properties_map.isset(this, name);
return domxpath_properties_map.isset(this, name.toString());
}
Variant c_DOMXPath::t_evaluate(CStrRef expr,
@@ -5335,7 +5335,7 @@ void c_DOMNodeIterator::reset_iterator() {
err:
if (curnode) {
p_DOMDocument doc = m_objmap->m_baseobj.getTyped<c_DOMNode>()->doc();
m_curobj = create_node_object(curnode, doc, owner);
m_curobj = create_node_object(curnode, doc, owner).toObject();
} else {
m_curobj.reset();
}
@@ -5409,7 +5409,7 @@ Variant c_DOMNodeIterator::t_next() {
err:
if (curnode) {
p_DOMDocument doc = m_objmap->m_baseobj.getTyped<c_DOMNode>()->doc();
m_curobj = create_node_object(curnode, doc, owner);
m_curobj = create_node_object(curnode, doc, owner).toObject();
} else {
m_curobj.reset();
}
+7 -6
Ver Arquivo
@@ -245,7 +245,7 @@ Variant f_fgetss(CObjRef handle, int64_t length /* = 0 */,
CStrRef allowable_tags /* = null_string */) {
Variant ret = f_fgets(handle, length);
if (!same(ret, false)) {
return StringUtil::StripHTMLTags(ret, allowable_tags);
return StringUtil::StripHTMLTags(ret.toString(), allowable_tags);
}
return ret;
}
@@ -360,14 +360,14 @@ Variant f_file_get_contents(CStrRef filename,
int64_t maxlen /* = 0 */) {
Variant stream = f_fopen(filename, "rb", use_include_path, context);
if (same(stream, false)) return false;
return f_stream_get_contents(stream, maxlen, offset);
return f_stream_get_contents(stream.toObject(), maxlen, offset);
}
Variant f_file_put_contents(CStrRef filename, CVarRef data,
int flags /* = 0 */,
CVarRef context /* = null */) {
Variant fvar = File::Open(filename, (flags & PHP_FILE_APPEND) ? "ab" : "wb");
if (!fvar) {
if (!fvar.toBoolean()) {
return false;
}
File *f = fvar.asObjRef().getTyped<File>();
@@ -528,7 +528,7 @@ Variant f_parse_ini_file(CStrRef filename, bool process_sections /* = false */,
}
Variant content = f_file_get_contents(translated);
if (same(content, false)) return false;
return IniSetting::FromString(content, filename, process_sections,
return IniSetting::FromString(content.toString(), filename, process_sections,
scanner_mode);
}
@@ -540,7 +540,7 @@ Variant f_parse_ini_string(CStrRef ini, bool process_sections /* = false */,
Variant f_parse_hdf_file(CStrRef filename) {
Variant content = f_file_get_contents(filename);
if (same(content, false)) return false;
return f_parse_hdf_string(content);
return f_parse_hdf_string(content.toString());
}
Variant f_parse_hdf_string(CStrRef input) {
@@ -1038,7 +1038,8 @@ bool f_copy(CStrRef source, CStrRef dest,
return false;
}
return f_stream_copy_to_stream(sfile, dfile).toBoolean();
return f_stream_copy_to_stream(sfile.toObject(),
dfile.toObject()).toBoolean();
} else {
int ret =
RuntimeOption::UseDirectCopy ?
+1 -1
Ver Arquivo
@@ -171,7 +171,7 @@ String f_call_user_func_serialized(CStrRef input) {
Variant out;
try {
Variant in = unserialize_from_string(input);
out.set(s_ret, vm_call_user_func(in[s_func], in[s_args]));
out.set(s_ret, vm_call_user_func(in[s_func], in[s_args].toArray()));
} catch (Object &e) {
out.set(s_exception, e);
}
+6 -6
Ver Arquivo
@@ -181,8 +181,8 @@ static Variant php_hash_do_hash(CStrRef algo, CStrRef data, bool isfilename,
ops->hash_init(context);
if (isfilename) {
for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk);
chunk = f_fread(f, 1024)) {
for (Variant chunk = f_fread(f.toObject(), 1024); !is_empty_string(chunk);
chunk = f_fread(f.toObject(), 1024)) {
String schunk = chunk.toString();
ops->hash_update(context, (unsigned char *)schunk.data(), schunk.size());
}
@@ -272,8 +272,8 @@ static Variant php_hash_do_hash_hmac(CStrRef algo, CStrRef data,
char *K = prepare_hmac_key(ops, context, key);
if (isfilename) {
for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk);
chunk = f_fread(f, 1024)) {
for (Variant chunk = f_fread(f.toObject(), 1024); !is_empty_string(chunk);
chunk = f_fread(f.toObject(), 1024)) {
String schunk = chunk.toString();
ops->hash_update(context, (unsigned char *)schunk.data(), schunk.size());
}
@@ -342,8 +342,8 @@ bool f_hash_update_file(CObjRef init_context, CStrRef filename,
}
HashContext *hash = init_context.getTyped<HashContext>();
for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk);
chunk = f_fread(f, 1024)) {
for (Variant chunk = f_fread(f.toObject(), 1024); !is_empty_string(chunk);
chunk = f_fread(f.toObject(), 1024)) {
String schunk = chunk.toString();
hash->ops->hash_update(hash->context, (unsigned char *)schunk.data(),
schunk.size());
+3 -3
Ver Arquivo
@@ -541,7 +541,7 @@ Array c_UConverter::ti_getaliases(CStrRef encoding) {
if (U_FAILURE(error)) {
THROW_UFAILURE(ucnv_getAliases, error, s_intl_error->m_error);
return uninit_null();
return uninit_null().toArray();
}
Array ret = Array::Create();
@@ -550,7 +550,7 @@ Array c_UConverter::ti_getaliases(CStrRef encoding) {
const char *alias = ucnv_getAlias(encoding.c_str(), i, &error);
if (U_FAILURE(error)) {
THROW_UFAILURE(ucnv_getAlias, error, s_intl_error->m_error);
return uninit_null();
return uninit_null().toArray();
}
ret.append(alias);
}
@@ -566,7 +566,7 @@ Array c_UConverter::ti_getstandards() {
const char *name = ucnv_getStandard(i, &error);
if (U_FAILURE(error)) {
THROW_UFAILURE(ucnv_getStandard, error, s_intl_error->m_error);
return uninit_null();
return uninit_null().toArray();
}
ret.append(name);
}
+58 -58
Ver Arquivo
@@ -402,7 +402,7 @@ static struct gfxinfo *php_handle_gif(CObjRef stream) {
String dim;
const unsigned char *s;
if (f_fseek(stream, 3, SEEK_CUR)) return NULL;
if (f_fseek(stream, 3, SEEK_CUR).toBoolean()) return NULL;
dim = f_fread(stream, 5);
if (dim.length() != 5) return NULL;
s = (unsigned char *)dim.c_str();
@@ -420,7 +420,7 @@ static struct gfxinfo *php_handle_psd (CObjRef stream) {
String dim;
const unsigned char *s;
if (f_fseek(stream, 11, SEEK_CUR)) return NULL;
if (f_fseek(stream, 11, SEEK_CUR).toBoolean()) return NULL;
dim = f_fread(stream, 8);
if (dim.length() != 8) return NULL;
@@ -444,7 +444,7 @@ static struct gfxinfo *php_handle_bmp (CObjRef stream) {
const unsigned char *s;
int size;
if (f_fseek(stream, 11, SEEK_CUR)) return NULL;
if (f_fseek(stream, 11, SEEK_CUR).toBoolean()) return NULL;
dim = f_fread(stream, 16);
if (dim.length() != 16) return NULL;
@@ -511,7 +511,7 @@ static struct gfxinfo *php_handle_swc(CObjRef stream) {
b = (unsigned char *)IM_CALLOC(1, len + 1);
CHECK_ALLOC_R(b, (len + 1), NULL);
if (f_fseek(stream, 5, SEEK_CUR)) {
if (f_fseek(stream, 5, SEEK_CUR).toBoolean()) {
IM_FREE(b);
return NULL;
}
@@ -524,7 +524,7 @@ static struct gfxinfo *php_handle_swc(CObjRef stream) {
if (uncompress((Bytef*)b, &len, (const Bytef*)a.c_str(), 64) != Z_OK) {
/* failed to decompress the file, will try reading the rest of the file */
if (f_fseek(stream, 8, SEEK_SET)) {
if (f_fseek(stream, 8, SEEK_SET).toBoolean()) {
IM_FREE(b);
return NULL;
}
@@ -582,7 +582,7 @@ static struct gfxinfo *php_handle_swf(CObjRef stream) {
long bits;
unsigned char *a;
if (f_fseek(stream, 5, SEEK_CUR)) return NULL;
if (f_fseek(stream, 5, SEEK_CUR).toBoolean()) return NULL;
String str = toString(f_fread(stream, 32));
if (str.length() != 32) return NULL;
@@ -612,7 +612,7 @@ static struct gfxinfo *php_handle_png(CObjRef stream) {
* Interlace method: 1 byte
*/
if (f_fseek(stream, 8, SEEK_CUR)) return NULL;
if (f_fseek(stream, 8, SEEK_CUR).toBoolean()) return NULL;
dim = f_fread(stream, 9);
if (dim.length() < 9) return NULL;
@@ -807,7 +807,7 @@ static struct gfxinfo *php_handle_jpeg(CObjRef stream, Variant &info) {
/* if we don't want an extanded info -> return */
return result;
}
if (f_fseek(stream, length - 8, SEEK_CUR)) {
if (f_fseek(stream, length - 8, SEEK_CUR).toBoolean()) {
/* file error after info */
return result;
}
@@ -939,7 +939,7 @@ static struct gfxinfo *php_handle_jpc(CObjRef stream) {
php_read4(stream); /* XTOsiz */
php_read4(stream); /* YTOsiz */
#else
if (f_fseek(stream, 24, SEEK_CUR)) {
if (f_fseek(stream, 24, SEEK_CUR).toBoolean()) {
IM_FREE(result);
return NULL;
}
@@ -1016,7 +1016,7 @@ static struct gfxinfo *php_handle_jp2(CObjRef stream) {
}
/* Skip over LBox (Which includes both TBox and LBox itself */
if (f_fseek(stream, box_length - 8, SEEK_CUR)) {
if (f_fseek(stream, box_length - 8, SEEK_CUR).toBoolean()) {
break;
}
}
@@ -1142,7 +1142,7 @@ static struct gfxinfo *php_handle_tiff(CObjRef stream, int motorola_intel) {
ifd_ptr = stream.getTyped<File>()->read(4);
if (ifd_ptr.length() != 4) return NULL;
ifd_addr = php_ifd_get32u((void*)ifd_ptr.c_str(), motorola_intel);
if (f_fseek(stream, ifd_addr-8, SEEK_CUR)) return NULL;
if (f_fseek(stream, ifd_addr-8, SEEK_CUR).toBoolean()) return NULL;
ifd_data = f_fread(stream, 2);
if (ifd_data.length() != 2) return NULL;
num_entries = php_ifd_get16u((void*)ifd_data.c_str(), motorola_intel);
@@ -1245,7 +1245,7 @@ static struct gfxinfo *php_handle_iff(CObjRef stream) {
return result;
}
} else {
if (f_fseek(stream, size, SEEK_CUR)) return NULL;
if (f_fseek(stream, size, SEEK_CUR).toBoolean()) return NULL;
}
} while (1);
}
@@ -1592,61 +1592,61 @@ Variant f_getimagesize(CStrRef filename, VRefParam imageinfo /* = null */) {
raise_warning("failed to open stream: %s", filename.c_str());
return false;
}
itype = php_getimagetype(stream);
itype = php_getimagetype(stream.toObject());
switch( itype) {
case IMAGE_FILETYPE_GIF:
result = php_handle_gif(stream);
result = php_handle_gif(stream.toObject());
break;
case IMAGE_FILETYPE_JPEG:
result = php_handle_jpeg(stream, imageinfo);
result = php_handle_jpeg(stream.toObject(), imageinfo);
break;
case IMAGE_FILETYPE_PNG:
result = php_handle_png(stream);
result = php_handle_png(stream.toObject());
break;
case IMAGE_FILETYPE_SWF:
result = php_handle_swf(stream);
result = php_handle_swf(stream.toObject());
break;
case IMAGE_FILETYPE_SWC:
#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
result = php_handle_swc(stream);
result = php_handle_swc(stream.toObject());
#else
raise_notice("The image is a compressed SWF file, but you do not "
"have a static version of the zlib extension enabled");
#endif
break;
case IMAGE_FILETYPE_PSD:
result = php_handle_psd(stream);
result = php_handle_psd(stream.toObject());
break;
case IMAGE_FILETYPE_BMP:
result = php_handle_bmp(stream);
result = php_handle_bmp(stream.toObject());
break;
case IMAGE_FILETYPE_TIFF_II:
result = php_handle_tiff(stream, 0);
result = php_handle_tiff(stream.toObject(), 0);
break;
case IMAGE_FILETYPE_TIFF_MM:
result = php_handle_tiff(stream, 1);
result = php_handle_tiff(stream.toObject(), 1);
break;
case IMAGE_FILETYPE_JPC:
result = php_handle_jpc(stream);
result = php_handle_jpc(stream.toObject());
break;
case IMAGE_FILETYPE_JP2:
result = php_handle_jp2(stream);
result = php_handle_jp2(stream.toObject());
break;
case IMAGE_FILETYPE_IFF:
result = php_handle_iff(stream);
result = php_handle_iff(stream.toObject());
break;
case IMAGE_FILETYPE_WBMP:
result = php_handle_wbmp(stream);
result = php_handle_wbmp(stream.toObject());
break;
case IMAGE_FILETYPE_XBM:
result = php_handle_xbm(stream);
result = php_handle_xbm(stream.toObject());
break;
default:
case IMAGE_FILETYPE_UNKNOWN:
break;
}
f_fclose(stream);
f_fclose(stream.toObject());
if (result) {
ArrayInit ret(7);
@@ -1722,10 +1722,10 @@ static Variant php_open_plain_file(CStrRef filename, const char *mode,
if (same(stream, false)) {
return false;
}
PlainFile *plain_file = Object(stream).getTyped<PlainFile>(false, true);
PlainFile *plain_file = stream.toObject().getTyped<PlainFile>(false, true);
FILE *fp = NULL;
if (!plain_file || !(fp = plain_file->getStream())) {
f_fclose(stream);
f_fclose(stream.toObject());
return false;
}
if (fpp) *fpp = fp;
@@ -1833,7 +1833,7 @@ static bool _php_image_output_ctx(CObjRef image, CStrRef filename,
if(fp) {
fflush(fp);
f_fclose(stream);
f_fclose(stream.toObject());
}
return true;
@@ -2024,7 +2024,7 @@ static bool _php_image_convert(CStrRef f_org, CStrRef f_dest,
gdImageDestroy(im_org);
f_fclose(org_stream);
f_fclose(org_stream.toObject());
im_dest = gdImageCreate(dest_width, dest_height);
if (im_dest == NULL) {
@@ -2068,7 +2068,7 @@ static bool _php_image_convert(CStrRef f_org, CStrRef f_dest,
gdImageWBMP(im_dest, black , dest);
fflush(dest);
f_fclose(dest_stream);
f_fclose(dest_stream.toObject());
gdImageDestroy(im_dest);
@@ -2150,7 +2150,7 @@ static bool _php_image_output(CObjRef image, CStrRef filename, int quality,
break;
}
fflush(fp);
f_fclose(stream);
f_fclose(stream.toObject());
} else {
int b;
FILE *tmp;
@@ -2253,7 +2253,7 @@ static gdImagePtr _php_image_create_from(CStrRef filename,
#endif
FILE *fp = NULL;
File *file = Object(stream).getTyped<File>();
File *file = stream.toObject().getTyped<File>();
PlainFile *plain_file = dynamic_cast<PlainFile*>(file);
if (plain_file) {
fp = plain_file->getStream();
@@ -2327,13 +2327,13 @@ static gdImagePtr _php_image_create_from(CStrRef filename,
}
if (im) {
f_fclose(stream);
f_fclose(stream.toObject());
return im;
}
raise_warning("'%s' is not a valid %s file", filename.c_str(), tn);
out_err:
f_fclose(stream);
f_fclose(stream.toObject());
return NULL;
}
@@ -2580,10 +2580,10 @@ static bool php_imagepolygon(CObjRef image, CArrRef points, int num_points,
for (i = 0; i < num_points; i++) {
if (points.exists(i * 2)) {
pts[i].x = points[i * 2];
pts[i].x = points[i * 2].toInt32();
}
if (points.exists(i * 2 + 1)) {
pts[i].y = points[i * 2 + 1];
pts[i].y = points[i * 2 + 1].toInt32();
}
}
@@ -2844,15 +2844,15 @@ static Variant php_imagettftext_common(int mode, int extended,
#endif
if (mode == TTFTEXT_BBOX) {
ptsize = arg1;
angle = arg2;
ptsize = arg1.toDouble();
angle = arg2.toDouble();
fontname = arg3;
str = arg4;
extrainfo = arg5;
} else {
Object image = arg1;
ptsize = arg2;
angle = arg3;
Object image = arg1.toObject();
ptsize = arg2.toDouble();
angle = arg3.toDouble();
x = toInt64(arg4);
y = toInt64(arg5);
col = toInt64(arg6);
@@ -2891,7 +2891,7 @@ static Variant php_imagettftext_common(int mode, int extended,
raise_warning("Invalid font filename %s", fontname.c_str());
return false;
}
f_fclose(stream);
f_fclose(stream.toObject());
#ifdef USE_GD_IMGSTRTTF
# if HAVE_GD_STRINGFTEX
@@ -3133,7 +3133,7 @@ bool f_imagesetstyle(CObjRef image, CArrRef style) {
CHECK_ALLOC_R(stylearr, malloc_size, false);
index = 0;
for (ArrayIter iter(style); iter; ++iter) {
stylearr[index++] = iter.secondRef();
stylearr[index++] = iter.secondRef().toInt32();
}
gdImageSetStyle(im, stylearr, index);
IM_FREE(stylearr);
@@ -4401,16 +4401,16 @@ Variant f_iptcembed(CStrRef iptcdata, CStrRef jpeg_file_name,
return false;
}
if (spool < 2) {
Array stat = f_fstat(stream);
int st_size = stat[s_size];
Array stat = f_fstat(stream.toObject()).toArray();
int st_size = stat[s_size].toInt32();
size_t malloc_size = iptcdata_len + sizeof(psheader) + st_size + 1024 + 1;
poi = spoolbuf = (unsigned char *)IM_MALLOC(malloc_size);
CHECK_ALLOC_R(poi, malloc_size, false);
memset(poi, 0, malloc_size);
}
File *file = Object(stream).getTyped<File>();
File *file = stream.toObject().getTyped<File>();
if (php_iptc_get1(file, spool, poi?&poi:0) != 0xFF) {
f_fclose(stream);
f_fclose(stream.toObject());
if (spoolbuf) {
IM_FREE(spoolbuf);
}
@@ -4418,7 +4418,7 @@ Variant f_iptcembed(CStrRef iptcdata, CStrRef jpeg_file_name,
}
if (php_iptc_get1(file, spool, poi?&poi:0) != 0xD8) {
f_fclose(stream);
f_fclose(stream.toObject());
if (spoolbuf) {
IM_FREE(spoolbuf);
}
@@ -4486,7 +4486,7 @@ Variant f_iptcembed(CStrRef iptcdata, CStrRef jpeg_file_name,
}
}
f_fclose(stream);
f_fclose(stream.toObject());
if (spool < 2) {
return String((char *)spoolbuf, poi - spoolbuf, AttachString);
@@ -7298,7 +7298,7 @@ static int exif_read_file(image_info_type *ImageInfo, String FileName,
raise_warning("Unable to open file %s", FileName.c_str());
return 0;
}
ImageInfo->infile = Object(stream).getTyped<File>();
ImageInfo->infile = stream.toObject().getTyped<File>();
PlainFile *plain_file = dynamic_cast<PlainFile*>(ImageInfo->infile);
if (plain_file) {
if (stat(FileName.c_str(), &st) >= 0) {
@@ -7313,9 +7313,9 @@ static int exif_read_file(image_info_type *ImageInfo, String FileName,
ImageInfo->FileSize = st.st_size;
} else {
if (!ImageInfo->FileSize) {
f_fseek(stream, 0, SEEK_END);
f_fseek(stream.toObject(), 0, SEEK_END);
ImageInfo->FileSize = ImageInfo->infile->tell();
f_fseek(stream, 0, SEEK_SET);
f_fseek(stream.toObject(), 0, SEEK_SET);
}
}
@@ -7336,7 +7336,7 @@ static int exif_read_file(image_info_type *ImageInfo, String FileName,
/* Scan the JPEG headers. */
ret = exif_scan_FILE_header(ImageInfo);
f_fclose(stream);
f_fclose(stream.toObject());
return ret;
}
@@ -8021,8 +8021,8 @@ Variant f_exif_imagetype(CStrRef filename) {
raise_warning("failed to open file: %s", filename.c_str());
return false;
}
int itype = php_getimagetype(stream);
f_fclose(stream);
int itype = php_getimagetype(stream.toObject());
f_fclose(stream.toObject());
if (itype == IMAGE_FILETYPE_UNKNOWN) return false;
return itype;
}
+4 -4
Ver Arquivo
@@ -134,13 +134,13 @@ bool f_msg_set_queue(CObjRef queue, CArrRef data) {
if (msgctl(q->id, IPC_STAT, &stat) == 0) {
Variant value;
value = data[s_msg_perm_uid];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
if (!value.isNull()) stat.msg_perm.uid = value.toInt64();
value = data[s_msg_perm_gid];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
if (!value.isNull()) stat.msg_perm.uid = value.toInt64();
value = data[s_msg_perm_mode];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
if (!value.isNull()) stat.msg_perm.uid = value.toInt64();
value = data[s_msg_qbytes];
if (!value.isNull()) stat.msg_perm.uid = (int64_t)value;
if (!value.isNull()) stat.msg_perm.uid = value.toInt64();
return msgctl(q->id, IPC_SET, &stat) == 0;
}
+2 -2
Ver Arquivo
@@ -348,7 +348,7 @@ static Variant php_ldap_do_search(CVarRef link, CVarRef base_dn,
LdapLink **lds = (LdapLink**)malloc(nlinks * sizeof(LdapLink*));
int *rcs = (int*)malloc(nlinks * sizeof(int));
ArrayIter iter(link);
ArrayIter iter(link.toArray());
ArrayIter iterdn(base_dn.toArray());
ArrayIter iterfilter(filter.toArray());
for (int i = 0; i < nlinks; i++) {
@@ -866,7 +866,7 @@ bool f_ldap_set_option(CVarRef link, int option, CVarRef newval) {
*ctrls = NULL;
ctrlp = ctrls;
Array stringHolder;
for (ArrayIter iter(newval); iter; ++iter) {
for (ArrayIter iter(newval.toArray()); iter; ++iter) {
Variant vctrlval = iter.second();
if (!vctrlval.isArray()) {
raise_warning("The array value must contain only arrays, "
+1 -1
Ver Arquivo
@@ -179,7 +179,7 @@ Variant f_mailparse_msg_extract_part(CObjRef mimemail, CVarRef msgbody,
}
Array f_mailparse_msg_get_part_data(CObjRef mimemail) {
return mimemail.getTyped<MimePart>()->getPartData();
return mimemail.getTyped<MimePart>()->getPartData().toArray();
}
Variant f_mailparse_msg_get_part(CObjRef mimemail, CStrRef mimesection) {
+1 -1
Ver Arquivo
@@ -3959,7 +3959,7 @@ bool f_mb_send_mail(CStrRef to, CStrRef subject, CStrRef message,
} suppressed_hdrs = { 0, 0 };
static const StaticString s_CONTENT_TYPE("CONTENT-TYPE");
String s = ht_headers[s_CONTENT_TYPE];
String s = ht_headers[s_CONTENT_TYPE].toString();
if (!s.isNull()) {
char *tmp;
char *param_name;
+2 -2
Ver Arquivo
@@ -416,7 +416,7 @@ bool c_Memcached::t_setmultibykey(CStrRef server_key, CArrRef items,
for (ArrayIter iter(items); iter; ++iter) {
Variant key = iter.first();
if (!key.isString()) continue;
if (!t_setbykey(server_key, key, iter.second(), expiration)) {
if (!t_setbykey(server_key, key.toString(), iter.second(), expiration)) {
return false;
}
}
@@ -994,7 +994,7 @@ memcached_return c_Memcached::doCacheCallback(CVarRef callback, CStrRef key,
Array params(ArrayInit(3).set(Variant(this))
.set(key)
.setRef(value).create());
if (!vm_call_user_func(callback, params)) {
if (!vm_call_user_func(callback, params).toBoolean()) {
return MEMCACHED_NOTFOUND;
}
+3 -3
Ver Arquivo
@@ -1442,7 +1442,7 @@ Variant f_mysql_async_wait_actionable(CVarRef items, double timeout) {
// necessary for the descriptor in question, and put an entry into
// fds.
int nfds = 0;
for (ArrayIter iter(items); iter; ++iter) {
for (ArrayIter iter(items.toArray()); iter; ++iter) {
Array entry = iter.second().toArray();
if (entry.size() < 1) {
raise_warning("element %d did not have at least one entry",
@@ -1482,7 +1482,7 @@ Variant f_mysql_async_wait_actionable(CVarRef items, double timeout) {
// arrays from our input array into our return value.
Array ret = Array::Create();
nfds = 0;
for (ArrayIter iter(items); iter; ++iter) {
for (ArrayIter iter(items.toArray()); iter; ++iter) {
Array entry = iter.second().toArray();
if (entry.size() < 1) {
raise_warning("element %d did not have at least one entry",
@@ -1579,7 +1579,7 @@ Variant f_mysql_fetch_object(CVarRef result,
Variant properties = php_mysql_fetch_hash(result, MYSQL_ASSOC);
if (!same(properties, false)) {
Object obj = create_object(class_name, params);
obj->o_setArray(properties);
obj->o_setArray(properties.toArray());
return obj;
}
+1 -1
Ver Arquivo
@@ -343,7 +343,7 @@ Variant f_mysql_fetch_array(CVarRef result, int result_type = 3);
Variant f_mysql_fetch_lengths(CVarRef result);
Variant f_mysql_fetch_object(CVarRef result, CStrRef class_name = "stdClass",
CArrRef params = uninit_null());
CArrRef params = uninit_null().toArray());
Variant f_mysql_result(CVarRef result, int row, CVarRef field = null_variant);
+1 -1
Ver Arquivo
@@ -140,7 +140,7 @@ String f_get_current_user() {
}
Array f_get_defined_constants(CVarRef categorize /* = null_variant */) {
if (categorize) {
if (categorize.toBoolean()) {
throw NotSupportedException(__func__, "constant categorization not "
"supported");
}
+1 -1
Ver Arquivo
@@ -101,7 +101,7 @@ int64_t f_hphp_get_stats(CStrRef name) {
Array f_hphp_get_status() {
std::string out;
ServerStats::ReportStatus(out, ServerStats::Format::JSON);
return f_json_decode(String(out));
return f_json_decode(String(out)).toArray();
}
Array f_hphp_get_iostatus() {
return ServerStats::GetThreadIOStatuses();
+10 -8
Ver Arquivo
@@ -596,7 +596,7 @@ static void pdo_stmt_construct(sp_PDOStatement stmt, Object object,
static bool valid_statement_class(sp_PDOConnection dbh, CVarRef opt,
String &clsname, Variant &ctor_args) {
if (!opt.isArray() || !opt.toArray().exists(0) || !opt[0].isString() ||
!f_class_exists(opt[0])) {
!f_class_exists(opt[0].toString())) {
pdo_raise_impl_error
(dbh, NULL, "HY000",
"PDO::ATTR_STATEMENT_CLASS requires format array(classname, "
@@ -820,7 +820,7 @@ static bool pdo_stmt_set_fetch_mode(sp_PDOStatement stmt, int _argc, int64_t mod
pdo_raise_impl_error(stmt->dbh, stmt, "HY000",
"classname must be a string");
} else {
retval = f_class_exists(_argv[0]);
retval = f_class_exists(_argv[0].toString());
if (retval) {
stmt->fetch.clsname = _argv[0].toString();
}
@@ -1813,7 +1813,7 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
Variant val;
fetch_value(stmt, val, i++, NULL);
if (!val.isNull()) {
if (!f_class_exists(val)) {
if (!f_class_exists(val.toString())) {
stmt->fetch.clsname = "stdclass";
} else {
stmt->fetch.clsname = val.toString();
@@ -1836,7 +1836,7 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
if (!stmt->fetch.constructor.empty() &&
(flags & PDO_FETCH_PROPS_LATE)) {
ret.asCObjRef().get()->o_invoke(stmt->fetch.constructor,
stmt->fetch.ctor_args);
stmt->fetch.ctor_args.toArray());
ret.asCObjRef().get()->clearNoDestruct();
}
}
@@ -1972,7 +1972,8 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
case PDO_FETCH_CLASS:
if (!stmt->fetch.constructor.empty() &&
!(flags & (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
ret.toObject()->o_invoke(stmt->fetch.constructor, stmt->fetch.ctor_args);
ret.toObject()->o_invoke(stmt->fetch.constructor,
stmt->fetch.ctor_args.toArray());
ret.toObject()->clearNoDestruct();
}
if (flags & PDO_FETCH_CLASSTYPE) {
@@ -1982,7 +1983,8 @@ static bool do_fetch(sp_PDOStatement stmt, bool do_bind, Variant &ret,
break;
case PDO_FETCH_FUNC:
ret = vm_call_user_func(stmt->fetch.func, stmt->fetch.values);
ret = vm_call_user_func(stmt->fetch.func,
stmt->fetch.values.toArray());
break;
default:
@@ -2457,7 +2459,7 @@ safe:
if (stmt->dbh->support(PDOConnection::MethodQuoter)) {
if (param->param_type == PDO_PARAM_LOB &&
param->parameter.isResource()) {
Variant buf = f_stream_get_contents(param->parameter);
Variant buf = f_stream_get_contents(param->parameter.toObject());
if (!same(buf, false)) {
if (!stmt->dbh->quoter(buf.toString(), plc->quoted,
param->param_type)) {
@@ -2795,7 +2797,7 @@ Variant c_PDOStatement::t_fetchall(int64_t how /* = 0 */,
break;
case PDO_FETCH_FUNC:
if (!f_function_exists(class_name)) {
if (!f_function_exists(class_name.toString())) {
pdo_raise_impl_error(m_stmt->dbh, m_stmt, "HY000",
"no fetch function specified");
error = 1;
+2 -2
Ver Arquivo
@@ -78,7 +78,7 @@ static const StaticString s_dir("dir");
static const StaticString s_shell("shell");
static Variant php_posix_group_to_array(int gid,
CStrRef gname = null_variant) {
CStrRef gname = null_variant.toString()) {
// Don't pass a gid *and* a gname to this.
assert((gid < 0) || gname.size() == 0);
@@ -169,7 +169,7 @@ int64_t f_posix_getppid() {
}
static Variant php_posix_passwd_to_array(int uid,
CStrRef name = null_variant) {
CStrRef name = null_variant.toString()) {
// Don't pass a uid *and* a name to this.
assert((uid < 0) || name.size() == 0);
+9 -5
Ver Arquivo
@@ -434,7 +434,7 @@ String f_exec(CStrRef command, VRefParam output /* = null */,
StringBuffer sbuf;
sbuf.read(fp);
Array lines = StringUtil::Explode(sbuf.detach(), "\n");
Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
@@ -453,7 +453,9 @@ String f_exec(CStrRef command, VRefParam output /* = null */,
if (!count || lines.empty()) {
return String();
}
return StringUtil::Trim(lines[count - 1], StringUtil::TrimType::Right);
return StringUtil::Trim(lines[count - 1].toString(),
StringUtil::TrimType::Right);
}
void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
@@ -483,7 +485,7 @@ String f_system(CStrRef command, VRefParam return_var /* = null */) {
sbuf.read(fp);
}
Array lines = StringUtil::Explode(sbuf.detach(), "\n");
Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
@@ -493,13 +495,15 @@ String f_system(CStrRef command, VRefParam return_var /* = null */) {
}
for (int i = 0; i < count; i++) {
echo(lines[i]);
echo(lines[i].toString());
echo("\n");
}
if (!count || lines.empty()) {
return String();
}
return StringUtil::Trim(lines[count - 1], StringUtil::TrimType::Right);
return StringUtil::Trim(lines[count - 1].toString(),
StringUtil::TrimType::Right);
}
///////////////////////////////////////////////////////////////////////////////
+10 -10
Ver Arquivo
@@ -303,7 +303,7 @@ String SessionModule::create_sid() {
Logger::Error("Invalid session hash function: %s", PS(hash_func).c_str());
return String();
}
if (!f_hash_update(context, buf.detach())) {
if (!f_hash_update(context.toObject(), buf.detach())) {
Logger::Error("hash_update() failed");
return String();
}
@@ -318,7 +318,7 @@ String SessionModule::create_sid() {
n = ::read(fd, rbuf, (to_read < (int)sizeof(rbuf) ?
to_read : (int)sizeof(buf)));
if (n <= 0) break;
if (!f_hash_update(context,
if (!f_hash_update(context.toObject(),
String((const char *)rbuf, n, AttachLiteral))) {
Logger::Error("hash_update() failed");
::close(fd);
@@ -330,7 +330,7 @@ String SessionModule::create_sid() {
}
}
String hashed = f_hash_final(context);
String hashed = f_hash_final(context.toObject());
if (PS(hash_bits_per_character) < 4 || PS(hash_bits_per_character) > 6) {
PS(hash_bits_per_character) = 4;
@@ -716,14 +716,14 @@ public:
CREATE_VECTOR2(PS(ps_session_handler),
String("open")),
CREATE_VECTOR2(String(save_path, CopyString),
String(session_name, CopyString)));
String(session_name, CopyString))).toBoolean();
}
virtual bool close() {
return vm_call_user_func(
CREATE_VECTOR2(PS(ps_session_handler),
String("close")),
Array::Create());
Array::Create()).toBoolean();
}
virtual bool read(const char *key, String &value) {
@@ -742,21 +742,21 @@ public:
return vm_call_user_func(
CREATE_VECTOR2(PS(ps_session_handler),
String("write")),
CREATE_VECTOR2(String(key, CopyString), value));
CREATE_VECTOR2(String(key, CopyString), value)).toBoolean();
}
virtual bool destroy(const char *key) {
return vm_call_user_func(
CREATE_VECTOR2(PS(ps_session_handler),
String("destroy")),
CREATE_VECTOR1(String(key, CopyString)));
CREATE_VECTOR1(String(key, CopyString))).toBoolean();
}
virtual bool gc(int maxlifetime, int *nrdels) {
return vm_call_user_func(
CREATE_VECTOR2(PS(ps_session_handler),
String("gc")),
CREATE_VECTOR1((int64_t)maxlifetime));
CREATE_VECTOR1((int64_t)maxlifetime)).toBoolean();
}
};
static UserSessionModule s_user_session_module;
@@ -802,7 +802,7 @@ public:
virtual String encode() {
StringBuffer buf;
GlobalVariables *g = get_global_variables();
for (ArrayIter iter(g->get(s__SESSION)); iter; ++iter) {
for (ArrayIter iter(g->get(s__SESSION).toArray()); iter; ++iter) {
Variant key = iter.first();
if (key.isString()) {
String skey = key.toString();
@@ -855,7 +855,7 @@ public:
virtual String encode() {
StringBuffer buf;
GlobalVariables *g = get_global_variables();
for (ArrayIter iter(g->get(s__SESSION)); iter; ++iter) {
for (ArrayIter iter(g->get(s__SESSION).toArray()); iter; ++iter) {
Variant key = iter.first();
if (key.isString()) {
String skey = key.toString();
+13 -13
Ver Arquivo
@@ -531,7 +531,7 @@ Object c_SimpleXMLElement::t_children(CStrRef ns /* = "" */,
elem->m_children.assignRef(m_children);
} else {
Array props = Array::Create();
for (ArrayIter iter(m_children); iter; ++iter) {
for (ArrayIter iter(m_children.toArray()); iter; ++iter) {
if (iter.second().isObject()) {
c_SimpleXMLElement *elem = iter.second().toObject().
getTyped<c_SimpleXMLElement>();
@@ -540,7 +540,7 @@ Object c_SimpleXMLElement::t_children(CStrRef ns /* = "" */,
}
} else {
Array subnodes;
for (ArrayIter iter2(iter.second()); iter2; ++iter2) {
for (ArrayIter iter2(iter.second().toArray()); iter2; ++iter2) {
c_SimpleXMLElement *elem = iter2.second().toObject().
getTyped<c_SimpleXMLElement>();
if (elem->m_node && match_ns(elem->m_node, ns, is_prefix)) {
@@ -564,7 +564,7 @@ Object c_SimpleXMLElement::t_children(CStrRef ns /* = "" */,
String c_SimpleXMLElement::t_getname() {
if (m_is_children) {
Variant first;
ArrayIter iter(m_children);
ArrayIter iter(m_children.toArray());
if (iter) {
return iter.first();
}
@@ -713,7 +713,7 @@ void c_SimpleXMLElement::t_addattribute(CStrRef qname,
String c_SimpleXMLElement::t___tostring() {
Variant prop;
ArrayIter iter(m_children);
ArrayIter iter(m_children.toArray());
if (iter) {
prop = iter.second();
if (prop.isString()) {
@@ -771,7 +771,7 @@ Variant c_SimpleXMLElement::t___unset(Variant name) {
xmlUnlinkNode(elem->m_node);
}
} else if (node.isArray()) {
for (ArrayIter iter(node); iter; ++iter) {
for (ArrayIter iter(node.toArray()); iter; ++iter) {
c_SimpleXMLElement *elem = iter.second().toObject().
getTyped<c_SimpleXMLElement>();
if (elem->m_node) {
@@ -881,7 +881,7 @@ bool c_SimpleXMLElement::o_toBooleanImpl() const noexcept {
int64_t c_SimpleXMLElement::o_toInt64Impl() const noexcept {
Variant prop;
ArrayIter iter(m_children);
ArrayIter iter(m_children.toArray());
if (iter) {
prop = iter.second();
}
@@ -890,7 +890,7 @@ int64_t c_SimpleXMLElement::o_toInt64Impl() const noexcept {
double c_SimpleXMLElement::o_toDoubleImpl() const noexcept {
Variant prop;
ArrayIter iter(m_children);
ArrayIter iter(m_children.toArray());
if (iter) {
prop = iter.second();
}
@@ -899,7 +899,7 @@ double c_SimpleXMLElement::o_toDoubleImpl() const noexcept {
Array c_SimpleXMLElement::o_toArray() const {
if (m_attributes.toArray().empty()) {
return m_children;
return m_children.toArray();
}
Array ret;
ret.set(s_attributes, m_attributes);
@@ -1037,7 +1037,7 @@ void c_SimpleXMLElementIterator::reset_iterator() {
delete m_iter2; m_iter2 = NULL;
if (m_parent->m_is_attribute) {
m_iter1 = new ArrayIter(m_parent->m_attributes);
m_iter1 = new ArrayIter(m_parent->m_attributes.toArray());
return;
}
@@ -1058,7 +1058,7 @@ void c_SimpleXMLElementIterator::reset_iterator() {
}
if (m_parent->m_children.toArray().size() == 1) {
ArrayIter iter(m_parent->m_children);
ArrayIter iter(m_parent->m_children.toArray());
if (iter.second().isObject()) {
c_SimpleXMLElement *elem = iter.second().toObject().
getTyped<c_SimpleXMLElement>();
@@ -1068,9 +1068,9 @@ void c_SimpleXMLElementIterator::reset_iterator() {
}
}
m_iter1 = new ArrayIter(m_parent->m_children);
m_iter1 = new ArrayIter(m_parent->m_children.toArray());
if (!m_iter1->end() && m_iter1->second().isArray()) {
m_iter2 = new ArrayIter(m_iter1->second());
m_iter2 = new ArrayIter(m_iter1->second().toArray());
}
}
@@ -1120,7 +1120,7 @@ Variant c_SimpleXMLElementIterator::t_next() {
m_iter1->next();
while (!m_iter1->end()) {
if (m_iter1->second().isArray()) {
m_iter2 = new ArrayIter(m_iter1->second());
m_iter2 = new ArrayIter(m_iter1->second().toArray());
break;
}
if (m_iter1->second().isObject()) {
+6 -6
Ver Arquivo
@@ -559,13 +559,13 @@ static encodeMapPtr soap_create_typemap_impl(sdl *sdl, Array &ht) {
new_enc->to_xml = enc->to_xml;
new_enc->to_zval = enc->to_zval;
new_enc->details.map = soapMappingPtr(new soapMapping());
if (to_xml) {
if (to_xml.toBoolean()) {
new_enc->details.map->to_xml = to_xml;
new_enc->to_xml = to_xml_user;
} else if (enc->details.map && !enc->details.map->to_xml.isNull()) {
new_enc->details.map->to_xml = enc->details.map->to_xml;
}
if (to_zval) {
if (to_zval.toBoolean()) {
new_enc->details.map->to_zval = to_zval;
new_enc->to_zval = to_zval_user;
} else if (enc->details.map && !enc->details.map->to_zval.isNull()) {
@@ -2094,7 +2094,7 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
GlobalVariables *g = get_global_variables();
if (g->get(s__SERVER).toArray().exists(s_HTTP_CONTENT_ENCODING)) {
String encoding = g->get(s__SERVER)[s_HTTP_CONTENT_ENCODING];
String encoding = g->get(s__SERVER)[s_HTTP_CONTENT_ENCODING].toString();
Variant ret;
if (encoding == "gzip" || encoding == "x-gzip") {
ret = f_gzinflate(String(data, size, AttachLiteral));
@@ -2440,7 +2440,7 @@ void c_SoapClient::t___construct(CVarRef wsdl,
}
Variant c_SoapClient::t___call(Variant name, Variant args) {
return t___soapcall(name, args);
return t___soapcall(name.toString(), args.toArray());
}
Variant c_SoapClient::t___soapcall(CStrRef name, CArrRef args,
@@ -2479,7 +2479,7 @@ Variant c_SoapClient::t___soapcall(CStrRef name, CArrRef args,
return uninit_null();
}
if (!m_default_headers.isNull()) {
soap_headers.merge(m_default_headers);
soap_headers.merge(m_default_headers.toArray());
}
output_headers = Array::Create();
@@ -2799,7 +2799,7 @@ void c_SoapVar::t___construct(CVarRef data, CVarRef type,
}
}
if (data) m_value = data;
if (data.toBoolean()) m_value = data;
if (!type_name.empty()) m_stype = type_name;
if (!type_namespace.empty()) m_ns = type_namespace;
if (!node_name.empty()) m_name = node_name;
+1 -1
Ver Arquivo
@@ -548,7 +548,7 @@ Variant c_SQLite3Stmt::t_execute() {
{
String sblob;
if (p.value.isResource()) {
Variant blob = f_stream_get_contents(p.value);
Variant blob = f_stream_get_contents(p.value.toObject());
if (same(blob, false)) {
raise_warning("Unable to read stream for parameter %d",
p.index);
+8 -8
Ver Arquivo
@@ -46,10 +46,10 @@ String f_base64_encode(CStrRef data) {
Variant f_get_headers(CStrRef url, int format /* = 0 */) {
Variant c = f_curl_init();
f_curl_setopt(c, k_CURLOPT_URL, url);
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c, k_CURLOPT_HEADER, 1);
Variant res = f_curl_exec(c);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, url);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c.toObject(), k_CURLOPT_HEADER, 1);
Variant res = f_curl_exec(c.toObject());
if (same(res, false)) {
return false;
}
@@ -60,14 +60,14 @@ Variant f_get_headers(CStrRef url, int format /* = 0 */) {
response = response.substr(0, pos);
}
Array ret = f_explode("\r\n", response);
Array ret = f_explode("\r\n", response).toArray();
if (!format) {
return ret;
}
Array assoc;
for (ArrayIter iter(ret); iter; ++iter) {
Array tokens = f_explode(": ", iter.second(), 2);
Array tokens = f_explode(": ", iter.second(), 2).toArray();
if (tokens.size() == 2) {
assoc.set(tokens[0], tokens[1]);
} else {
@@ -102,8 +102,8 @@ Array f_get_meta_tags(CStrRef filename, bool use_include_path /* = false */) {
f, ref(matches), k_PREG_SET_ORDER);
Array ret = Array::Create();
for (ArrayIter iter(matches); iter; ++iter) {
Array pair = iter.second();
for (ArrayIter iter(matches.toArray()); iter; ++iter) {
Array pair = iter.second().toArray();
ret.set(normalize_variable_name(pair[1].toString()), pair[2]);
}
return ret;
+15 -14
Ver Arquivo
@@ -329,7 +329,7 @@ static String _xml_string_zval(const char *str) {
static Variant xml_call_handler(XmlParser *parser, CVarRef handler,
CArrRef args) {
if (parser && handler) {
if (parser && handler.toBoolean()) {
Variant retval;
if (handler.isString()) {
if (!parser->object.isObject()) {
@@ -382,7 +382,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name) {
tag_name = _xml_decode_tag(parser, (const char*)name);
if (parser->endElementHandler) {
if (parser->endElementHandler.toBoolean()) {
args.append(parser);
args.append(_xml_string_zval(tag_name));
xml_call_handler(parser, parser->endElementHandler, args);
@@ -419,7 +419,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) {
Variant retval;
Array args = Array::Create();
if (parser->characterDataHandler) {
if (parser->characterDataHandler.toBoolean()) {
args.append(parser);
args.append(_xml_xmlchar_zval(s, len, parser->target_encoding));
xml_call_handler(parser, parser->characterDataHandler, args);
@@ -496,7 +496,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) {
void _xml_defaultHandler(void *userData, const XML_Char *s, int len) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->defaultHandler) {
if (parser && parser->defaultHandler.toBoolean()) {
xml_call_handler(parser, parser->defaultHandler, CREATE_VECTOR2(
parser, _xml_xmlchar_zval(s, len, parser->target_encoding)));
}
@@ -513,7 +513,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
char* tag_name = _xml_decode_tag(parser, (const char*)name);
if (parser->startElementHandler) {
if (parser->startElementHandler.toBoolean()) {
args.append(parser);
args.append(_xml_string_zval(tag_name));
args.append(Array::Create());
@@ -574,7 +574,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
void _xml_processingInstructionHandler(void *userData, const XML_Char *target,
const XML_Char *data) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->processingInstructionHandler) {
if (parser && parser->processingInstructionHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
args.append(_xml_xmlchar_zval(target, 0, parser->target_encoding));
@@ -590,7 +590,7 @@ int _xml_externalEntityRefHandler(XML_ParserStruct* /* void* */ parserPtr,
const XML_Char *publicId) {
XmlParser *parser = (XmlParser*)XML_GetUserData((XML_Parser)parserPtr);
int ret = 0; /* abort if no handler is set (should be configurable?) */
if (parser && parser->externalEntityRefHandler) {
if (parser && parser->externalEntityRefHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
args.append(_xml_xmlchar_zval(openEntityNames, 0,
@@ -598,7 +598,8 @@ int _xml_externalEntityRefHandler(XML_ParserStruct* /* void* */ parserPtr,
args.append(_xml_xmlchar_zval(base, 0, parser->target_encoding));
args.append(_xml_xmlchar_zval(systemId, 0, parser->target_encoding));
args.append(_xml_xmlchar_zval(publicId, 0, parser->target_encoding));
ret = xml_call_handler(parser, parser->externalEntityRefHandler, args);
ret = xml_call_handler(parser,
parser->externalEntityRefHandler, args).toInt64();
}
return ret;
}
@@ -610,7 +611,7 @@ void _xml_notationDeclHandler(void *userData,
const XML_Char *publicId) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->notationDeclHandler) {
if (parser && parser->notationDeclHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
args.append(_xml_xmlchar_zval(notationName, 0, parser->target_encoding));
@@ -625,7 +626,7 @@ void _xml_startNamespaceDeclHandler(void *userData,const XML_Char *prefix,
const XML_Char *uri) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->startNamespaceDeclHandler) {
if (parser && parser->startNamespaceDeclHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
@@ -638,7 +639,7 @@ void _xml_startNamespaceDeclHandler(void *userData,const XML_Char *prefix,
void _xml_endNamespaceDeclHandler(void *userData, const XML_Char *prefix) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->endNamespaceDeclHandler) {
if (parser && parser->endNamespaceDeclHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
args.append(_xml_xmlchar_zval(prefix, 0, parser->target_encoding));
@@ -654,7 +655,7 @@ void _xml_unparsedEntityDeclHandler(void *userData,
const XML_Char *notationName) {
XmlParser *parser = (XmlParser *)userData;
if (parser && parser->unparsedEntityDeclHandler) {
if (parser && parser->unparsedEntityDeclHandler.toBoolean()) {
Array args = Array::Create();
args.append(parser);
args.append(_xml_xmlchar_zval(entityName, 0, parser->target_encoding));
@@ -680,12 +681,12 @@ static void xml_set_handler(Variant * handler, CVarRef data) {
///////////////////////////////////////////////////////////////////////////////
Object f_xml_parser_create(CStrRef encoding /* = null_string */) {
return php_xml_parser_create_impl(encoding, null_string, 0);
return php_xml_parser_create_impl(encoding, null_string, 0).toObject();
}
Object f_xml_parser_create_ns(CStrRef encoding /* = null_string */,
CStrRef separator /* = null_string */) {
return php_xml_parser_create_impl(encoding, separator, 1);
return php_xml_parser_create_impl(encoding, separator, 1).toObject();
}
bool f_xml_parser_free(CObjRef parser) {
+2 -2
Ver Arquivo
@@ -215,7 +215,7 @@ static Variant filter_var(CVarRef variable, int64_t filter, CVarRef options) {
option_array = options[s_options];
}
Variant ret(filter_func.function(variable, flags, option_array));
Variant ret(filter_func.function(variable.toString(), flags, option_array));
if (option_array.isArray() && option_array.toArray().exists(s_default) &&
((flags & k_FILTER_NULL_ON_FAILURE && ret.isNull()) ||
(!(flags & k_FILTER_NULL_ON_FAILURE) && ret.isBoolean() &&
@@ -228,7 +228,7 @@ static Variant filter_var(CVarRef variable, int64_t filter, CVarRef options) {
static Variant filter_recursive(CVarRef variable, int64_t filter,
CVarRef options) {
Array ret;
for (ArrayIter iter(variable); iter; ++iter) {
for (ArrayIter iter(variable.toArray()); iter; ++iter) {
if (iter.second().isArray()) {
ret.add(
iter.first(),
+2 -2
Ver Arquivo
@@ -372,7 +372,7 @@ Variant php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) {
RETURN_VALIDATION_FAILED
}
int matches = preg_match(regexp, value);
int matches = preg_match(regexp, value).toInt32();
if (matches <= 0) {
RETURN_VALIDATION_FAILED
@@ -470,7 +470,7 @@ Variant php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) {
RETURN_VALIDATION_FAILED
}
int matches = preg_match(regexp, value);
int matches = preg_match(regexp, value).toInt32();
if (matches <= 0) {
RETURN_VALIDATION_FAILED
+2 -2
Ver Arquivo
@@ -910,7 +910,7 @@ Variant MimePart::extract(CVarRef filename, CVarRef callbackfunc, int decode,
if (filename.isResource()) {
f = filename.toObject().getTyped<File>();
} else if (isfile) {
Variant stream = File::Open(filename, "rb");
Variant stream = File::Open(filename.toString(), "rb");
if (!same(stream, false)) {
file = stream.toObject();
f = file.getTyped<File>();
@@ -944,7 +944,7 @@ Variant MimePart::extract(CVarRef filename, CVarRef callbackfunc, int decode,
return m_extract_context;
}
if (callbackfunc.isResource()) {
return f_stream_get_contents(callbackfunc);
return f_stream_get_contents(callbackfunc.toObject());
}
return true;
}
+2 -2
Ver Arquivo
@@ -475,7 +475,7 @@ bool PDOMySqlConnection::preparer(CStrRef sql, sp_PDOStatement *stmt,
return true;
}
if (s->create(sql, options)) {
if (s->create(sql, options.toArray())) {
alloc_own_columns = 1;
return true;
}
@@ -1100,7 +1100,7 @@ bool PDOMySqlStatement::paramHook(PDOBoundParam *param,
return false;
case PDO_PARAM_LOB:
if (param->parameter.isResource()) {
Variant buf = f_stream_get_contents(param->parameter);
Variant buf = f_stream_get_contents(param->parameter.toObject());
if (!same(buf, false)) {
param->parameter = buf;
} else {
+1 -1
Ver Arquivo
@@ -499,7 +499,7 @@ bool PDOSqliteStatement::paramHook(PDOBoundParam *param,
case PDO_PARAM_LOB:
if (param->parameter.isResource()) {
Variant buf = f_stream_get_contents(param->parameter);
Variant buf = f_stream_get_contents(param->parameter.toObject());
if (!same(buf, false)) {
param->parameter = buf;
} else {
+2 -2
Ver Arquivo
@@ -1193,7 +1193,7 @@ static void model_to_zval_any(Variant &ret, xmlNodePtr node) {
if (!val2.isString()) {
break;
}
concat_assign(val, val2);
concat_assign(val, val2.toString());
node = node->next;
}
} else {
@@ -1233,7 +1233,7 @@ static void model_to_zval_any(Variant &ret, xmlNodePtr node) {
}
node = node->next;
}
if (any) {
if (any.toBoolean()) {
ret.toObject()->o_set(name ? String(name, CopyString) : "any", any);
}
}
+1 -1
Ver Arquivo
@@ -81,7 +81,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename) {
Variant stream = File::Open(filename, "rb", 0, f_stream_context_create(
CREATE_MAP1(s_http, CREATE_MAP1(s_timeout, 1000))));
if (!same(stream, false)) {
content = f_stream_get_contents(stream);
content = f_stream_get_contents(stream.toObject());
if (!same(content, false)) {
f_apc_store(cache_key, content);
}
+2 -2
Ver Arquivo
@@ -115,7 +115,7 @@ Variant binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport,
throw_tprotocolexception(String(errbuf, CopyString), INVALID_DATA);
return uninit_null();
}
binary_deserialize_spec(ret, transport, spec.toArray());
binary_deserialize_spec(ret.toObject(), transport, spec.toArray());
return ret;
} break;
case T_BOOL: {
@@ -356,7 +356,7 @@ void binary_serialize(int8_t thrift_typeID, PHPOutputTransport& transport,
throw_tprotocolexception("Attempt to send non-object "
"type as a T_STRUCT", INVALID_DATA);
}
binary_serialize_spec(value, transport,
binary_serialize_spec(value.toObject(), transport,
f_hphp_get_static_property(value.toObject()->
o_getClassName(),
s_TSPEC).toArray());
+9 -7
Ver Arquivo
@@ -287,7 +287,7 @@ class CompactWriter {
thrift_error("Attempt to send non-object type as T_STRUCT",
ERR_INVALID_DATA);
}
writeStruct(value);
writeStruct(value.toObject());
break;
case T_BOOL: {
@@ -503,12 +503,12 @@ class CompactReader {
if (type == T_REPLY) {
Object ret = create_object(resultClassName, Array());
Variant spec = f_hphp_get_static_property(resultClassName, "_TSPEC");
readStruct(ret, spec);
readStruct(ret, spec.toArray());
return ret;
} else if (type == T_EXCEPTION) {
Object exn = create_object("TApplicationException", Array());
Variant spec = f_hphp_get_static_property("TApplicationException", "_TSPEC");
readStruct(exn, spec);
readStruct(exn, spec.toArray());
throw exn;
} else {
thrift_error("Invalid response type", ERR_INVALID_DATA);
@@ -635,7 +635,7 @@ class CompactReader {
thrift_error("invalid type of spec", ERR_INVALID_DATA);
}
readStruct(newStruct, newStructSpec);
readStruct(newStruct.toObject(), newStructSpec.toArray());
return newStruct;
}
@@ -787,8 +787,10 @@ class CompactReader {
uint32_t size;
readMapBegin(keyType, valueType, size);
Array keySpec = spec.rvalAt(PHPTransport::s_key, AccessFlags::Error);
Array valueSpec = spec.rvalAt(PHPTransport::s_val, AccessFlags::Error);
Array keySpec = spec.rvalAt(PHPTransport::s_key,
AccessFlags::Error).toArray();
Array valueSpec = spec.rvalAt(PHPTransport::s_val,
AccessFlags::Error).toArray();
Variant ret = Array::Create();
for (uint32_t i = 0; i < size; i++) {
@@ -807,7 +809,7 @@ class CompactReader {
readListBegin(valueType, size);
Array valueSpec = spec.rvalAt(PHPTransport::s_elem,
AccessFlags::Error_Key);
AccessFlags::Error_Key).toArray();
Variant ret = Array::Create();
for (uint32_t i = 0; i < size; i++) {
+1 -1
Ver Arquivo
@@ -117,7 +117,7 @@ protected:
buffer_used = 0;
buffer_size = _buffer_size;
p = _p;
t = p->o_invoke_few_args(s_getTransport, 0);
t = p->o_invoke_few_args(s_getTransport, 0).toObject();
}
~PHPTransport() {
free(buffer);
+67 -57
Ver Arquivo
@@ -3691,7 +3691,8 @@ inline void OPTBLD_INLINE VMExecutionContext::iopConcat(PC& pc) {
Cell* c1 = m_stack.topC();
Cell* c2 = m_stack.indC(1);
if (IS_STRING_TYPE(c1->m_type) && IS_STRING_TYPE(c2->m_type)) {
tvCellAsVariant(c2) = concat(tvCellAsVariant(c2), tvCellAsCVarRef(c1));
tvCellAsVariant(c2) = concat(
tvCellAsVariant(c2).toString(), tvCellAsCVarRef(c1).toString());
} else {
tvCellAsVariant(c2) = concat(tvCellAsVariant(c2).toString(),
tvCellAsCVarRef(c1).toString());
@@ -3717,6 +3718,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopConcat(PC& pc) {
m_stack.popC(); \
} \
} while (0)
#define MATHOP_DOUBLE(OP) \
else if (c2->m_type == KindOfDouble \
&& c1->m_type == KindOfDouble) { \
@@ -3766,22 +3768,27 @@ inline void OPTBLD_INLINE VMExecutionContext::iopDiv(PC& pc) {
}
#undef MATHOP_DOUBLE
// XXX:
Numeric moduloVar(CVarRef v1, CVarRef v2) {
return modulo(v1.toInt64(), v2.toInt64());
}
#define MATHOP_DOUBLE(OP)
inline void OPTBLD_INLINE VMExecutionContext::iopMod(PC& pc) {
MATHOP(%, modulo);
MATHOP(%, moduloVar);
}
#undef MATHOP_DOUBLE
#undef MATHOP_DIVCHECK
#define LOGICOP(OP) do { \
NEXT(); \
Cell* c1 = m_stack.topC(); \
Cell* c2 = m_stack.indC(1); \
{ \
tvCellAsVariant(c2) = \
(bool)(bool(tvCellAsVariant(c2)) OP bool(tvCellAsVariant(c1))); \
} \
m_stack.popC(); \
#define LOGICOP(OP) do { \
NEXT(); \
Cell* c1 = m_stack.topC(); \
Cell* c2 = m_stack.indC(1); \
{ \
tvCellAsVariant(c2) = \
bool(tvCellAsVariant(c2).toBoolean() OP tvCellAsVariant(c1).toBoolean()); \
} \
m_stack.popC(); \
} while (0)
inline void OPTBLD_INLINE VMExecutionContext::iopXor(PC& pc) {
@@ -3792,27 +3799,28 @@ inline void OPTBLD_INLINE VMExecutionContext::iopXor(PC& pc) {
inline void OPTBLD_INLINE VMExecutionContext::iopNot(PC& pc) {
NEXT();
Cell* c1 = m_stack.topC();
tvCellAsVariant(c1) = !bool(tvCellAsVariant(c1));
tvCellAsVariant(c1) = !tvCellAsVariant(c1).toBoolean();
}
#define CMPOP(OP, VOP) do { \
NEXT(); \
Cell* c1 = m_stack.topC(); \
Cell* c2 = m_stack.indC(1); \
if (c2->m_type == KindOfInt64 && c1->m_type == KindOfInt64) { \
int64_t a = c2->m_data.num; \
int64_t b = c1->m_data.num; \
c2->m_data.num = (a OP b); \
c2->m_type = KindOfBoolean; \
m_stack.popX(); \
} else { \
int64_t result = VOP(tvCellAsVariant(c2), tvCellAsCVarRef(c1)); \
tvRefcountedDecRefCell(c2); \
c2->m_data.num = result; \
c2->m_type = KindOfBoolean; \
m_stack.popC(); \
} \
#define CMPOP(OP, VOP) do { \
NEXT(); \
Cell* c1 = m_stack.topC(); \
Cell* c2 = m_stack.indC(1); \
if (c2->m_type == KindOfInt64 && c1->m_type == KindOfInt64) { \
int64_t a = c2->m_data.num; \
int64_t b = c1->m_data.num; \
c2->m_data.num = (a OP b); \
c2->m_type = KindOfBoolean; \
m_stack.popX(); \
} else { \
int64_t result = VOP(tvCellAsVariant(c2), tvCellAsCVarRef(c1)); \
tvRefcountedDecRefCell(c2); \
c2->m_data.num = result; \
c2->m_type = KindOfBoolean; \
m_stack.popC(); \
} \
} while (0)
inline void OPTBLD_INLINE VMExecutionContext::iopSame(PC& pc) {
CMPOP(==, same);
}
@@ -4059,40 +4067,42 @@ inline void OPTBLD_INLINE VMExecutionContext::iopJmp(PC& pc) {
pc += offset - 1;
}
#define JMPOP(OP, VOP) do { \
Cell* c1 = m_stack.topC(); \
if (c1->m_type == KindOfInt64 || c1->m_type == KindOfBoolean) { \
int64_t n = c1->m_data.num; \
if (n OP 0) { \
NEXT(); \
DECODE_JMP(Offset, offset); \
JMP_SURPRISE_CHECK(); \
pc += offset - 1; \
m_stack.popX(); \
} else { \
pc += 1 + sizeof(Offset); \
m_stack.popX(); \
} \
} else { \
if (VOP(tvCellAsCVarRef(c1))) { \
NEXT(); \
DECODE_JMP(Offset, offset); \
JMP_SURPRISE_CHECK(); \
pc += offset - 1; \
m_stack.popC(); \
} else { \
pc += 1 + sizeof(Offset); \
m_stack.popC(); \
} \
} \
#define JMPOP(OP, VOP) do { \
Cell* c1 = m_stack.topC(); \
if (c1->m_type == KindOfInt64 || c1->m_type == KindOfBoolean) { \
int64_t n = c1->m_data.num; \
if (n OP 0) { \
NEXT(); \
DECODE_JMP(Offset, offset); \
JMP_SURPRISE_CHECK(); \
pc += offset - 1; \
m_stack.popX(); \
} else { \
pc += 1 + sizeof(Offset); \
m_stack.popX(); \
} \
} else { \
if (VOP(tvCellAsCVarRef(c1))) { \
NEXT(); \
DECODE_JMP(Offset, offset); \
JMP_SURPRISE_CHECK(); \
pc += offset - 1; \
m_stack.popC(); \
} else { \
pc += 1 + sizeof(Offset); \
m_stack.popC(); \
} \
} \
} while (0)
inline void OPTBLD_INLINE VMExecutionContext::iopJmpZ(PC& pc) {
JMPOP(==, !bool);
JMPOP(==, !toBoolean);
}
inline void OPTBLD_INLINE VMExecutionContext::iopJmpNZ(PC& pc) {
JMPOP(!=, bool);
JMPOP(!=, toBoolean);
}
#undef JMPOP
#undef JMP_SURPRISE_CHECK
+20 -18
Ver Arquivo
@@ -38,24 +38,26 @@ namespace HPHP {
// SETOP_BODY() would ideally be an inline function, but the header
// dependencies for concat_assign() make this unfeasible.
#define SETOP_BODY(lhs, op, rhs) do { \
switch (op) { \
case SetOpPlusEqual: tvAsVariant(lhs) += tvCellAsCVarRef(rhs); break; \
case SetOpMinusEqual: tvAsVariant(lhs) -= tvCellAsCVarRef(rhs); break; \
case SetOpMulEqual: tvAsVariant(lhs) *= tvCellAsCVarRef(rhs); break; \
case SetOpDivEqual: tvAsVariant(lhs) /= tvCellAsCVarRef(rhs); break; \
case SetOpConcatEqual: { \
concat_assign(tvAsVariant(lhs), tvCellAsCVarRef(rhs)); \
break; \
} \
case SetOpModEqual: tvAsVariant(lhs) %= tvCellAsCVarRef(rhs); break; \
case SetOpAndEqual: tvAsVariant(lhs) &= tvCellAsCVarRef(rhs); break; \
case SetOpOrEqual: tvAsVariant(lhs) |= tvCellAsCVarRef(rhs); break; \
case SetOpXorEqual: tvAsVariant(lhs) ^= tvCellAsCVarRef(rhs); break; \
case SetOpSlEqual: tvAsVariant(lhs) <<= tvCellAsCVarRef(rhs); break; \
case SetOpSrEqual: tvAsVariant(lhs) >>= tvCellAsCVarRef(rhs); break; \
default: assert(false); \
} \
#define SETOP_BODY(lhs, op, rhs) do { \
switch (op) { \
case SetOpPlusEqual: tvAsVariant(lhs) += tvCellAsCVarRef(rhs); break; \
case SetOpMinusEqual: tvAsVariant(lhs) -= tvCellAsCVarRef(rhs); break; \
case SetOpMulEqual: tvAsVariant(lhs) *= tvCellAsCVarRef(rhs); break; \
case SetOpDivEqual: tvAsVariant(lhs) /= tvCellAsCVarRef(rhs); break; \
case SetOpConcatEqual: { \
concat_assign(tvAsVariant(lhs), tvCellAsCVarRef(rhs).toString()); \
break; \
} \
case SetOpModEqual: tvAsVariant(lhs) %= tvCellAsCVarRef(rhs); break; \
case SetOpAndEqual: tvAsVariant(lhs) &= tvCellAsCVarRef(rhs); break; \
case SetOpOrEqual: tvAsVariant(lhs) |= tvCellAsCVarRef(rhs); break; \
case SetOpXorEqual: tvAsVariant(lhs) ^= tvCellAsCVarRef(rhs); break; \
case SetOpSlEqual: tvAsVariant(lhs) <<= \
tvCellAsCVarRef(rhs).toInt64(); break; \
case SetOpSrEqual: tvAsVariant(lhs) >>= \
tvCellAsCVarRef(rhs).toInt64(); break; \
default: assert(false); \
} \
} while (0)
class Func;
+2 -2
Ver Arquivo
@@ -679,9 +679,9 @@ bool Instance::t___isset(Variant v_name) {
TypedValue args[1];
tvDup(v_name.asTypedValue(), args + 0);
g_vmContext->invokeFuncFew((TypedValue*)&v, method, this, nullptr, 1, args);
return v;
return v.toBoolean();
} else {
return uninit_null();
return false;
}
}
+1 -1
Ver Arquivo
@@ -251,7 +251,7 @@ inline TypedValue* Elem(TypedValue& tvScratch, TypedValue& tvRef,
x = key->m_data.pstr->toInt64(10);
} else {
raise_warning("String offset cast occurred");
x = int64_t(tvCellAsCVarRef(key));
x = tvCellAsCVarRef(key).toInt64();
}
if (x < 0 || x >= base->m_data.pstr->size()) {
if (warn) {
+1 -1
Ver Arquivo
@@ -302,7 +302,7 @@ tv_to_bool(TypedValue* tv) {
ArrayData* ad = tv->m_data.parr;
retval = bool(arr0_to_bool(ad));
} else {
retval = bool(tvAsCVarRef(tv));
retval = tvAsCVarRef(tv).toBoolean();
}
TRACE(2, Trace::prettyNode("TvToBool", *tv) + string(" -> ") +
string(retval ? "t" : "f") + string("\n"));
+2 -2
Ver Arquivo
@@ -86,7 +86,7 @@ class TestBase {
template <bool value>
class WithOption {
public:
WithOption(bool &option) :
explicit WithOption(bool& option) :
m_option(&option), m_save(option) {
option = value;
}
@@ -117,7 +117,7 @@ typedef WithOption<false> WithNoOpt;
return CountSkip(); \
#define VERIFY(exp) \
if (!(exp)) { \
if (!toBoolean(exp)) { \
LOG_TEST_ERROR("%s:%d: [%s] is false", __FILE__, __LINE__, #exp); \
return Count(false); \
} \
+2 -2
Ver Arquivo
@@ -236,7 +236,7 @@ bool TestCppBase::TestArray() {
arr = Array::Create(0);
VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
VERIFY(!arr.isNull());
VERIFY((int)arr[0] == 0);
VERIFY(arr[0].toInt32() == 0);
VS(arr, Array(ArrayInit(1).set(0).create()));
arr = Array::Create("test");
@@ -256,7 +256,7 @@ bool TestCppBase::TestArray() {
arr = Array::Create("name", 1);
VERIFY(!arr.empty()); VERIFY(arr.size() == 1); VERIFY(arr.length() == 1);
VERIFY(!arr.isNull());
VERIFY((int)arr[s_name] == 1);
VERIFY(arr[s_name].toInt32() == 1);
VS(arr, Array(ArrayInit(1).set(s_name, 1).create()));
arr = Array::Create(s_name, "test");
+5 -5
Ver Arquivo
@@ -94,10 +94,10 @@ bool TestDebugger::getResponse(const string& path, string& result,
server += "/" + path;
printf("\n Getting URL '%s'...\n", server.get()->data());
Variant c = f_curl_init();
f_curl_setopt(c, k_CURLOPT_URL, server);
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c, CURLOPT_TIMEOUT, 120);
Variant res = f_curl_exec(c);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, server);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c.toObject(), CURLOPT_TIMEOUT, 120);
Variant res = f_curl_exec(c.toObject());
if (same(res, false)) {
printf(" Request failed\n");
return false;
@@ -171,7 +171,7 @@ static std::string getSandboxHostFormat() {
// and we need to change to the following to match sandbox format:
// www.<sandbox>.<host>.<domain>.com
String hostName = f_php_uname("n");
Array fields = f_split("\\.", hostName);
Array fields = f_split("\\.", hostName).toArray();
if (fields.size() != 4) {
return "";
}
+58 -58
Ver Arquivo
@@ -116,18 +116,18 @@ bool TestExtCurl::RunTests(const std::string &which) {
bool TestExtCurl::test_curl_init() {
Variant c = f_curl_init();
VS(f_curl_errno(c), 0);
VS(f_curl_error(c), "");
VS(f_curl_errno(c.toObject()), 0);
VS(f_curl_error(c.toObject()), "");
return Count(true);
}
bool TestExtCurl::test_curl_copy_handle() {
Variant c = f_curl_init();
f_curl_setopt(c, k_CURLOPT_URL, String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
Variant cpy = f_curl_copy_handle(c);
f_curl_close(c); // to test cpy is still working fine
Variant res = f_curl_exec(cpy);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, String(get_request_uri()));
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
Variant cpy = f_curl_copy_handle(c.toObject());
f_curl_close(c.toObject()); // to test cpy is still working fine
Variant res = f_curl_exec(cpy.toObject());
if (res.toString() != "OK") {
// XXX: t1782098
return CountSkip();
@@ -151,9 +151,9 @@ bool TestExtCurl::test_curl_version() {
bool TestExtCurl::test_curl_setopt() {
Variant c = f_curl_init();
f_curl_setopt(c, k_CURLOPT_URL, String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, String(get_request_uri()));
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c.toObject());
VS(res, "OK");
return Count(true);
}
@@ -161,10 +161,10 @@ bool TestExtCurl::test_curl_setopt() {
bool TestExtCurl::test_curl_setopt_array() {
Variant c = f_curl_init();
f_curl_setopt_array
(c,
(c.toObject(),
CREATE_MAP2(k_CURLOPT_URL, String(get_request_uri()),
k_CURLOPT_RETURNTRANSFER, true));
Variant res = f_curl_exec(c);
Variant res = f_curl_exec(c.toObject());
VS(res, "OK");
return Count(true);
}
@@ -172,15 +172,15 @@ bool TestExtCurl::test_curl_setopt_array() {
bool TestExtCurl::test_curl_exec() {
{
Variant c = f_curl_init(String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c.toObject());
VS(res, "OK");
}
{
Variant c = f_curl_init(String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_WRITEFUNCTION, "curl_write_func");
f_curl_setopt(c.toObject(), k_CURLOPT_WRITEFUNCTION, "curl_write_func");
f_ob_start();
f_curl_exec(c);
f_curl_exec(c.toObject());
String res = f_ob_get_contents();
VS(res, "curl_write_func called with OK");
f_ob_end_clean();
@@ -190,29 +190,29 @@ bool TestExtCurl::test_curl_exec() {
bool TestExtCurl::test_curl_getinfo() {
Variant c = f_curl_init(String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c);
Variant ret = f_curl_getinfo(c);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c.toObject());
Variant ret = f_curl_getinfo(c.toObject());
VS(ret[s_url], String(get_request_uri()));
ret = f_curl_getinfo(c, k_CURLINFO_EFFECTIVE_URL);
ret = f_curl_getinfo(c.toObject(), k_CURLINFO_EFFECTIVE_URL);
VS(ret, String(get_request_uri()));
return Count(true);
}
bool TestExtCurl::test_curl_errno() {
Variant c = f_curl_init("http://www.thereisnosuchanurl");
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c);
Variant err = f_curl_errno(c);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c.toObject());
Variant err = f_curl_errno(c.toObject());
VS(err, k_CURLE_COULDNT_RESOLVE_HOST);
return Count(true);
}
bool TestExtCurl::test_curl_error() {
Variant c = f_curl_init("http://www.thereisnosuchanurl");
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c);
Variant err = f_curl_error(c);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c.toObject());
Variant err = f_curl_error(c.toObject());
VERIFY(equal(err, String("Couldn't resolve host 'www.thereisnosuchanurl'")) ||
equal(err, String("Could not resolve host: www.thereisnosuchanurl"
" (Domain name not found)")));
@@ -221,9 +221,9 @@ bool TestExtCurl::test_curl_error() {
bool TestExtCurl::test_curl_close() {
Variant c = f_curl_init(String(get_request_uri()));
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c);
f_curl_close(c);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_exec(c.toObject());
f_curl_close(c.toObject());
return Count(true);
}
@@ -236,8 +236,8 @@ bool TestExtCurl::test_curl_multi_add_handle() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
return Count(true);
}
@@ -245,9 +245,9 @@ bool TestExtCurl::test_curl_multi_remove_handle() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_multi_remove_handle(mh, c1);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
f_curl_multi_remove_handle(mh, c1.toObject());
return Count(true);
}
@@ -255,10 +255,10 @@ bool TestExtCurl::test_curl_multi_exec() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_setopt(c1, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2, k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_setopt(c1.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
Variant still_running;
do {
@@ -272,8 +272,8 @@ bool TestExtCurl::test_curl_multi_select() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
VS(f_curl_multi_select(mh), 0);
return Count(true);
}
@@ -282,20 +282,20 @@ bool TestExtCurl::test_curl_multi_getcontent() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_setopt(c1, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2, k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_setopt(c1.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
Variant still_running;
do {
f_curl_multi_exec(mh, ref(still_running));
} while (more(still_running, 0));
VS(f_curl_multi_getcontent(c1), "OK");
VS(f_curl_multi_getcontent(c1), "OK");
VS(f_curl_multi_getcontent(c2), "OK");
VS(f_curl_multi_getcontent(c2), "OK");
VS(f_curl_multi_getcontent(c1.toObject()), "OK");
VS(f_curl_multi_getcontent(c1.toObject()), "OK");
VS(f_curl_multi_getcontent(c2.toObject()), "OK");
VS(f_curl_multi_getcontent(c2.toObject()), "OK");
return Count(true);
}
@@ -303,10 +303,10 @@ bool TestExtCurl::test_curl_multi_info_read() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_setopt(c1, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2, k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_setopt(c1.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
Variant still_running;
do {
@@ -322,10 +322,10 @@ bool TestExtCurl::test_curl_multi_close() {
Object mh = f_curl_multi_init();
Variant c1 = f_curl_init(String(get_request_uri()));
Variant c2 = f_curl_init(String(get_request_uri()));
f_curl_setopt(c1, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2, k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1);
f_curl_multi_add_handle(mh, c2);
f_curl_setopt(c1.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c2.toObject(), k_CURLOPT_RETURNTRANSFER, true);
f_curl_multi_add_handle(mh, c1.toObject());
f_curl_multi_add_handle(mh, c2.toObject());
Variant still_running;
do {
@@ -391,7 +391,7 @@ bool TestExtCurl::test_evhttp_post_gzip() {
bool TestExtCurl::test_evhttp_async_get() {
Variant ret = f_evhttp_async_get(String(get_request_uri()),
CREATE_VECTOR1("ECHO: foo"));
ret = f_evhttp_recv(ret);
ret = f_evhttp_recv(ret.toObject());
VS(ret[s_code], 200);
VS(ret[s_response], "OK");
VS(ret[s_headers][0], "ECHOED: foo");
@@ -402,7 +402,7 @@ bool TestExtCurl::test_evhttp_async_get() {
bool TestExtCurl::test_evhttp_async_post() {
Variant ret = f_evhttp_async_post(String(get_request_uri()), "echo",
CREATE_VECTOR1("ECHO: foo"));
ret = f_evhttp_recv(ret);
ret = f_evhttp_recv(ret.toObject());
VS(ret[s_code], 200);
VS(ret[s_response], "POST: echo");
VS(ret[s_headers][0], "ECHOED: foo");
+3 -2
Ver Arquivo
@@ -133,8 +133,9 @@ bool TestExtMemcached::test_Memcached_types() {
bool TestExtMemcached::test_Memcached_cas() {
CREATE_MEMCACHED();
for (ArrayIter iter(memc_version); iter; ++iter) {
if (!f_version_compare(iter.second().toString(), "1.3.0", ">=")) {
for (ArrayIter iter(memc_version.toArray()); iter; ++iter) {
if (!f_version_compare(iter.second().toString(), "1.3.0", ">=")
.toBoolean()) {
SKIP("Need memcached 1.3.0 for CAS");
return Count(true);
}
+3 -3
Ver Arquivo
@@ -93,7 +93,7 @@ static bool CreateTestTable() {
f_mysql_query("drop table test");
return f_mysql_query("create table test (id int not null auto_increment,"
" name varchar(255) not null, primary key (id)) "
"engine=innodb");
"engine=innodb").toBoolean();
}
///////////////////////////////////////////////////////////////////////////////
@@ -157,14 +157,14 @@ bool TestExtMysql::test_mysql_close() {
bool TestExtMysql::test_mysql_errno() {
Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD);
VERIFY(!f_mysql_select_db("nonexistentdb"));
VERIFY(!f_mysql_select_db("nonexistentdb").toBoolean());
VS(f_mysql_errno(conn), 1049);
return Count(true);
}
bool TestExtMysql::test_mysql_error() {
Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD);
VERIFY(!f_mysql_select_db("nonexistentdb"));
VERIFY(!f_mysql_select_db("nonexistentdb").toBoolean());
VS(f_mysql_error(conn), "Unknown database 'nonexistentdb'");
return Count(true);
}
+7 -5
Ver Arquivo
@@ -57,11 +57,11 @@ bool TestLogger::initializeRun() {
Array response = postData(CREATE_MAP1("runData", dataArr));
if (!response[s_result]) {
if (!response[s_result].toBoolean()) {
return false;
}
run_id = response[s_result][s_runId];
run_id = response[s_result][s_runId].toInt32();
return true;
}
@@ -76,8 +76,9 @@ bool TestLogger::finishRun() {
"runData", CREATE_MAP1("stillRunning", false));
Array response = postData(data);
if (response[s_result])
if (response[s_result].toBoolean()) {
return true;
}
return false;
}
@@ -92,8 +93,9 @@ bool TestLogger::logTest(Array test) {
"tests", CREATE_VECTOR1(test));
Array response = postData(data);
if (response[s_result])
if (response[s_result].toBoolean()) {
return true;
}
return false;
}
@@ -112,7 +114,7 @@ Array TestLogger::postData(Array arr) {
client.post(log_url, str.c_str(), str.length(), response);
return f_json_decode(response.detach(), true);
return f_json_decode(response.detach(), true).toArray();
}
std::string TestLogger::getRepoRoot() {
+10 -10
Ver Arquivo
@@ -86,20 +86,20 @@ bool TestServer::VerifyServerResponse(const char *input, const char **outputs,
string err;
for (int i = 0; i < 10; i++) {
Variant c = f_curl_init();
f_curl_setopt(c, k_CURLOPT_URL, server);
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, server);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
if (postdata) {
f_curl_setopt(c, k_CURLOPT_POSTFIELDS, postdata);
f_curl_setopt(c, k_CURLOPT_POST, true);
f_curl_setopt(c.toObject(), k_CURLOPT_POSTFIELDS, postdata);
f_curl_setopt(c.toObject(), k_CURLOPT_POST, true);
}
if (header) {
f_curl_setopt(c, k_CURLOPT_HTTPHEADER, CREATE_VECTOR1(header));
f_curl_setopt(c.toObject(), k_CURLOPT_HTTPHEADER, CREATE_VECTOR1(header));
}
if (responseHeader) {
f_curl_setopt(c, k_CURLOPT_HEADER, 1);
f_curl_setopt(c.toObject(), k_CURLOPT_HEADER, 1);
}
Variant res = f_curl_exec(c);
Variant res = f_curl_exec(c.toObject());
if (!same(res, false)) {
actual = (std::string) res.toString();
break;
@@ -166,9 +166,9 @@ void TestServer::StopServer() {
String url = "http://";
url += f_php_uname("n");
url += ":" + lexical_cast<string>(s_admin_port) + "/stop";
f_curl_setopt(c, k_CURLOPT_URL, url);
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c);
f_curl_setopt(c.toObject(), k_CURLOPT_URL, url);
f_curl_setopt(c.toObject(), k_CURLOPT_RETURNTRANSFER, true);
Variant res = f_curl_exec(c.toObject());
if (!same(res, false)) {
break;
}
+8 -1
Ver Arquivo
@@ -390,7 +390,14 @@ void emitExtCall(const PhpFunc& func, std::ostream& out, const char* ind) {
if (kindof != KindOfAny ||
(defVal != "null" && defVal != "null_variant")) {
out << " = ";
out << (defVal == "null" ? "uninit_null()" : defVal);
std::string nullToType =
kindof == KindOfArray ? ".toArray()" :
kindof == KindOfString ? ".toString()" :
kindof == KindOfObject ? ".toObject()" :
kindof == KindOfRef ? "" :
"icantconvertthisfromnull";
if (defVal == "null_variant") defVal += nullToType;
out << (defVal == "null" ? "uninit_null()" + nullToType : defVal);
}
out << ";\n";
}