Skip to content

Commit 1487451

Browse files
authored
Merge pull request #33 from simplesamlphp/feature/array-last
Replace array_pop with array_last
2 parents 17a385f + 221b392 commit 1487451

9 files changed

Lines changed: 32 additions & 22 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ext-pcre": "*",
1616

1717
"simplesamlphp/assert": "~2.0",
18-
"simplesamlphp/xml-common": "dev-feature/dom-migration-php84"
18+
"simplesamlphp/xml-common": "~2.0"
1919
},
2020
"require-dev": {
2121
"simplesamlphp/simplesamlphp-test-framework": "~1.11"

src/SOAP11/XML/Body.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use function array_diff;
1818
use function array_filter;
19-
use function array_pop;
19+
use function array_last;
2020
use function array_values;
2121

2222
/**
@@ -61,7 +61,7 @@ public function __construct(array $children = [], array $namespacedAttributes =
6161
}));
6262
Assert::maxCount($fault, 1, ProtocolViolationException::class);
6363

64-
$this->setFault(array_pop($fault));
64+
$this->setFault(array_last($fault));
6565
$this->setElements(array_diff($children, $fault));
6666
$this->setAttributesNS($namespacedAttributes);
6767
}

src/SOAP11/XML/Envelope.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
1616
use SimpleSAML\XMLSchema\XML\Constants\NS;
1717

18+
use function array_last;
19+
1820
/**
1921
* Class representing a SOAP-ENV:Envelope element.
2022
*
@@ -91,8 +93,8 @@ public static function fromXML(DOMElement $xml): static
9193
Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class);
9294

9395
return new static(
94-
array_pop($body),
95-
empty($header) ? null : array_pop($header),
96+
array_last($body),
97+
array_last($header),
9698
self::getChildElementsFromXML($xml),
9799
self::getAttributesNSFromXML($xml),
98100
);

src/SOAP11/XML/Fault.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use SimpleSAML\XMLSchema\Exception\MissingElementException;
1313
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
1414

15+
use function array_last;
16+
1517
/**
1618
* Class representing a SOAP-ENV:Fault element.
1719
*
@@ -106,10 +108,10 @@ public static function fromXML(DOMElement $xml): static
106108
Assert::maxCount($detail, 1, 'Cannot process more than one detail element.', TooManyElementsException::class);
107109

108110
return new self(
109-
array_pop($faultCode),
110-
array_pop($faultString),
111-
array_pop($faultActor),
112-
array_pop($detail),
111+
array_last($faultCode),
112+
array_last($faultString),
113+
array_last($faultActor),
114+
array_last($detail),
113115
);
114116
}
115117

src/SOAP12/XML/Body.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1515
use SimpleSAML\XMLSchema\XML\Constants\NS;
1616

17-
use function array_pop;
17+
use function array_last;
1818

1919
/**
2020
* Class representing a env:Body element.
@@ -104,7 +104,7 @@ public static function fromXML(DOMElement $xml): static
104104
Assert::maxCount($fault, 1, ProtocolViolationException::class);
105105

106106
return new static(
107-
array_pop($fault),
107+
array_last($fault),
108108
self::getChildElementsFromXML($xml),
109109
self::getAttributesNSFromXML($xml),
110110
);

src/SOAP12/XML/Code.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public static function fromXML(DOMElement $xml): static
6868
Assert::maxCount($subcode, 1, 'Cannot process more than one Subcode element.', TooManyElementsException::class);
6969

7070
return new static(
71-
array_pop($value),
72-
empty($subcode) ? null : array_pop($subcode),
71+
array_last($value),
72+
array_last($subcode),
7373
);
7474
}
7575

src/SOAP12/XML/Envelope.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
1515
use SimpleSAML\XMLSchema\XML\Constants\NS;
1616

17+
use function array_last;
18+
1719
/**
1820
* Class representing a env:Envelope element.
1921
*
@@ -83,8 +85,8 @@ public static function fromXML(DOMElement $xml): static
8385
Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class);
8486

8587
return new static(
86-
array_pop($body),
87-
empty($header) ? null : array_pop($header),
88+
array_last($body),
89+
array_last($header),
8890
self::getAttributesNSFromXML($xml),
8991
);
9092
}

src/SOAP12/XML/Fault.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use SimpleSAML\XMLSchema\Exception\MissingElementException;
1414
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
1515

16+
use function array_last;
17+
1618
/**
1719
* Class representing a env:Fault element.
1820
*
@@ -116,11 +118,11 @@ public static function fromXML(DOMElement $xml): static
116118
Assert::maxCount($detail, 1, 'Cannot process more than one Detail element.', TooManyElementsException::class);
117119

118120
return new self(
119-
array_pop($code),
120-
array_pop($reason),
121-
empty($node) ? null : array_pop($node),
122-
empty($role) ? null : array_pop($role),
123-
empty($detail) ? null : array_pop($detail),
121+
array_last($code),
122+
array_last($reason),
123+
array_last($node),
124+
array_last($role),
125+
array_last($detail),
124126
);
125127
}
126128

src/SOAP12/XML/Subcode.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use SimpleSAML\XMLSchema\Exception\MissingElementException;
1111
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
1212

13+
use function array_last;
14+
1315
/**
1416
* Class representing a env:Subcode element.
1517
*
@@ -68,8 +70,8 @@ public static function fromXML(DOMElement $xml): static
6870
Assert::maxCount($subcode, 1, 'Cannot process more than one Subcode element.', TooManyElementsException::class);
6971

7072
return new static(
71-
array_pop($value),
72-
empty($subcode) ? null : array_pop($subcode),
73+
array_last($value),
74+
array_last($subcode),
7375
);
7476
}
7577

0 commit comments

Comments
 (0)