code: protected function adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
      {
          $aComments = $pSheet->getComments();
          $aNewComments = []; // the new array of all comments
  
          foreach ($aComments as $key => &$value) {
              // Any comments inside a deleted range will be ignored
              if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
                  // Otherwise build a new array of comments indexed by the adjusted cell reference
                  $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
                  $aNewComments[$newReference] = $value;
              }
          }
          //    Replace the comments array with the new set of comments
          $pSheet->setComments($aNewComments);
      }
docs: Update cell comments when inserting/deleting rows/columns.
  
  @param Worksheet $pSheet The worksheet that we're editing
  @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
  @param int $beforeColumnIndex Index number of the column we're inserting/deleting before
  @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
  @param int $beforeRow Number of the row we're inserting/deleting before
  @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)