Skip to content

Commit e4c2bf2

Browse files
committed
More phpdoc @throws
1 parent 293b65c commit e4c2bf2

File tree

2 files changed

+67
-43
lines changed

2 files changed

+67
-43
lines changed

src/EnumMap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function offsetExists($enumerator)
143143
* @param Enum|null|bool|int|float|string|array $enumerator
144144
* @return mixed
145145
* @throws InvalidArgumentException On an invalid given enumerator
146+
* @throws UnexpectedValueException If the given enumerator does not exist in this map
146147
*/
147148
public function offsetGet($enumerator)
148149
{
@@ -198,6 +199,7 @@ public function offsetUnset($enumerator)
198199
/**
199200
* Seeks to the given iterator position.
200201
* @param int $pos
202+
* @throws OutOfBoundsException On an invalid position
201203
*/
202204
public function seek($pos)
203205
{

src/EnumSet.php

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ public function next()
183183
* Go to the first valid iterator position.
184184
* If no valid iterator position was found the iterator position will be 0.
185185
* @return void
186-
* @see doRewindBin
187-
* @see doRewindInt
186+
* @uses doRewindBin()
187+
* @uses doRewindInt()
188188
*/
189189
public function rewind()
190190
{
@@ -198,8 +198,8 @@ public function rewind()
198198
* This is the binary bitset implementation.
199199
*
200200
* @return void
201-
* @see rewind
202-
* @see doRewindInt
201+
* @see rewind()
202+
* @see doRewindInt()
203203
*/
204204
private function doRewindBin()
205205
{
@@ -218,8 +218,8 @@ private function doRewindBin()
218218
* This is the binary bitset implementation.
219219
*
220220
* @return void
221-
* @see rewind
222-
* @see doRewindBin
221+
* @see rewind()
222+
* @see doRewindBin()
223223
*/
224224
private function doRewindInt()
225225
{
@@ -246,8 +246,8 @@ public function valid()
246246
* Count the number of elements
247247
*
248248
* @return int
249-
* @see doCountBin
250-
* @see doCountInt
249+
* @uses doCountBin()
250+
* @uses doCountInt()
251251
*/
252252
public function count()
253253
{
@@ -260,8 +260,8 @@ public function count()
260260
* This is the binary bitset implementation.
261261
*
262262
* @return int
263-
* @see count
264-
* @see doCountInt
263+
* @see count()
264+
* @see doCountInt()
265265
*/
266266
private function doCountBin()
267267
{
@@ -293,8 +293,8 @@ private function doCountBin()
293293
* This is the integer bitset implementation.
294294
*
295295
* @return int
296-
* @see count
297-
* @see doCountBin
296+
* @see count()
297+
* @see doCountBin()
298298
*/
299299
private function doCountInt()
300300
{
@@ -376,6 +376,7 @@ public function isSuperset(EnumSet $other)
376376
*
377377
* @param EnumSet $other EnumSet of the same enumeration to produce the union
378378
* @return EnumSet
379+
* @throws InvalidArgumentException If $other doesn't match the enumeration
379380
*/
380381
public function union(EnumSet $other)
381382
{
@@ -396,6 +397,7 @@ public function union(EnumSet $other)
396397
*
397398
* @param EnumSet $other EnumSet of the same enumeration to produce the intersect
398399
* @return EnumSet
400+
* @throws InvalidArgumentException If $other doesn't match the enumeration
399401
*/
400402
public function intersect(EnumSet $other)
401403
{
@@ -416,6 +418,7 @@ public function intersect(EnumSet $other)
416418
*
417419
* @param EnumSet $other EnumSet of the same enumeration to produce the diff
418420
* @return EnumSet
421+
* @throws InvalidArgumentException If $other doesn't match the enumeration
419422
*/
420423
public function diff(EnumSet $other)
421424
{
@@ -436,6 +439,7 @@ public function diff(EnumSet $other)
436439
*
437440
* @param EnumSet $other EnumSet of the same enumeration to produce the symmetric difference
438441
* @return EnumSet
442+
* @throws InvalidArgumentException If $other doesn't match the enumeration
439443
*/
440444
public function symDiff(EnumSet $other)
441445
{
@@ -454,6 +458,8 @@ public function symDiff(EnumSet $other)
454458
/**
455459
* Get ordinal numbers of the defined enumerators as array
456460
* @return int[]
461+
* @uses doGetOrdinalsBin()
462+
* @uses doGetOrdinalsInt()
457463
*/
458464
public function getOrdinals()
459465
{
@@ -466,8 +472,8 @@ public function getOrdinals()
466472
* This is the binary bitset implementation.
467473
*
468474
* @return int[]
469-
* @see getOrdinals
470-
* @see goGetOrdinalsInt
475+
* @see getOrdinals()
476+
* @see goGetOrdinalsInt()
471477
*/
472478
private function doGetOrdinalsBin()
473479
{
@@ -496,8 +502,8 @@ private function doGetOrdinalsBin()
496502
* This is the integer bitset implementation.
497503
*
498504
* @return int[]
499-
* @see getOrdinals
500-
* @see doGetOrdinalsBin
505+
* @see getOrdinals()
506+
* @see doGetOrdinalsBin()
501507
*/
502508
private function doGetOrdinalsInt()
503509
{
@@ -558,6 +564,8 @@ public function getEnumerators()
558564
* Get binary bitset in little-endian order
559565
*
560566
* @return string
567+
* @uses doGetBinaryBitsetLeBin()
568+
* @uses doGetBinaryBitsetLeInt()
561569
*/
562570
public function getBinaryBitsetLe()
563571
{
@@ -570,6 +578,8 @@ public function getBinaryBitsetLe()
570578
* This is the binary bitset implementation.
571579
*
572580
* @return string
581+
* @see getBinaryBitsetLe()
582+
* @see doGetBinaryBitsetLeInt()
573583
*/
574584
private function doGetBinaryBitsetLeBin()
575585
{
@@ -582,6 +592,8 @@ private function doGetBinaryBitsetLeBin()
582592
* This is the integer bitset implementation.
583593
*
584594
* @return string
595+
* @see getBinaryBitsetLe()
596+
* @see doGetBinaryBitsetLeBin()
585597
*/
586598
private function doGetBinaryBitsetLeInt()
587599
{
@@ -597,7 +609,9 @@ private function doGetBinaryBitsetLeInt()
597609
* @param string $bitset
598610
* @return void
599611
* @throws InvalidArgumentException On a non string is given as Parameter
600-
* @throws InvalidArgumentException On Out-Of-Range bits given as input bitset
612+
* @throws InvalidArgumentException On out-of-range bits given as input bitset
613+
* @uses doSetBinaryBitsetLeBin()
614+
* @uses doSetBinaryBitsetLeInt()
601615
*/
602616
public function setBinaryBitsetLe($bitset)
603617
{
@@ -618,7 +632,9 @@ public function setBinaryBitsetLe($bitset)
618632
*
619633
* @param string $bitset
620634
* @return void
621-
* @throws InvalidArgumentException On Out-Of-Range bits given as input bitset
635+
* @throws InvalidArgumentException On out-of-range bits given as input bitset
636+
* @see setBinaryBitsetLeBin()
637+
* @see doSetBinaryBitsetLeInt()
622638
*/
623639
private function doSetBinaryBitsetLeBin($bitset)
624640
{
@@ -630,7 +646,7 @@ private function doSetBinaryBitsetLeBin($bitset)
630646
$bitset .= \str_repeat("\0", $size - $sizeIn);
631647
} elseif ($sizeIn > $size) {
632648
if (\ltrim(\substr($bitset, $size), "\0") !== '') {
633-
throw new InvalidArgumentException('Out-Of-Range bits detected');
649+
throw new InvalidArgumentException('out-of-range bits detected');
634650
}
635651
$bitset = \substr($bitset, 0, $size);
636652
}
@@ -641,7 +657,7 @@ private function doSetBinaryBitsetLeBin($bitset)
641657
$lastByte = $bitset[$size - 1];
642658
$lastByteExpected = \chr((1 << $lastByteMaxOrd) - 1) & $lastByte;
643659
if ($lastByte !== $lastByteExpected) {
644-
throw new InvalidArgumentException('Out-Of-Range bits detected');
660+
throw new InvalidArgumentException('out-of-range bits detected');
645661
}
646662

647663
$this->bitset = \substr($bitset, 0, -1) . $lastByteExpected;
@@ -657,7 +673,9 @@ private function doSetBinaryBitsetLeBin($bitset)
657673
*
658674
* @param string $bitset
659675
* @return void
660-
* @throws InvalidArgumentException On Out-Of-Range bits given as input bitset
676+
* @throws InvalidArgumentException On out-of-range bits given as input bitset
677+
* @see setBinaryBitsetLeBin()
678+
* @see doSetBinaryBitsetLeBin()
661679
*/
662680
private function doSetBinaryBitsetLeInt($bitset)
663681
{
@@ -667,14 +685,14 @@ private function doSetBinaryBitsetLeInt($bitset)
667685
$ord = \ord($bitset[$i]);
668686

669687
if ($ord && $i > \PHP_INT_SIZE - 1) {
670-
throw new InvalidArgumentException('Out-Of-Range bits detected');
688+
throw new InvalidArgumentException('out-of-range bits detected');
671689
}
672690

673691
$int |= $ord << (8 * $i);
674692
}
675693

676694
if ($int & (~0 << $this->ordinalMax)) {
677-
throw new InvalidArgumentException('Out-Of-Range bits detected');
695+
throw new InvalidArgumentException('out-of-range bits detected');
678696
}
679697

680698
$this->bitset = $int;
@@ -698,7 +716,7 @@ public function getBinaryBitsetBe()
698716
* @param string $bitset
699717
* @return void
700718
* @throws InvalidArgumentException On a non string is given as Parameter
701-
* @throws InvalidArgumentException On Out-Of-Range bits given as input bitset
719+
* @throws InvalidArgumentException On out-of-range bits given as input bitset
702720
*/
703721
public function setBinaryBitsetBe($bitset)
704722
{
@@ -713,6 +731,9 @@ public function setBinaryBitsetBe($bitset)
713731
*
714732
* @param int $ordinal Ordinal number of bit to get
715733
* @return bool
734+
* @throws InvalidArgumentException If the given ordinal number is out-of-range
735+
* @uses doGetBitBin()
736+
* @uses doGetBitInt()
716737
*/
717738
public function getBit($ordinal)
718739
{
@@ -730,8 +751,8 @@ public function getBit($ordinal)
730751
*
731752
* @param int $ordinal Ordinal number of bit to get
732753
* @return bool
733-
* @see getBit
734-
* @see doGetBitInt
754+
* @see getBit()
755+
* @see doGetBitInt()
735756
*/
736757
private function doGetBitBin($ordinal)
737758
{
@@ -745,8 +766,8 @@ private function doGetBitBin($ordinal)
745766
*
746767
* @param int $ordinal Ordinal number of bit to get
747768
* @return bool
748-
* @see getBit
749-
* @see doGetBitBin
769+
* @see getBit()
770+
* @see doGetBitBin()
750771
*/
751772
private function doGetBitInt($ordinal)
752773
{
@@ -756,13 +777,14 @@ private function doGetBitInt($ordinal)
756777
/**
757778
* Set a bit at the given ordinal number
758779
*
759-
* @param int $ordinal Ordnal number of bit to set
780+
* @param int $ordinal Ordinal number of bit to set
760781
* @param bool $bit The bit to set
761782
* @return void
762-
* @see doSetBitBin
763-
* @see doSetBitInt
764-
* @see doUnsetBin
765-
* @see doUnsetInt
783+
* @throws InvalidArgumentException If the given ordinal number is out-of-range
784+
* @uses doSetBitBin()
785+
* @uses doSetBitInt()
786+
* @uses doUnsetBitBin()
787+
* @uses doUnsetBitInt()
766788
*/
767789
public function setBit($ordinal, $bit)
768790
{
@@ -782,10 +804,10 @@ public function setBit($ordinal, $bit)
782804
*
783805
* This is the binary bitset implementation.
784806
*
785-
* @param int $ordinal Ordnal number of bit to set
807+
* @param int $ordinal Ordinal number of bit to set
786808
* @return void
787-
* @see setBit
788-
* @see doSetBitInt
809+
* @see setBit()
810+
* @see doSetBitInt()
789811
*/
790812
private function doSetBitBin($ordinal)
791813
{
@@ -798,10 +820,10 @@ private function doSetBitBin($ordinal)
798820
*
799821
* This is the binary bitset implementation.
800822
*
801-
* @param int $ordinal Ordnal number of bit to set
823+
* @param int $ordinal Ordinal number of bit to set
802824
* @return void
803-
* @see setBit
804-
* @see doSetBitBin
825+
* @see setBit()
826+
* @see doSetBitBin()
805827
*/
806828
private function doSetBitInt($ordinal)
807829
{
@@ -815,8 +837,8 @@ private function doSetBitInt($ordinal)
815837
*
816838
* @param int $ordinal Ordinal number of bit to unset
817839
* @return void
818-
* @see setBit
819-
* @see doUnsetBitInt
840+
* @see setBit()
841+
* @see doUnsetBitInt()
820842
*/
821843
private function doUnsetBitBin($ordinal)
822844
{
@@ -831,8 +853,8 @@ private function doUnsetBitBin($ordinal)
831853
*
832854
* @param int $ordinal Ordinal number of bit to unset
833855
* @return void
834-
* @see setBit
835-
* @see doUnsetBitBin
856+
* @see setBit()
857+
* @see doUnsetBitBin()
836858
*/
837859
private function doUnsetBitInt($ordinal)
838860
{

0 commit comments

Comments
 (0)