1--TEST--
2GH-11830 (ParentNode methods should perform their checks upfront) - attribute variation
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$doc = new DOMDocument;
8$doc->loadXML(<<<XML
9<?xml version="1.0"?>
10<container x="foo">
11    <test/>
12</container>
13XML);
14
15try {
16    $doc->documentElement->firstElementChild->prepend($doc->documentElement->attributes[0]);
17} catch (\DOMException $e) {
18    echo $e->getMessage(), "\n";
19}
20
21try {
22    $doc->documentElement->firstElementChild->append($doc->documentElement->attributes[0]);
23} catch (\DOMException $e) {
24    echo $e->getMessage(), "\n";
25}
26
27try {
28    $doc->documentElement->firstElementChild->before($doc->documentElement->attributes[0]);
29} catch (\DOMException $e) {
30    echo $e->getMessage(), "\n";
31}
32
33try {
34    $doc->documentElement->firstElementChild->after($doc->documentElement->attributes[0]);
35} catch (\DOMException $e) {
36    echo $e->getMessage(), "\n";
37}
38
39try {
40    $doc->documentElement->firstElementChild->replaceWith($doc->documentElement->attributes[0]);
41} catch (\DOMException $e) {
42    echo $e->getMessage(), "\n";
43}
44
45echo $doc->saveXML();
46?>
47--EXPECT--
48Hierarchy Request Error
49Hierarchy Request Error
50Hierarchy Request Error
51Hierarchy Request Error
52Hierarchy Request Error
53<?xml version="1.0"?>
54<container x="foo">
55    <test/>
56</container>
57