@@ -307,6 +307,9 @@ private function movePropertyGroup( PropertyId $propertyId, $toIndex ) {
307307
308308 $ oldIndex = $ this ->getPropertyGroupIndex ( $ propertyId );
309309 $ byIdClone = $ this ->byId ;
310+ if ( $ byIdClone === null ) {
311+ throw new RuntimeException ( 'LogicError - index should have been built ' );
312+ }
310313
311314 // Remove "property group" to calculate the groups new index:
312315 unset( $ this ->byId [$ propertyId ->getSerialization ()] );
@@ -432,7 +435,7 @@ public function addObjectAtIndex( $object, $index = null ) {
432435 if ( count ( $ this ) === 0 ) {
433436 // Array is empty, just append object.
434437 $ this ->append ( $ object );
435- } elseif ( empty ( $ validIndices ) ) {
438+ } elseif ( $ validIndices === [] ) {
436439 // No objects featuring that property exist. The object may be inserted at a place
437440 // between existing "property groups".
438441 $ this ->append ( $ object );
@@ -461,7 +464,7 @@ private function addObjectToPropertyGroup( $object, $index = null ) {
461464 $ propertyId = $ object ->getPropertyId ();
462465 $ validIndices = $ this ->getFlatArrayIndices ( $ propertyId );
463466
464- if ( empty ( $ validIndices ) ) {
467+ if ( $ validIndices === [] ) {
465468 throw new OutOfBoundsException ( 'No objects featuring the object \'s property exist ' );
466469 }
467470
@@ -473,6 +476,10 @@ private function addObjectToPropertyGroup( $object, $index = null ) {
473476 $ index = end ( $ validIndices );
474477 }
475478
479+ if ( $ this ->byId === null ) {
480+ throw new RuntimeException ( 'LogicError - index should have been built ' );
481+ }
482+
476483 if ( in_array ( $ index , $ validIndices ) ) {
477484 // Add object at index within "property group".
478485 $ this ->byId [$ propertyId ->getSerialization ()][] = $ object ;
0 commit comments