Fix reflection for default values that were optimized
If a default value is optimized from a class constant, to the value of the class constant, then reflection needs to be able to get the text of the original class constant. Fortunately hphp tags that onto the replacement expression for just this reason. Lets use it in the emitter.
Esse commit está contido em:
@@ -5241,10 +5241,17 @@ void EmitterVisitor::emitPostponedMeths() {
|
||||
initScalar(dv, vNode);
|
||||
pi.setDefaultValue(dv);
|
||||
|
||||
// Simple case: it's a scalar value so we just serialize it
|
||||
VariableSerializer vs(VariableSerializer::PHPOutput);
|
||||
String result = vs.serialize(tvAsCVarRef(&dv), true);
|
||||
phpCode = StringData::GetStaticString(result.data());
|
||||
std::string orig = vNode->getComment();
|
||||
if (orig.empty()) {
|
||||
// Simple case: it's a scalar value so we just serialize it
|
||||
VariableSerializer vs(VariableSerializer::PHPOutput);
|
||||
String result = vs.serialize(tvAsCVarRef(&dv), true);
|
||||
phpCode = StringData::GetStaticString(result.get());
|
||||
} else {
|
||||
// This was optimized from a Constant, or ClassConstant
|
||||
// use the original string
|
||||
phpCode = StringData::GetStaticString(orig);
|
||||
}
|
||||
} else {
|
||||
// Non-scalar, so we have to output PHP from the AST node
|
||||
std::ostringstream os;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void pushConst(const std::string &name);
|
||||
void popConst();
|
||||
void setComment(const std::string &comment) { m_comment = comment;}
|
||||
const std::string getComment() { return m_comment;}
|
||||
std::string getComment() { return m_comment;}
|
||||
bool isValid() const { return m_valid; }
|
||||
bool isDynamic() const { return m_dynamic; }
|
||||
private:
|
||||
|
||||
@@ -172,6 +172,7 @@ public:
|
||||
}
|
||||
bool hasSubExpr(ExpressionPtr sub) const;
|
||||
virtual void setComment(const std::string &) {}
|
||||
virtual std::string getComment() { return ""; }
|
||||
/**
|
||||
* Set this expression's error flags.
|
||||
*/
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
int64_t getHash() const;
|
||||
|
||||
void setComment(const std::string &comment) { m_comment = comment;}
|
||||
const std::string getComment() { return m_comment;}
|
||||
std::string getComment() { return m_comment;}
|
||||
|
||||
|
||||
bool getString(const std::string *&s) const;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário