@@ -65,8 +65,8 @@ class EnumSet implements Iterator, Countable
65
65
*/
66
66
public function __construct ($ enumeration )
67
67
{
68
- if (!is_subclass_of ($ enumeration , Enum::class)) {
69
- throw new InvalidArgumentException (sprintf (
68
+ if (!\ is_subclass_of ($ enumeration , Enum::class)) {
69
+ throw new InvalidArgumentException (\ sprintf (
70
70
"%s can handle subclasses of '%s' only " ,
71
71
static ::class,
72
72
Enum::class
@@ -81,7 +81,7 @@ public function __construct($enumeration)
81
81
// we will switch this into a binary bitset
82
82
if ($ this ->ordinalMax > \PHP_INT_SIZE * 8 ) {
83
83
// init binary bitset with zeros
84
- $ this ->bitset = str_repeat ("\0" , ceil ($ this ->ordinalMax / 8 ));
84
+ $ this ->bitset = \ str_repeat ("\0" , ceil ($ this ->ordinalMax / 8 ));
85
85
86
86
// switch internal binary bitset functions
87
87
$ this ->fnDoRewind = 'doRewindBin ' ;
@@ -203,7 +203,7 @@ public function rewind()
203
203
*/
204
204
private function doRewindBin ()
205
205
{
206
- if (ltrim ($ this ->bitset , "\0" ) !== '' ) {
206
+ if (\ ltrim ($ this ->bitset , "\0" ) !== '' ) {
207
207
$ this ->ordinal = -1 ;
208
208
$ this ->next ();
209
209
} else {
@@ -267,14 +267,14 @@ private function doCountBin()
267
267
{
268
268
$ count = 0 ;
269
269
$ bitset = $ this ->bitset ;
270
- $ byteLen = strlen ($ bitset );
270
+ $ byteLen = \ strlen ($ bitset );
271
271
for ($ bytePos = 0 ; $ bytePos < $ byteLen ; ++$ bytePos ) {
272
272
if ($ bitset [$ bytePos ] === "\0" ) {
273
273
// fast skip null byte
274
274
continue ;
275
275
}
276
276
277
- $ ord = ord ($ bitset [$ bytePos ]);
277
+ $ ord = \ ord ($ bitset [$ bytePos ]);
278
278
for ($ bitPos = 0 ; $ bitPos < 8 ; ++$ bitPos ) {
279
279
if ($ ord & (1 << $ bitPos )) {
280
280
++$ count ;
@@ -470,14 +470,14 @@ private function doGetOrdinalsBin()
470
470
{
471
471
$ ordinals = [];
472
472
$ bitset = $ this ->bitset ;
473
- $ byteLen = strlen ($ bitset );
473
+ $ byteLen = \ strlen ($ bitset );
474
474
for ($ bytePos = 0 ; $ bytePos < $ byteLen ; ++$ bytePos ) {
475
475
if ($ bitset [$ bytePos ] === "\0" ) {
476
476
// fast skip null byte
477
477
continue ;
478
478
}
479
479
480
- $ ord = ord ($ bitset [$ bytePos ]);
480
+ $ ord = \ ord ($ bitset [$ bytePos ]);
481
481
for ($ bitPos = 0 ; $ bitPos < 8 ; ++$ bitPos ) {
482
482
if ($ ord & (1 << $ bitPos )) {
483
483
$ ordinals [] = $ bytePos * 8 + $ bitPos ;
@@ -582,8 +582,8 @@ private function doGetBinaryBitsetLeBin()
582
582
*/
583
583
private function doGetBinaryBitsetLeInt ()
584
584
{
585
- $ bin = pack (\PHP_INT_SIZE === 8 ? 'P ' : 'V ' , $ this ->bitset );
586
- return substr ($ bin , 0 , ceil ($ this ->ordinalMax / 8 ));
585
+ $ bin = \ pack (\PHP_INT_SIZE === 8 ? 'P ' : 'V ' , $ this ->bitset );
586
+ return \ substr ($ bin , 0 , \ ceil ($ this ->ordinalMax / 8 ));
587
587
}
588
588
589
589
/**
@@ -597,7 +597,7 @@ private function doGetBinaryBitsetLeInt()
597
597
*/
598
598
public function setBinaryBitsetLe ($ bitset )
599
599
{
600
- if (!is_string ($ bitset )) {
600
+ if (!\ is_string ($ bitset )) {
601
601
throw new InvalidArgumentException ('Bitset must be a string ' );
602
602
}
603
603
@@ -618,29 +618,29 @@ public function setBinaryBitsetLe($bitset)
618
618
*/
619
619
private function doSetBinaryBitsetLeBin ($ bitset )
620
620
{
621
- $ size = strlen ($ this ->bitset );
622
- $ sizeIn = strlen ($ bitset );
621
+ $ size = \ strlen ($ this ->bitset );
622
+ $ sizeIn = \ strlen ($ bitset );
623
623
624
624
if ($ sizeIn < $ size ) {
625
625
// add "\0" if the given bitset is not long enough
626
- $ bitset .= str_repeat ("\0" , $ size - $ sizeIn );
626
+ $ bitset .= \ str_repeat ("\0" , $ size - $ sizeIn );
627
627
} elseif ($ sizeIn > $ size ) {
628
- if (ltrim (substr ($ bitset , $ size ), "\0" ) !== '' ) {
628
+ if (\ ltrim (\ substr ($ bitset , $ size ), "\0" ) !== '' ) {
629
629
throw new InvalidArgumentException ('Out-Of-Range bits detected ' );
630
630
}
631
- $ bitset = substr ($ bitset , 0 , $ size );
631
+ $ bitset = \ substr ($ bitset , 0 , $ size );
632
632
}
633
633
634
634
// truncate out-of-range bits of last byte
635
635
$ lastByteMaxOrd = $ this ->ordinalMax % 8 ;
636
636
if ($ lastByteMaxOrd !== 0 ) {
637
637
$ lastByte = $ bitset [$ size - 1 ];
638
- $ lastByteExpected = chr ((1 << $ lastByteMaxOrd ) - 1 ) & $ lastByte ;
638
+ $ lastByteExpected = \ chr ((1 << $ lastByteMaxOrd ) - 1 ) & $ lastByte ;
639
639
if ($ lastByte !== $ lastByteExpected ) {
640
640
throw new InvalidArgumentException ('Out-Of-Range bits detected ' );
641
641
}
642
642
643
- $ this ->bitset = substr ($ bitset , 0 , -1 ) . $ lastByteExpected ;
643
+ $ this ->bitset = \ substr ($ bitset , 0 , -1 ) . $ lastByteExpected ;
644
644
}
645
645
646
646
$ this ->bitset = $ bitset ;
@@ -657,10 +657,10 @@ private function doSetBinaryBitsetLeBin($bitset)
657
657
*/
658
658
private function doSetBinaryBitsetLeInt ($ bitset )
659
659
{
660
- $ len = strlen ($ bitset );
660
+ $ len = \ strlen ($ bitset );
661
661
$ int = 0 ;
662
662
for ($ i = 0 ; $ i < $ len ; ++$ i ) {
663
- $ ord = ord ($ bitset [$ i ]);
663
+ $ ord = \ ord ($ bitset [$ i ]);
664
664
665
665
if ($ ord && $ i > \PHP_INT_SIZE - 1 ) {
666
666
throw new InvalidArgumentException ('Out-Of-Range bits detected ' );
@@ -683,7 +683,7 @@ private function doSetBinaryBitsetLeInt($bitset)
683
683
*/
684
684
public function getBinaryBitsetBe ()
685
685
{
686
- return strrev ($ this ->bitset );
686
+ return \ strrev ($ this ->bitset );
687
687
}
688
688
689
689
/**
@@ -697,10 +697,10 @@ public function getBinaryBitsetBe()
697
697
*/
698
698
public function setBinaryBitsetBe ($ bitset )
699
699
{
700
- if (!is_string ($ bitset )) {
700
+ if (!\ is_string ($ bitset )) {
701
701
throw new InvalidArgumentException ('Bitset must be a string ' );
702
702
}
703
- $ this ->setBinaryBitsetLe (strrev ($ bitset ));
703
+ $ this ->setBinaryBitsetLe (\ strrev ($ bitset ));
704
704
}
705
705
706
706
/**
@@ -730,7 +730,7 @@ public function getBit($ordinal)
730
730
*/
731
731
private function doGetBitBin ($ ordinal )
732
732
{
733
- return (ord ($ this ->bitset [(int ) ($ ordinal / 8 )]) & 1 << ($ ordinal % 8 )) !== 0 ;
733
+ return (\ ord ($ this ->bitset [(int ) ($ ordinal / 8 )]) & 1 << ($ ordinal % 8 )) !== 0 ;
734
734
}
735
735
736
736
/**
@@ -785,7 +785,7 @@ public function setBit($ordinal, $bit)
785
785
private function doSetBitBin ($ ordinal )
786
786
{
787
787
$ byte = (int ) ($ ordinal / 8 );
788
- $ this ->bitset [$ byte ] = $ this ->bitset [$ byte ] | chr (1 << ($ ordinal % 8 ));
788
+ $ this ->bitset [$ byte ] = $ this ->bitset [$ byte ] | \ chr (1 << ($ ordinal % 8 ));
789
789
}
790
790
791
791
/**
@@ -816,7 +816,7 @@ private function doSetBitInt($ordinal)
816
816
private function doUnsetBitBin ($ ordinal )
817
817
{
818
818
$ byte = (int ) ($ ordinal / 8 );
819
- $ this ->bitset [$ byte ] = $ this ->bitset [$ byte ] & chr (~(1 << ($ ordinal % 8 )));
819
+ $ this ->bitset [$ byte ] = $ this ->bitset [$ byte ] & \ chr (~(1 << ($ ordinal % 8 )));
820
820
}
821
821
822
822
/**
0 commit comments