1--TEST-- 2compareDocumentPosition: attribute order for same element 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = new DOMDocument(); 9$dom->loadXML(<<<XML 10<?xml version="1.0"?> 11<container a="b" c="d" e="f" /> 12XML); 13 14$attrs = $dom->documentElement->attributes; 15for ($i = 0; $i <= 2; $i++) { 16 for ($j = $i + 1; $j <= $i + 2; $j++) { 17 echo "--- Compare $i and ", ($j % 3), " ---\n"; 18 if ($i < ($j % 3)) { 19 $expected = DOMNode::DOCUMENT_POSITION_FOLLOWING | DOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; 20 } else { 21 $expected = DOMNode::DOCUMENT_POSITION_PRECEDING | DOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; 22 } 23 var_dump($attrs[$i]->compareDocumentPosition($attrs[$j % 3]) === $expected); 24 } 25} 26 27?> 28--EXPECT-- 29--- Compare 0 and 1 --- 30bool(true) 31--- Compare 0 and 2 --- 32bool(true) 33--- Compare 1 and 2 --- 34bool(true) 35--- Compare 1 and 0 --- 36bool(true) 37--- Compare 2 and 0 --- 38bool(true) 39--- Compare 2 and 1 --- 40bool(true) 41