original_string: protected function guardType($items) : void {
          // this allows guardType($items) to receive
          // both a single item or an array of items
          if ( ! is_array($items)) {
              $items = array($items);
          }
  
          // throw an exception if any items are not
          // an instance of the required type
          foreach ($items as $item) {
              if ( ! $item instanceof $this->collectionType) {
                  throw new \InvalidArgumentException(
                      "Got " . (is_object($item) ? get_class($item) : $item) . " but expected " . $this->collectionType
                  );
              }
          }
      }
code: protected function guardType($items) : void {
          // this allows guardType($items) to receive
          // both a single item or an array of items
          if ( ! is_array($items)) {
              $items = array($items);
          }
  
          // throw an exception if any items are not
          // an instance of the required type
          foreach ($items as $item) {
              if ( ! $item instanceof $this->collectionType) {
                  throw new \InvalidArgumentException(
                      "Got " . (is_object($item) ? get_class($item) : $item) . " but expected " . $this->collectionType
                  );
              }
          }
      }
code_tokens: protected function guardType ( $ items ) : void { // this allows guardType($items) to receive // both a single item or an array of items if ( ! is_array ( $ items ) ) { $ items = array ( $ items ) ; } // throw an exception if any items are not // an instance of the required type foreach ( $ items as $ item ) { if ( ! $ item instanceof $ this -> collectionType ) { throw new \ InvalidArgumentException ( "Got " . ( is_object ( $ item ) ? get_class ( $ item ) : $ item ) . " but expected " . $ this -> collectionType ) ; } } }
docstring: ensure that items added to the collection conform to
  the defined collection type
  
  @param $items
docstring_tokens: ensure that items added to the collection conform to the defined collection type