File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ final public static function getByOrdinal($ordinal)
222222 $ class = get_called_class ();
223223 $ constants = self ::detectConstants ($ class );
224224 $ item = array_slice ($ constants , $ ordinal , 1 , true );
225- if (! $ item ) {
225+ if (empty ( $ item) ) {
226226 throw new InvalidArgumentException (sprintf (
227227 'Invalid ordinal number, must between 0 and %s ' ,
228228 count ($ constants ) - 1
@@ -292,7 +292,7 @@ private static function detectConstants($class)
292292 $ ambiguous [var_export ($ value , true )] = $ names ;
293293 }
294294 }
295- if ($ ambiguous ) {
295+ if (! empty ( $ ambiguous) ) {
296296 throw new LogicException (
297297 'All possible values needs to be unique. The following are ambiguous: '
298298 . implode (', ' , array_map (function ($ names ) use ($ constants ) {
Original file line number Diff line number Diff line change @@ -111,9 +111,10 @@ public function testGetEnumerators()
111111 {
112112 $ constants = EnumInheritance::getConstants ();
113113 $ enumerators = EnumInheritance::getEnumerators ();
114+ $ count = count ($ enumerators );
114115
115- $ this ->assertSame (count ($ constants ), count ( $ enumerators ) );
116- for ($ i = 0 ; $ i < count ( $ enumerators ) ; ++$ i ) {
116+ $ this ->assertSame (count ($ constants ), $ count );
117+ for ($ i = 0 ; $ i < $ count ; ++$ i ) {
117118 $ this ->assertArrayHasKey ($ i , $ enumerators );
118119 $ this ->assertInstanceOf ('MabeEnumTest\TestAsset\EnumInheritance ' , $ enumerators [$ i ]);
119120
You can’t perform that action at this time.
0 commit comments