Implement Set
Esse commit está contido em:
+5
-10
@@ -2280,8 +2280,7 @@ class MappedIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method MappedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return ($this->fn)($this->it->current());
|
||||
@@ -2377,8 +2376,7 @@ class FilteredIterator implements Iterator {
|
||||
}
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method FilteredIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return $this->it->current();
|
||||
@@ -2477,8 +2475,7 @@ class ZippedIterator implements Iterator {
|
||||
$this->it2->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method ZippedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return Pair {$this->it1->current(), $this->it2->current()};
|
||||
@@ -2567,8 +2564,7 @@ class KeysIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method KeysIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return $this->it->key();
|
||||
@@ -2607,8 +2603,7 @@ class KVZippedIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method KVZippedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return Pair {$this->it->key(), $this->it->current()};
|
||||
|
||||
@@ -2894,6 +2894,8 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
|
||||
cType = Collection::MapType;
|
||||
} else if (!strcasecmp(clsName->c_str(), "stablemap")) {
|
||||
cType = Collection::StableMapType;
|
||||
} else if (!strcasecmp(clsName->c_str(), "set")) {
|
||||
cType = Collection::SetType;
|
||||
} else if (!strcasecmp(clsName->c_str(), "pair")) {
|
||||
cType = Collection::PairType;
|
||||
if (nElms != 2) {
|
||||
@@ -2930,7 +2932,8 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
|
||||
ExpressionPtr key = ap->getName();
|
||||
if ((bool)key) {
|
||||
throw IncludeTimeFatalException(ap,
|
||||
"Keys may not be specified for Vector initialization");
|
||||
"Keys may not be specified for Vector, Set, or Pair "
|
||||
"initialization");
|
||||
}
|
||||
visit(ap->getValue());
|
||||
emitConvertToCell(e);
|
||||
|
||||
@@ -71,6 +71,8 @@ BinaryOpExpression::BinaryOpExpression
|
||||
cType = Collection::MapType;
|
||||
} else if (strcasecmp(s.c_str(), "stablemap") == 0) {
|
||||
cType = Collection::StableMapType;
|
||||
} else if (strcasecmp(s.c_str(), "set") == 0) {
|
||||
cType = Collection::SetType;
|
||||
} else if (strcasecmp(s.c_str(), "pair") == 0) {
|
||||
cType = Collection::PairType;
|
||||
}
|
||||
|
||||
@@ -2112,6 +2112,516 @@
|
||||
"consts": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Set",
|
||||
"ifaces": [
|
||||
"MutableSet"
|
||||
],
|
||||
"desc": "An unordered set-style collection.",
|
||||
"flags": [
|
||||
"IsFinal",
|
||||
"HasDocComment"
|
||||
],
|
||||
"funcs": [
|
||||
{
|
||||
"name": "__construct",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Set built from the values produced by the specified Iterable.",
|
||||
"return": {
|
||||
"type": null
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant",
|
||||
"value": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "isEmpty",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns true if the Set is empty, false otherwise.",
|
||||
"return": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns the number of values in the Set.",
|
||||
"return": {
|
||||
"type": "Int64"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "items",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns an Iterable that produces the values from this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "view",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a lazy iterable view of this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "clear",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Removes all values from the Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "contains",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns true if the specified value is present in the Set, returns false otherwise.",
|
||||
"return": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "val",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "remove",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Removes the specified value from this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "val",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "discard",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Removes the specified value from this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "val",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "add",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Adds the specified value to this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "val",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "addAll",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Adds the values produced by the specified Iterable to this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "toArray",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns an array built from the values from this Set.",
|
||||
"return": {
|
||||
"type": "VariantMap"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "getIterator",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns an iterator that points to beginning of this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "map",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns an Iterable of the values produced by applying the specified callback on the values of this Set.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "filter",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Iterable of all the values from this Set for which the specified callback returns true.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "zip",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Iterable produced by combined the specified Iterables pair-wise.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "difference",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "updateFromArrayValues",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "arr",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "updateFromIterableValues",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "__toString",
|
||||
"return": {
|
||||
"type": "String"
|
||||
},
|
||||
"flags": [
|
||||
],
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "__get",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Variant"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "__set",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Variant"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "Variant"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "__isset",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "__unset",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Variant"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fromItems",
|
||||
"flags": [
|
||||
"IsStatic",
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Set built from the values produced by the specified Iterable.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fromArray",
|
||||
"flags": [
|
||||
"IsStatic",
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Set built from the values from the specified array.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "arr",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fromArrays",
|
||||
"flags": [
|
||||
"IsStatic",
|
||||
"VariableArguments",
|
||||
"HasDocComment"
|
||||
],
|
||||
"desc": "Returns a Set built from the values from the specified arrays.",
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fromIterableValues",
|
||||
"flags": [
|
||||
"IsStatic",
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Object"
|
||||
},
|
||||
"args": [
|
||||
{
|
||||
"name": "iterable",
|
||||
"type": "Variant"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"consts": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SetIterator",
|
||||
"ifaces": [
|
||||
"Iterator"
|
||||
],
|
||||
"desc": "An iterator implementation for iterating over a Set.",
|
||||
"flags": [
|
||||
"IsFinal",
|
||||
"HasDocComment"
|
||||
],
|
||||
"funcs": [
|
||||
{
|
||||
"name": "__construct",
|
||||
"return": {
|
||||
"type": null
|
||||
},
|
||||
"flags": [
|
||||
],
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "current",
|
||||
"desc": "Returns the current value that the iterator points to.",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Variant"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "key",
|
||||
"flags": [
|
||||
],
|
||||
"return": {
|
||||
"type": "Variant"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "valid",
|
||||
"desc": "Returns true if the iterator points to a valid value, returns false otherwise.",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": "Boolean"
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "next",
|
||||
"desc": "Advance this iterator forward one position.",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": null
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "rewind",
|
||||
"desc": "Move this iterator back to the first position.",
|
||||
"flags": [
|
||||
"HasDocComment"
|
||||
],
|
||||
"return": {
|
||||
"type": null
|
||||
},
|
||||
"args": [
|
||||
]
|
||||
}
|
||||
],
|
||||
"consts": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Pair",
|
||||
"ifaces": [
|
||||
@@ -2416,4 +2926,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,12 @@ void ArrayIter::objInit(ObjectData *obj) {
|
||||
m_pos = smp->iter_begin();
|
||||
break;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
c_Set* st = getSet();
|
||||
m_version = st->getVersion();
|
||||
m_pos = st->iter_begin();
|
||||
break;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
m_pos = 0;
|
||||
break;
|
||||
@@ -157,6 +163,9 @@ bool ArrayIter::endHelper() {
|
||||
case Collection::StableMapType: {
|
||||
return m_pos == 0;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
return m_pos == 0;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
return m_pos >= getPair()->t_count();
|
||||
}
|
||||
@@ -191,6 +200,15 @@ void ArrayIter::nextHelper() {
|
||||
m_pos = smp->iter_next(m_pos);
|
||||
return;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
assert(m_pos != 0);
|
||||
c_Set* st = getSet();
|
||||
if (UNLIKELY(m_version != st->getVersion())) {
|
||||
throw_collection_modified();
|
||||
}
|
||||
m_pos = st->iter_next(m_pos);
|
||||
return;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
m_pos++;
|
||||
return;
|
||||
@@ -222,6 +240,9 @@ Variant ArrayIter::firstHelper() {
|
||||
}
|
||||
return smp->iter_key(m_pos);
|
||||
}
|
||||
case Collection::SetType: {
|
||||
return uninit_null();
|
||||
}
|
||||
case Collection::PairType: {
|
||||
return m_pos;
|
||||
}
|
||||
@@ -262,6 +283,13 @@ Variant ArrayIter::second() {
|
||||
}
|
||||
return smp->iter_value(m_pos);
|
||||
}
|
||||
case Collection::SetType: {
|
||||
c_Set* st = getSet();
|
||||
if (UNLIKELY(m_version != st->getVersion())) {
|
||||
throw_collection_modified();
|
||||
}
|
||||
return st->iter_value(m_pos);
|
||||
}
|
||||
case Collection::PairType: {
|
||||
return tvAsCVarRef(getPair()->at(m_pos));
|
||||
}
|
||||
@@ -298,6 +326,14 @@ void ArrayIter::secondHelper(Variant& v) {
|
||||
v = smp->iter_value(m_pos);
|
||||
break;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
c_Set* st = getSet();
|
||||
if (UNLIKELY(m_version != st->getVersion())) {
|
||||
throw_collection_modified();
|
||||
}
|
||||
v = st->iter_value(m_pos);
|
||||
break;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
v = tvAsCVarRef(getPair()->at(m_pos));
|
||||
break;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct TypedValue;
|
||||
class c_Vector;
|
||||
class c_Map;
|
||||
class c_StableMap;
|
||||
class c_Set;
|
||||
class c_Pair;
|
||||
struct Iter;
|
||||
|
||||
@@ -192,6 +193,10 @@ class ArrayIter {
|
||||
assert(hasCollection() && getCollectionType() == Collection::StableMapType);
|
||||
return (c_StableMap*)((intptr_t)m_obj & ~1);
|
||||
}
|
||||
c_Set* getSet() {
|
||||
assert(hasCollection() && getCollectionType() == Collection::SetType);
|
||||
return (c_Set*)((intptr_t)m_obj & ~1);
|
||||
}
|
||||
c_Pair* getPair() {
|
||||
assert(hasCollection() && getCollectionType() == Collection::PairType);
|
||||
return (c_Pair*)((intptr_t)m_obj & ~1);
|
||||
|
||||
@@ -68,6 +68,7 @@ class ObjectData : public CountableNF {
|
||||
VectorAttrInit = (Collection::VectorType << 13),
|
||||
MapAttrInit = (Collection::MapType << 13),
|
||||
StableMapAttrInit = (Collection::StableMapType << 13),
|
||||
SetAttrInit = (Collection::SetType << 13),
|
||||
PairAttrInit = (Collection::PairType << 13),
|
||||
};
|
||||
|
||||
|
||||
@@ -321,8 +321,9 @@ enum Type {
|
||||
VectorType = 1,
|
||||
MapType = 2,
|
||||
StableMapType = 3,
|
||||
PairType = 4,
|
||||
MaxNumTypes = 5
|
||||
SetType = 4,
|
||||
PairType = 5,
|
||||
MaxNumTypes = 6
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -708,7 +708,6 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
m_buf->append("]=>\n");
|
||||
break;
|
||||
case APCSerialize:
|
||||
assert(!info.is_object);
|
||||
case Serialize:
|
||||
case DebuggerSerialize:
|
||||
write(key);
|
||||
@@ -758,6 +757,36 @@ void VariableSerializer::writeCollectionKey(CVarRef key) {
|
||||
writeArrayKey(key);
|
||||
}
|
||||
|
||||
void VariableSerializer::writeCollectionKeylessPrefix() {
|
||||
ArrayInfo &info = m_arrayInfos.back();
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
indent();
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case APCSerialize:
|
||||
case Serialize:
|
||||
case DebuggerSerialize:
|
||||
break;
|
||||
case JSON:
|
||||
case DebuggerDump:
|
||||
if (!info.first_element) {
|
||||
m_buf->append(',');
|
||||
}
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_buf->append("\n");
|
||||
indent();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VariableSerializer::writeArrayValue(CVarRef value) {
|
||||
// Do not count referenced values after the first
|
||||
if ((m_type == Serialize || m_type == APCSerialize ||
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
/**
|
||||
* Constructor and destructor.
|
||||
*/
|
||||
VariableSerializer(Type type, int option = 0, int maxRecur = 3);
|
||||
explicit VariableSerializer(Type type, int option = 0, int maxRecur = 3);
|
||||
~VariableSerializer() {
|
||||
if (m_arrayIds) delete m_arrayIds;
|
||||
}
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
void writeArrayKey(Variant key);
|
||||
void writeArrayValue(CVarRef value);
|
||||
void writeCollectionKey(CVarRef key);
|
||||
void writeCollectionKeylessPrefix();
|
||||
void writeArrayFooter();
|
||||
void writeSerializableObject(CStrRef clsname, CStrRef serialized);
|
||||
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -3785,6 +3785,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopNewCol(PC& pc) {
|
||||
case Collection::VectorType: obj = NEWOBJ(c_Vector)(); break;
|
||||
case Collection::MapType: obj = NEWOBJ(c_Map)(); break;
|
||||
case Collection::StableMapType: obj = NEWOBJ(c_StableMap)(); break;
|
||||
case Collection::SetType: obj = NEWOBJ(c_Set)(); break;
|
||||
case Collection::PairType: obj = NEWOBJ(c_Pair)(); break;
|
||||
default:
|
||||
obj = nullptr;
|
||||
|
||||
@@ -97,6 +97,7 @@ ArrayData* new_tuple(int n, const TypedValue* values) {
|
||||
NEW_COLLECTION_HELPER(Vector)
|
||||
NEW_COLLECTION_HELPER(Map)
|
||||
NEW_COLLECTION_HELPER(StableMap)
|
||||
NEW_COLLECTION_HELPER(Set)
|
||||
|
||||
ObjectData* newPairHelper() {
|
||||
ObjectData *obj = NEWOBJ(c_Pair)();
|
||||
@@ -428,6 +429,11 @@ void collection_setm_ik1_v0(ObjectData* obj, int64_t key, TypedValue* value) {
|
||||
smp->set(key, value);
|
||||
break;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
Object e(SystemLib::AllocRuntimeExceptionObject(
|
||||
"Set does not support $c[$k] syntax"));
|
||||
throw e;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
Object e(SystemLib::AllocRuntimeExceptionObject(
|
||||
"Cannot assign to an element of a Pair"));
|
||||
@@ -457,6 +463,11 @@ void collection_setm_sk1_v0(ObjectData* obj, StringData* key,
|
||||
smp->set(key, value);
|
||||
break;
|
||||
}
|
||||
case Collection::SetType: {
|
||||
Object e(SystemLib::AllocRuntimeExceptionObject(
|
||||
"Set does not support $c[$k] syntax"));
|
||||
throw e;
|
||||
}
|
||||
case Collection::PairType: {
|
||||
Object e(SystemLib::AllocRuntimeExceptionObject(
|
||||
"Cannot assign to an element of a Pair"));
|
||||
|
||||
@@ -33,6 +33,7 @@ ArrayData* new_tuple(int numArgs, const TypedValue* args);
|
||||
ObjectData* newVectorHelper(int nElms);
|
||||
ObjectData* newMapHelper(int nElms);
|
||||
ObjectData* newStableMapHelper(int nElms);
|
||||
ObjectData* newSetHelper(int nElms);
|
||||
ObjectData* newPairHelper();
|
||||
|
||||
StringData* concat_is(int64_t v1, StringData* v2);
|
||||
|
||||
@@ -5274,6 +5274,7 @@ TranslatorX64::translateNewCol(const Tracelet& t,
|
||||
case Collection::VectorType: fptr = (void*)newVectorHelper; break;
|
||||
case Collection::MapType: fptr = (void*)newMapHelper; break;
|
||||
case Collection::StableMapType: fptr = (void*)newStableMapHelper; break;
|
||||
case Collection::SetType: fptr = (void*)newSetHelper; break;
|
||||
case Collection::PairType: fptr = (void*)newPairHelper; break;
|
||||
default: assert(false); break;
|
||||
}
|
||||
@@ -5281,7 +5282,8 @@ TranslatorX64::translateNewCol(const Tracelet& t,
|
||||
ObjectData* obj1 UNUSED = newVectorHelper(42);
|
||||
ObjectData* obj2 UNUSED = newMapHelper(42);
|
||||
ObjectData* obj3 UNUSED = newStableMapHelper(42);
|
||||
ObjectData* obj4 UNUSED = newPairHelper();
|
||||
ObjectData* obj4 UNUSED = newSetHelper(42);
|
||||
ObjectData* obj5 UNUSED = newPairHelper();
|
||||
}
|
||||
if (cType == Collection::PairType) {
|
||||
// newPairHelper does not take any arguments, since Pairs always
|
||||
|
||||
@@ -20749,6 +20749,210 @@ const char *g_class_map[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006020, "Set", "", "", (const char *)0, (const char *)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/class.set.php )\n *\n * An unordered set-style collection.\n *\n */",
|
||||
"mutableset", NULL,
|
||||
(const char *)0x10006040, "__construct", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.construct.php )\n *\n * Returns a Set built from the values produced by the specified Iterable.\n *\n * @iterable mixed\n */",
|
||||
(const char *)0x8 /* KindOfNull */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "N;", (const char *)2, "null", (const char *)4, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "isEmpty", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.isempty.php )\n *\n * Returns true if the Set is empty, false otherwise.\n *\n * @return bool\n */",
|
||||
(const char *)0x9 /* KindOfBoolean */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "count", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.count.php )\n *\n * Returns the number of values in the Set.\n *\n * @return int\n */",
|
||||
(const char *)0xa /* KindOfInt64 */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "items", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.items.php )\n *\n * Returns an Iterable that produces the values from this Set.\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "view", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.view.php )\n *\n * Returns a lazy iterable view of this Set.\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "clear", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.clear.php )\n *\n * Removes all values from the Set.\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "contains", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.contains.php )\n *\n * Returns true if the specified value is present in the Set, returns\n * false otherwise.\n *\n * @val mixed\n *\n * @return bool\n */",
|
||||
(const char *)0x9 /* KindOfBoolean */, (const char *)0x2000, "val", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "remove", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.remove.php )\n *\n * Removes the specified value from this Set.\n *\n * @val mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "val", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "discard", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.discard.php )\n *\n * Removes the specified value from this Set.\n *\n * @val mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "val", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "add", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.add.php )\n *\n * Adds the specified value to this Set.\n *\n * @val mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "val", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "addAll", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.addall.php )\n *\n * Adds the values produced by the specified Iterable to this Set.\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "toArray", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.toarray.php )\n *\n * Returns an array built from the values from this Set.\n *\n * @return map\n */",
|
||||
(const char *)0x20 /* KindOfArray */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "getIterator", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.getiterator.php )\n *\n * Returns an iterator that points to beginning of this Set.\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "map", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.map.php )\n *\n * Returns an Iterable of the values produced by applying the specified\n * callback on the values of this Set.\n *\n * @callback mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "callback", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "filter", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.filter.php )\n *\n * Returns a Iterable of all the values from this Set for which the\n * specified callback returns true.\n *\n * @callback mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "callback", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "zip", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.zip.php )\n *\n * Returns a Iterable produced by combined the specified Iterables\n * pair-wise.\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "difference", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.difference.php )\n *\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "updateFromArrayValues", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.updatefromarrayvalues.php )\n *\n *\n * @arr mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "arr", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "updateFromIterableValues", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.updatefromiterablevalues.php\n * )\n *\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "__toString", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.tostring.php )\n *\n *\n * @return string\n */",
|
||||
(const char *)0x14 /* KindOfString */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "__get", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.get.php )\n *\n *\n * @name mixed\n *\n * @return mixed\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "name", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "__set", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.set.php )\n *\n *\n * @name mixed\n * @value mixed\n *\n * @return mixed\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "name", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
(const char *)0x2000, "value", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "__isset", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.isset.php )\n *\n *\n * @name mixed\n *\n * @return bool\n */",
|
||||
(const char *)0x9 /* KindOfBoolean */, (const char *)0x2000, "name", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "__unset", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.unset.php )\n *\n *\n * @name mixed\n *\n * @return mixed\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "name", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006240, "fromItems", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.fromitems.php )\n *\n * Returns a Set built from the values produced by the specified Iterable.\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006240, "fromArray", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.fromarray.php )\n *\n * Returns a Set built from the values from the specified array.\n *\n * @arr mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "arr", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10026240, "fromArrays", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.fromarrays.php )\n *\n * Returns a Set built from the values from the specified arrays.\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006240, "fromIterableValues", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/set.fromiterablevalues.php )\n *\n *\n * @iterable mixed\n *\n * @return object\n */",
|
||||
(const char *)0x40 /* KindOfObject */, (const char *)0x2000, "iterable", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006020, "SetIterator", "", "", (const char *)0, (const char *)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/class.setiterator.php )\n *\n * An iterator implementation for iterating over a Set.\n *\n */",
|
||||
"iterator", NULL,
|
||||
(const char *)0x10006040, "__construct", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.construct.php )\n *\n *\n */",
|
||||
(const char *)0x8 /* KindOfNull */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "current", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.current.php )\n *\n * Returns the current value that the iterator points to.\n *\n * @return mixed\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "key", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.key.php )\n *\n *\n * @return mixed\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "valid", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.valid.php )\n *\n * Returns true if the iterator points to a valid value, returns false\n * otherwise.\n *\n * @return bool\n */",
|
||||
(const char *)0x9 /* KindOfBoolean */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "next", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.next.php )\n *\n * Advance this iterator forward one position.\n *\n */",
|
||||
(const char *)0x8 /* KindOfNull */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "rewind", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/setiterator.rewind.php )\n *\n * Move this iterator back to the first position.\n *\n */",
|
||||
(const char *)0x8 /* KindOfNull */, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006020, "Pair", "", "", (const char *)0, (const char *)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/class.pair.php )\n *\n * An ordered fixed-sized container.\n *\n */",
|
||||
"constvector", NULL,
|
||||
|
||||
@@ -57,8 +57,7 @@ class MappedIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method MappedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return ($this->fn)($this->it->current());
|
||||
@@ -154,8 +153,7 @@ class FilteredIterator implements Iterator {
|
||||
}
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method FilteredIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return $this->it->current();
|
||||
@@ -254,8 +252,7 @@ class ZippedIterator implements Iterator {
|
||||
$this->it2->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method ZippedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return Pair {$this->it1->current(), $this->it2->current()};
|
||||
@@ -344,8 +341,7 @@ class KeysIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method KeysIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return $this->it->key();
|
||||
@@ -384,8 +380,7 @@ class KVZippedIterator implements Iterator {
|
||||
$this->it->next();
|
||||
}
|
||||
public function key() {
|
||||
throw new RuntimeException(
|
||||
"Call to undefined method KVZippedIterator::key()");
|
||||
return null;
|
||||
}
|
||||
public function current() {
|
||||
return Pair {$this->it->key(), $this->it->current()};
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$x = Set {1, 2, 3};
|
||||
var_dump($x);
|
||||
echo print_r($x, true);
|
||||
debug_zval_dump($x);
|
||||
echo var_export($x, true) . "\n";
|
||||
echo json_encode($x) . "\n";
|
||||
echo json_encode($x, JSON_PRETTY_PRINT) . "\n";
|
||||
echo serialize($x) . "\n";
|
||||
var_dump(unserialize(serialize($x)));
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
object(Set)#1 (3) {
|
||||
int(1)
|
||||
int(2)
|
||||
int(3)
|
||||
}
|
||||
Set Object
|
||||
(
|
||||
1
|
||||
2
|
||||
3
|
||||
)
|
||||
object(Set)#1 (3) refcount(2){
|
||||
long(1) refcount(1)
|
||||
long(2) refcount(1)
|
||||
long(3) refcount(1)
|
||||
}
|
||||
Set::__set_state(array(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
))
|
||||
[1,2,3]
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
V:3:"Set":3:{i:1;i:2;i:3;}
|
||||
object(Set)#2 (3) {
|
||||
int(1)
|
||||
int(2)
|
||||
int(3)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$mapFn = function ($v) { return $v+1; };
|
||||
$filtFn = function ($v) { return $v % 2 == 0; };
|
||||
$st = Set {0, 3};
|
||||
var_dump($st->map($mapFn)->filter($filtFn));
|
||||
foreach ($st->view()->map($mapFn)->filter($filtFn) as $v) {
|
||||
var_dump($v);
|
||||
}
|
||||
$st = new Set(Vector {6, 9});
|
||||
var_dump($st->map($mapFn)->filter($filtFn));
|
||||
foreach ($st->items()->map($mapFn)->filter($filtFn) as $v) {
|
||||
var_dump($v);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
object(Set)#5 (1) {
|
||||
int(4)
|
||||
}
|
||||
int(4)
|
||||
object(Set)#12 (1) {
|
||||
int(10)
|
||||
}
|
||||
int(10)
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$s1 = Set {};
|
||||
$s2 = Set {};
|
||||
var_dump($s1 == $s2);
|
||||
$s1->add('a');
|
||||
var_dump($s1 == $s2);
|
||||
$s2[] = 'b';
|
||||
var_dump($s1 == $s2);
|
||||
$s1[] = 'b';
|
||||
var_dump($s1 == $s2);
|
||||
$s2->add('a');
|
||||
var_dump($s1 == $s2);
|
||||
$s1[] = 'c';
|
||||
var_dump($s1 == $s2);
|
||||
echo "============\n";
|
||||
$s1 = Set {'a', 'b', 'c', 'd'};
|
||||
$s1->remove('a');
|
||||
$s1->remove('c');
|
||||
$s2 = Set {'b', 'd'};
|
||||
var_dump($s1 == $s2);
|
||||
$s1->remove('d');
|
||||
var_dump($s1 == $s2);
|
||||
$s2->remove('d');
|
||||
var_dump($s1 == $s2);
|
||||
$s1->add('d');
|
||||
var_dump($s1 == $s2);
|
||||
$s2->add('d');
|
||||
var_dump($s1 == $s2);
|
||||
echo "============\n";
|
||||
$m = Set {};
|
||||
var_dump($m == null);
|
||||
var_dump($m == false);
|
||||
var_dump($m == true);
|
||||
var_dump($m == 1);
|
||||
var_dump($m == "Set");
|
||||
echo "============\n";
|
||||
$m = Set {7};
|
||||
var_dump($m == null);
|
||||
var_dump($m == false);
|
||||
var_dump($m == true);
|
||||
var_dump($m == 1);
|
||||
var_dump($m == "Set");
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
============
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
============
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
============
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$obj = new stdclass();
|
||||
$x0 = Vector {1, $obj, "foo", $obj};
|
||||
apc_store('x0', $x0);
|
||||
$x1 = apc_fetch('x0');
|
||||
var_dump($x1);
|
||||
echo "========\n";
|
||||
$x0 = Map {'a' => 1, 'b' => $obj, 33 => "foo", 44 => $obj};
|
||||
apc_store('x0', $x0);
|
||||
$x1 = apc_fetch('x0');
|
||||
var_dump($x1);
|
||||
echo "========\n";
|
||||
$x0 = StableMap {'a' => 1, 'b' => $obj, 33 => "foo", 44 => $obj};
|
||||
apc_store('x0', $x0);
|
||||
$x1 = apc_fetch('x0');
|
||||
var_dump($x1);
|
||||
echo "========\n";
|
||||
$x0 = Set {1, "foo"};
|
||||
apc_store('x0', $x0);
|
||||
$x1 = apc_fetch('x0');
|
||||
var_dump($x1);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
object(Vector)#3 (4) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
object(stdClass)#4 (0) {
|
||||
}
|
||||
[2]=>
|
||||
string(3) "foo"
|
||||
[3]=>
|
||||
object(stdClass)#4 (0) {
|
||||
}
|
||||
}
|
||||
========
|
||||
object(Map)#6 (4) {
|
||||
[33]=>
|
||||
string(3) "foo"
|
||||
["a"]=>
|
||||
int(1)
|
||||
[44]=>
|
||||
object(stdClass)#7 (0) {
|
||||
}
|
||||
["b"]=>
|
||||
object(stdClass)#7 (0) {
|
||||
}
|
||||
}
|
||||
========
|
||||
object(StableMap)#9 (4) {
|
||||
["a"]=>
|
||||
int(1)
|
||||
["b"]=>
|
||||
object(stdClass)#10 (0) {
|
||||
}
|
||||
[33]=>
|
||||
string(3) "foo"
|
||||
[44]=>
|
||||
object(stdClass)#10 (0) {
|
||||
}
|
||||
}
|
||||
========
|
||||
object(Set)#12 (2) {
|
||||
int(1)
|
||||
string(3) "foo"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$m = StableMap {'d' => 4};
|
||||
$x0 = Vector {Map {'a' => 1}, Map {'b' => 2}, Set {'c'}, $m, $m};
|
||||
apc_store('x0', $x0);
|
||||
$x1 = apc_fetch('x0');
|
||||
$x1[3]['e'] = 5;
|
||||
var_dump($x1);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
object(Vector)#6 (5) {
|
||||
[0]=>
|
||||
object(Map)#7 (1) {
|
||||
["a"]=>
|
||||
int(1)
|
||||
}
|
||||
[1]=>
|
||||
object(Map)#8 (1) {
|
||||
["b"]=>
|
||||
int(2)
|
||||
}
|
||||
[2]=>
|
||||
object(Set)#9 (1) {
|
||||
string(1) "c"
|
||||
}
|
||||
[3]=>
|
||||
object(StableMap)#10 (2) {
|
||||
["d"]=>
|
||||
int(4)
|
||||
["e"]=>
|
||||
int(5)
|
||||
}
|
||||
[4]=>
|
||||
object(StableMap)#10 (2) {
|
||||
["d"]=>
|
||||
int(4)
|
||||
["e"]=>
|
||||
int(5)
|
||||
}
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário