1--TEST--
2Test edge case offsets in DOMNamedNodeMap
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$document = new DomDocument();
9$root = $document->createElement('root');
10$document->appendChild($root);
11$root->setAttribute('attrib', 'value');
12var_dump($root->attributes->length);
13// Consistent with the method call
14try {
15    var_dump($root->attributes[-1]);
16} catch (ValueError $e) {
17    echo $e->getMessage(), "\n";
18}
19try {
20    $root->attributes[][] = null;
21} catch (Throwable $e) {
22    echo $e->getMessage(), "\n";
23}
24
25?>
26--EXPECT--
27int(1)
28must be between 0 and 2147483647
29Cannot access DOMNamedNodeMap without offset
30