/** * @covers ::array_intersect */ public function testIntersect() { $a = ["3", "4", 1, 2]; $b = [1, 2, 3, 4]; $result = [1, 2]; $this->assertSame($result, Shim::array_intersect($a, $b)); }
/** * Reduce the generated tree to only contain the actual dominators * * This is an inefficient algorithm. It is approximately O(n^2). */ protected function reduce(Vertex $start) { $changed = true; while ($changed) { $changed = false; foreach ($this->graph->vertices() as $vertex) { if ($vertex === $start) { continue; } $pred = $this->iPredecessors[$vertex]; if (empty($pred)) { continue; } $new = $this->dominator[$pred[0]]; for ($i = 1; $i < count($pred); $i++) { $new = Shim::array_intersect($new, $this->dominator[$pred[$i]]); } $new = array_merge($new, [$vertex]); if ($new !== $this->dominator[$vertex]) { $changed = true; $this->dominator[$vertex] = $new; } } } }