rename IgnoreRedefinition to AllowOverride
IgnoreRedefinition does not do what it says it does (as the userland definition is selected) so renaming it
Esse commit está contido em:
@@ -5135,6 +5135,51 @@ class ReflectionClass implements Reflector {
|
||||
public function getAttributesRecursive() {
|
||||
return $this->fetch('attributes_rec');
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://www.php.net/manual/en/reflectionclass.innamespace.php )
|
||||
*
|
||||
* Checks if in namespace
|
||||
*
|
||||
* @return bool Returns TRUE on success or FALSE on failure.
|
||||
*/
|
||||
public function inNamespace() {
|
||||
return strrpos($this->getName(), '\\') !== false;
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://php.net/manual/en/reflectionclass.getnamespacename.php )
|
||||
*
|
||||
* Gets namespace name
|
||||
*
|
||||
* @return string The namespace name.
|
||||
*/
|
||||
public function getNamespaceName() {
|
||||
$pos = strrpos($this->getName(), '\\');
|
||||
if ($pos === false) {
|
||||
return '';
|
||||
}
|
||||
return substr($this->getName(), 0, $pos);
|
||||
}
|
||||
|
||||
// Do NOT modifiy this doc comment block generated by idl/sysdoc.php
|
||||
/**
|
||||
* ( excerpt from http://www.php.net/manual/en/reflectionclass.getshortname.php )
|
||||
*
|
||||
* Gets short name
|
||||
*
|
||||
* @return string The class short name.
|
||||
*/
|
||||
public function getShortName() {
|
||||
$pos = strrpos($this->getName(), '\\');
|
||||
if ($pos === false) {
|
||||
return $this->getName();
|
||||
}
|
||||
return substr($this->getName(), $pos + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/compiler/analysis/analysis_result.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include "hphp/compiler/analysis/analysis_result.h"
|
||||
#include "hphp/compiler/analysis/alias_manager.h"
|
||||
#include "hphp/compiler/analysis/file_scope.h"
|
||||
#include "hphp/compiler/analysis/class_scope.h"
|
||||
@@ -169,7 +170,7 @@ FunctionScopePtr AnalysisResult::findFunction(
|
||||
const std::string &funcName) const {
|
||||
StringToFunctionScopePtrMap::const_iterator bit =
|
||||
m_functions.find(funcName);
|
||||
if (bit != m_functions.end() && !bit->second->ignoreRedefinition()) {
|
||||
if (bit != m_functions.end() && !bit->second->allowOverride()) {
|
||||
return bit->second;
|
||||
}
|
||||
StringToFunctionScopePtrMap::const_iterator iter =
|
||||
@@ -345,7 +346,7 @@ bool AnalysisResult::declareFunction(FunctionScopePtr funcScope) const {
|
||||
// System functions override
|
||||
auto it = m_functions.find(fname);
|
||||
if (it != m_functions.end()) {
|
||||
if (!it->second->ignoreRedefinition()) {
|
||||
if (!it->second->allowOverride()) {
|
||||
// we need someone to hold on to a reference to it
|
||||
// even though we're not going to do anything with it
|
||||
this->lock()->m_ignoredScopes.push_back(funcScope);
|
||||
|
||||
@@ -5873,7 +5873,7 @@ bool EmitterVisitor::canEmitBuiltinCall(FunctionCallPtr fn,
|
||||
return false;
|
||||
}
|
||||
// in sandbox mode, don't emit FCallBuiltin for redefinable functions
|
||||
if (func->ignoreRedefinition() && !Option::WholeProgram) {
|
||||
if (func->allowOverride() && !Option::WholeProgram) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
MixedVariableArgument = 0x800, // variable args, may or may not be ref'd
|
||||
IsFoldable = 0x1000,// function can be constant folded
|
||||
NeedsActRec = 0x2000,// builtin function needs ActRec
|
||||
IgnoreRedefinition = 0x4000,// ignore redefinition of builtin function
|
||||
AllowOverride = 0x4000,// allow override of systemlib or builtin
|
||||
};
|
||||
|
||||
typedef boost::adjacency_list<boost::setS, boost::vecS> Graph;
|
||||
|
||||
@@ -302,8 +302,8 @@ bool FunctionScope::isVariableArgument() const {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool FunctionScope::ignoreRedefinition() const {
|
||||
return m_attribute & FileScope::IgnoreRedefinition;
|
||||
bool FunctionScope::allowOverride() const {
|
||||
return m_attribute & FileScope::AllowOverride;
|
||||
}
|
||||
|
||||
bool FunctionScope::isReferenceVariableArgument() const {
|
||||
@@ -378,8 +378,8 @@ void FunctionScope::setVariableArgument(int reference) {
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionScope::setIgnoreRedefinition() {
|
||||
m_attribute |= FileScope::IgnoreRedefinition;
|
||||
void FunctionScope::setAllowOverride() {
|
||||
m_attribute |= FileScope::AllowOverride;
|
||||
}
|
||||
|
||||
bool FunctionScope::hasEffect() const {
|
||||
|
||||
@@ -222,10 +222,10 @@ public:
|
||||
void setNeedsActRec();
|
||||
|
||||
/*
|
||||
* If this is a builtin and can be redefined
|
||||
* If this is a builtin (C++ or PHP) and can be redefined
|
||||
*/
|
||||
bool ignoreRedefinition() const;
|
||||
void setIgnoreRedefinition();
|
||||
bool allowOverride() const;
|
||||
void setAllowOverride();
|
||||
|
||||
/**
|
||||
* Whether this function is a runtime helper function
|
||||
|
||||
@@ -203,8 +203,8 @@ FunctionScopePtr BuiltinSymbols::ImportFunctionScopePtr(AnalysisResultPtr ar,
|
||||
if (attrs & ClassInfo::NeedsActRec) {
|
||||
f->setNeedsActRec();
|
||||
}
|
||||
if ((attrs & ClassInfo::IgnoreRedefinition) && !isMethod) {
|
||||
f->setIgnoreRedefinition();
|
||||
if ((attrs & ClassInfo::AllowOverride) && !isMethod) {
|
||||
f->setAllowOverride();
|
||||
}
|
||||
|
||||
FunctionScope::RecordFunctionInfo(f->getName(), f);
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ define('IsFinal', 1 << 5);
|
||||
define('IsPublic', 1 << 6);
|
||||
define('IsProtected', 1 << 7);
|
||||
define('IsPrivate', 1 << 8);
|
||||
define('IgnoreRedefinition', 1 << 8);
|
||||
define('AllowOverride', 1 << 8);
|
||||
define('IsStatic', 1 << 9);
|
||||
// FIXME (#2163116): IsInherited = (1 << 10) in base_class.h
|
||||
define('IsCppAbstract', 1 << 10);
|
||||
@@ -162,7 +162,7 @@ function get_flag_names($arr, $name, $global_func) {
|
||||
if ($flag & IsPublic ) $ret .= ' | IsPublic' ;
|
||||
if ($flag & IsProtected ) $ret .= ' | IsProtected' ;
|
||||
if ($global_func) {
|
||||
if ($flag & IgnoreRedefinition ) $ret .= ' | IgnoreRedefinition' ;
|
||||
if ($flag & AllowOverride ) $ret .= ' | AllowOverride' ;
|
||||
} else {
|
||||
if ($flag & IsPrivate ) $ret .= ' | IsPrivate' ;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
IsInherited = (1 << 10), // x
|
||||
HasCall = IsPublic, // x
|
||||
HasCallStatic = IsProtected,// x
|
||||
IgnoreRedefinition = IsPrivate, // x
|
||||
AllowOverride = IsPrivate, // x
|
||||
IsReference = (1 << 11), // x x x
|
||||
IsConstructor = (1 << 12), // x
|
||||
|
||||
|
||||
@@ -654,6 +654,11 @@ void Func::setCached() {
|
||||
setCachedFunc(this, isDebuggerAttached());
|
||||
}
|
||||
|
||||
bool Func::isAllowOverride() const {
|
||||
return shared()->m_info &&
|
||||
(shared()->m_info->attribute & ClassInfo::AllowOverride);
|
||||
}
|
||||
|
||||
const Func* Func::getGeneratorBody(const StringData* name) const {
|
||||
if (isNonClosureMethod()) {
|
||||
return cls()->lookupMethod(name);
|
||||
|
||||
@@ -347,10 +347,7 @@ struct Func {
|
||||
bool hasStaticLocals() const { return !shared()->m_staticVars.empty(); }
|
||||
int numStaticLocals() const { return shared()->m_staticVars.size(); }
|
||||
const ClassInfo::MethodInfo* info() const { return shared()->m_info; }
|
||||
bool isIgnoreRedefinition() const {
|
||||
return shared()->m_info &&
|
||||
(shared()->m_info->attribute & ClassInfo::IgnoreRedefinition);
|
||||
}
|
||||
bool isAllowOverride() const;
|
||||
const BuiltinFunction& nativeFuncPtr() const {
|
||||
return shared()->m_nativeFuncPtr;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ inline ALWAYS_INLINE void setCachedFunc(Func* func, bool debugger) {
|
||||
Func** funcAddr = getCachedFuncAddr(func->getCachedOffset());
|
||||
if (UNLIKELY(*funcAddr != nullptr)) {
|
||||
if (*funcAddr == func) return;
|
||||
if (!(*funcAddr)->isIgnoreRedefinition()) {
|
||||
if (!(*funcAddr)->isAllowOverride()) {
|
||||
raise_error(Strings::FUNCTION_ALREADY_DEFINED, func->name()->data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/runtime/vm/funcdict.h"
|
||||
|
||||
#include "hphp/runtime/base/runtime_option.h"
|
||||
#include "hphp/util/base.h"
|
||||
|
||||
#include "hphp/runtime/base/execution_context.h"
|
||||
#include "hphp/runtime/ext_hhvm/ext_hhvm.h"
|
||||
#include "hphp/runtime/vm/funcdict.h"
|
||||
#include "hphp/runtime/vm/translator/translator.h"
|
||||
#include "hphp/runtime/vm/translator/targetcache.h"
|
||||
#include "hphp/runtime/vm/unit.h"
|
||||
@@ -57,7 +58,7 @@ bool RenamedFuncDict::rename(const StringData* old, const StringData* n3w) {
|
||||
if (fnew && fnew != func) {
|
||||
// To match hphpc, we silently ignore functions defined in user code that
|
||||
// have the same name as a function defined in a separable extension
|
||||
if (!fnew->isIgnoreRedefinition()) {
|
||||
if (!fnew->isAllowOverride()) {
|
||||
raise_error("Function already defined: %s", n3w->data());
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário