EntityReferenceItem

Drupal 8: Looping through EntityReferenceItem(s) / EntityReferenceRevisionsItem(s) to get Target Entities is wrong

I just had the case to iterate over EntityReferenceRevisionsItem's which are similar to EntityReferenceItem to get the target entities,

My code snippet was (WRONG EXAMPLE):

  1. $subParagraphsER = $paragraph->get('field_paragraphs_paragraphs');
  2. foreach ($subParagraphsER as $subParagraph) {
  3. ...
  4. }