Skip to content

Commit 92472ab

Browse files
committed
Symbol: validate tokens in constructor
1 parent 77cbb14 commit 92472ab

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ImportDetection/Symbol.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ class Symbol {
88

99
public function __construct(array $tokens) {
1010
if (empty($tokens)) {
11-
throw new \Exception('Symbols cannot be empty');
11+
throw new \Exception('Cannot construct Symbol with no tokens');
12+
}
13+
foreach ($tokens as $token) {
14+
if (empty($token) || ! is_array($token)) {
15+
throw new \Exception('Cannot construct Symbol with invalid token: ' . var_export($token, true));
16+
}
1217
}
1318
$this->tokens = $tokens;
1419
}

0 commit comments

Comments
 (0)