Skip to content

Commit a356c99

Browse files
committed
Replace assertions
1 parent 47d523d commit a356c99

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/Cas/Ticket/DelegatingTicketStore.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Exception;
88
use InvalidArgumentException;
9+
use SimpleSAML\Assert\Assert;
910
use SimpleSAML\Configuration;
1011
use SimpleSAML\Logger;
1112
use SimpleSAML\Module;
@@ -55,7 +56,7 @@ public function __construct(Configuration $casConfig)
5556
Logger::error("Unable to create ticket store '$name'. Error " . $e->getMessage());
5657
}
5758
}
58-
assert(!empty($this->ticketStores), "'ticketStores' must be defined.");
59+
Assert::notEmpty($this->ticketStores, "'ticketStores' must be defined.");
5960
$this->ticketStores = $this->ticketStores;
6061

6162
if ($this->delegateTo === 'first') {

lib/Shib13/AuthnResponse.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use DOMXpath;
1717
use Exception;
1818
use SAML2\DOMDocumentFactory;
19+
use SimpleSAML\Assert\Assert;
1920
use SimpleSAML\Configuration;
2021
use SimpleSAML\Error;
2122
use SimpleSAML\Metadata\MetaDataStorageHandler;
@@ -100,7 +101,7 @@ public function getRelayState(): ?string
100101
*/
101102
public function validate(): bool
102103
{
103-
assert($this->dom instanceof DOMDocument);
104+
Assert::isInstanceOf($this->dom, DOMDocument::class);
104105

105106
if ($this->messageValidated) {
106107
// This message was validated externally
@@ -167,7 +168,7 @@ private function isNodeValidated($node): bool
167168
$node = dom_import_simplexml($node);
168169
}
169170

170-
assert($node instanceof DOMNode);
171+
Assert::isInstanceOf($node, DOMNode::class);
171172

172173
return $this->validator->isNodeValidated($node);
173174
}
@@ -183,13 +184,13 @@ private function isNodeValidated($node): bool
183184
*/
184185
private function doXPathQuery(string $query, DOMNode $node = null): DOMNodeList
185186
{
186-
assert($this->dom instanceof DOMDocument);
187+
Assert::isInstanceOf($node, DOMNode::class);
187188

188189
if ($node === null) {
189190
$node = $this->dom->documentElement;
190191
}
191192

192-
assert($node instanceof DOMNode);
193+
Assert::isInstanceOf($node, DOMNode::class);
193194

194195
$xPath = new DOMXpath($this->dom);
195196
$xPath->registerNamespace('shibp', self::SHIB_PROTOCOL_NS);
@@ -206,7 +207,7 @@ private function doXPathQuery(string $query, DOMNode $node = null): DOMNodeList
206207
*/
207208
public function getSessionIndex(): ?string
208209
{
209-
assert($this->dom instanceof DOMDocument);
210+
Assert::isInstanceOf($node, DOMNode::class);
210211

211212
$query = '/shibp:Response/shib:Assertion/shib:AuthnStatement';
212213
$nodelist = $this->doXPathQuery($query);

0 commit comments

Comments
 (0)