public function setMatches($matches, $unique = true)
{
// This causes a lot of overhead....
//if ($unique) $matches = self::unique($matches);
$this->last = $this->matches;
// Just set current matches.
if ($matches instanceof \SplObjectStorage) {
$this->matches = $matches;
} elseif (is_array($matches)) {
trigger_error('Legacy array detected.');
$tmp = new \SplObjectStorage();
foreach ($matches as $m) {
$tmp->attach($m);
}
$this->matches = $tmp;
} else {
$found = new \SplObjectStorage();
if (isset($matches)) {
$found->attach($matches);
}
$this->matches = $found;
}
// EXPERIMENTAL: Support for qp()->length.
$this->length = $this->matches->count();
}