private function traverseDisjunction(OrX $expr) { $disjuncts1 = $expr->getDisjuncts(); $disjuncts2 = array(); foreach ($disjuncts1 as $disjunct) { if ($disjunct = $this->traverse($disjunct)) { $disjuncts2[] = $disjunct; } } if ($disjuncts1 === $disjuncts2) { return $expr; } return $disjuncts2 ? new OrX($disjuncts2) : null; }
public function testToString() { $expr1 = new OrX(); $expr2 = new OrX(array(new GreaterThan(10), new EndsWith('.css'))); $expr3 = new OrX(array(new GreaterThan(10), new AndX(array(new Contains('foo'), new EndsWith('.css'))))); $this->assertSame('', $expr1->toString()); $this->assertSame('>10 || endsWith(".css")', $expr2->toString()); $this->assertSame('>10 || (contains("foo") && endsWith(".css"))', $expr3->toString()); }