Skip to content

Commit 5c9a3dc

Browse files
committed
Throw a meaningful exception when no schema was set
1 parent c4b8270 commit 5c9a3dc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/SchemaValidatableElementTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use DOMDocument;
88
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\XML\Exception\IOException;
9+
use SimpleSAML\XML\Exception\{IOException, RuntimeException};
1010
use SimpleSAML\XML\Exception\SchemaViolationException;
1111

1212
use function array_unique;
@@ -75,9 +75,10 @@ public static function schemaValidate(DOMDocument $document, ?string $schemaFile
7575
*/
7676
public static function getSchemaFile(): string
7777
{
78-
if (defined('static::SCHEMA')) {
79-
$schemaFile = static::SCHEMA;
78+
if (!defined('static::SCHEMA')) {
79+
throw new RuntimeException('A SCHEMA-constant was not set on this class.');
8080
}
81+
$schemaFile = static::SCHEMA;
8182

8283
Assert::true(file_exists($schemaFile), sprintf("File not found: %s", $schemaFile), IOException::class);
8384
return $schemaFile;

0 commit comments

Comments
 (0)