diff --git a/modules/contrib/entity_embed/src/Form/EntityEmbedDialog.php b/modules/contrib/entity_embed/src/Form/EntityEmbedDialog.php
index 66633c1f7..4e965dc68 100644
--- a/modules/contrib/entity_embed/src/Form/EntityEmbedDialog.php
+++ b/modules/contrib/entity_embed/src/Form/EntityEmbedDialog.php
@@ -424,7 +424,7 @@ public function buildEmbedStep(array $form, FormStateInterface $form_state) {
       else {
         $entity_label = '<a href="' . $entity->toUrl()->toString() . '" target="_blank">' . $entity->label() . '</a>';
       }
-      if(count($entity_element['data-entity-ids']) > 0) {
+      if(count((array) $entity_element['data-entity-ids']) > 0) {
         $entity_label = '';
         foreach($entity_element['data-entity-ids'] as $i => $entity_id) {
           $multiEntity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->load($entity_id);
@@ -434,7 +434,7 @@ public function buildEmbedStep(array $form, FormStateInterface $form_state) {
     }
     catch (\Exception $e) {
       $entity_label = $entity->label();
-      if(count($entity_element['data-entity-ids']) > 0) {
+      if(count((array) $entity_element['data-entity-ids']) > 0) {
         $entity_label = '';
         foreach($entity_element['data-entity-ids'] as $i => $entity_id) {
           $multiEntity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->load($entity_id);
@@ -496,7 +496,7 @@ public function buildEmbedStep(array $form, FormStateInterface $form_state) {
         'effect' => 'fade',
       ],
       // Hide the selection if only one option is available.
-      '#access' => count($display_plugin_options) > 1,
+      '#access' => count((array) $display_plugin_options) > 1,
     ];
     $form['attributes']['data-entity-embed-display-settings'] = [
       '#type' => 'container',
@@ -604,10 +604,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
   public function validateSelectStep(array $form, FormStateInterface $form_state) {
     $multipleEntities = array();
     if ($form_state->hasValue(['entity_browser', 'entities'])) {
-      if (count($form_state->getValue(['entity_browser', 'entities'])) > 0) {
+      if (count((array) $form_state->getValue(['entity_browser', 'entities'])) > 0) {
         $id = $form_state->getValue(['entity_browser', 'entities', 0])->id();
       }
-      if (count($form_state->getValue(['entity_browser', 'entities'])) > 1) {
+      if (count((array) $form_state->getValue(['entity_browser', 'entities'])) > 1) {
         foreach($form_state->getValue(['entity_browser', 'entities']) as $form_entity) {
           $multipleEntities[] = $form_entity->id();
         }
@@ -632,7 +632,7 @@ public function validateSelectStep(array $form, FormStateInterface $form_state)
       else {
         if ($uuid = $entity->uuid()) {
           $form_state->setValueForElement($form['attributes']['data-entity-uuid'], $uuid);
-          if(count($multipleEntities) > 0) {
+          if(count((array) $multipleEntities) > 0) {
             $form_state->setValueForElement($form['attributes']['data-entity-ids'], $multipleEntities);
           }
         }
