Skip to content

Commit 14ee624

Browse files
committed
Consolidate error types for unsupported array access
1 parent 0d87550 commit 14ee624

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/Map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Ds;
33

4+
use Error;
45
use OutOfBoundsException;
56
use OutOfRangeException;
67
use Traversable;
@@ -675,7 +676,6 @@ public function &offsetGet($offset)
675676
if ($pair) {
676677
return $pair->value;
677678
}
678-
679679
throw new OutOfBoundsException();
680680
}
681681

src/Queue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function offsetSet($offset, $value)
135135
if ($offset === null) {
136136
$this->push($value);
137137
} else {
138-
throw new OutOfBoundsException();
138+
throw new Error();
139139
}
140140
}
141141

src/Set.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ public function offsetSet($offset, $value)
426426
$this->add($value);
427427
return;
428428
}
429-
430-
throw new OutOfBoundsException();
429+
throw new Error();
431430
}
432431

433432
/**

src/Stack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function offsetSet($offset, $value)
140140
if ($offset === null) {
141141
$this->push($value);
142142
} else {
143-
throw new OutOfBoundsException();
143+
throw new Error();
144144
}
145145
}
146146

0 commit comments

Comments
 (0)