Skip to content
Snippets Groups Projects

Issue #3408166 by FatherShawn: fix Set inheritance bug

Merged Shawn Duncan requested to merge set-inheritance-bug into 1.0.x
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
+ 4
4
@@ -89,7 +89,7 @@ class Set implements SetInterface {
* {@inheritdoc}
*/
public function remove(mixed ...$values): void {
$filterSet = new Set(NULL);
$filterSet = new static(NULL);
$filterSet->add(...$values);
// $filter finds values not in the filter set.
$filter = fn($value) => !$filterSet->has($value);
@@ -118,7 +118,7 @@ class Set implements SetInterface {
$union = new \AppendIterator();
$union->append(new \IteratorIterator($this));
$union->append(new \IteratorIterator($set));
return new Set($union);
return new static($union);
}
/**
@@ -127,7 +127,7 @@ class Set implements SetInterface {
public function intersect(SetInterface $set): Set {
$filter = fn($value) => $set->has($value);
$intersection = array_filter($this->members, $filter);
return new Set($intersection);
return new static($intersection);
}
/**
@@ -136,7 +136,7 @@ class Set implements SetInterface {
public function difference(SetInterface $set): Set {
$filter = fn($value) => !$set->has($value);
$intersection = array_filter($this->members, $filter);
return new Set($intersection);
return new static($intersection);
}
/**
Loading