Get rid of some hphpiCompat brokenness

These were strictly to avoid people writing code that
worked under hhvm, but then fataled under hphpi. Since hphpi is
long gone, its time we removed it (no danger of breaking real code
since anything that worked before continues to work - and hphp
was already "doing the right thing" because it flattened traits).
Esse commit está contido em:
Mark Williams
2013-04-22 09:38:57 -07:00
commit de Sara Golemon
commit b8c78a9141
6 arquivos alterados com 12 adições e 39 exclusões
-24
Ver Arquivo
@@ -210,16 +210,6 @@ void TypeConstraint::verifyFail(const Func* func, int paramNum,
}
void TypeConstraint::selfToClass(const Func* func, const Class **cls) const {
if (hphpiCompat) {
// hphpi: a typehint self in a trait's method in the class using a trait
// represents the trait rather than the using class.
const PreClass* pc = func->preClass();
if (pc && !(pc->attrs() & AttrTrait)) {
*cls = func->cls();
}
return;
}
// PHP 5.4: typehint self in a method in a trait is the class using the trait
const Class* c = func->cls();
if (c) {
*cls = c;
@@ -228,16 +218,6 @@ void TypeConstraint::selfToClass(const Func* func, const Class **cls) const {
void TypeConstraint::selfToTypeName(const Func* func,
const StringData **typeName) const {
if (hphpiCompat) {
// hphpi: a typehint self in a trait's method in the class using a trait
// represents the trait rather than the using class.
const PreClass* pc = func->preClass();
if (pc) {
*typeName = pc->name();
}
return;
}
// PHP 5.4: typehint self in a trait's method is the class using the trait
const Class* c = func->cls();
if (c) {
*typeName = c->name();
@@ -245,10 +225,6 @@ void TypeConstraint::selfToTypeName(const Func* func,
}
void TypeConstraint::parentToClass(const Func* func, const Class **cls) const {
if (hphpiCompat) {
return;
}
// Match 5.4 for methods defined in classes and traits
Class* c1 = func->cls();
const Class* c2 = c1 ? c1->parent() : nullptr;
if (c2) {
+3 -11
Ver Arquivo
@@ -96,17 +96,9 @@ public:
}
bool compat(const TypeConstraint& other) const {
if (!hphpiCompat) {
// php 5.4.0RC6 allows 'int' compatible to Int but not integer
return (m_typeName == other.m_typeName
|| (m_typeName != nullptr && other.m_typeName != nullptr
&& m_typeName->isame(other.m_typeName)));
} else {
// For now, be compatible with hphpi: int $x != Int $x
return (m_typeName == other.m_typeName
|| (m_typeName != nullptr && other.m_typeName != nullptr
&& m_typeName->same(other.m_typeName)));
}
return (m_typeName == other.m_typeName
|| (m_typeName != nullptr && other.m_typeName != nullptr
&& m_typeName->isame(other.m_typeName)));
}
inline static bool equivDataTypes(DataType t1, DataType t2) {
+1 -1
Ver Arquivo
@@ -1,4 +1,4 @@
<?php
abstract class A { abstract public function b(bool $b1 = null); }
class B extends A { public function b(Bool $b1 = null) {} }
class B extends A { public function b(Boolean $b1 = null) {} }
+1 -1
Ver Arquivo
@@ -1,4 +1,4 @@
<?php
abstract class A { abstract public function a(int $a1 = null); }
class B extends A { public function a(Int $a1 = null) {} }
class B extends A { public function a(Integer $a1 = null) {} }
+5 -1
Ver Arquivo
@@ -1,2 +1,6 @@
A accepts param from subclass A
HipHop Fatal error: Argument 1 passed to B::bar() must be an instance of parent, A given in %s on line 19
B accepts param from subclass A
A accepts param from subclass B
C accepts param from subclass B
A accepts param from subclass C
HipHop Fatal error: Argument 1 passed to %s::bar() must be an instance of D, C given in %s on line 4
+2 -1
Ver Arquivo
@@ -1,4 +1,5 @@
A accepts param from subclass C
B accepts param from subclass C
A accepts param from subclass C
HipHop Fatal error: Argument 1 passed to T::bar() must be an instance of T, C given in %s on line 4
C accepts param from subclass C
HipHop Fatal error: Argument 1 passed to D::test() must be an instance of D, C given in %s on line 26