title: Illegal offset type in isset or empty Doctrine clear
body: <p>I search for hours to find solution for this problem but without luck.</p>
  
  <p>Maybe this is duplicate post, but I didn't find it.</p>
  
  <p>So, I have problem in <strong>Symfony's Service</strong>, when I call entity manager <code>clear($entityname)</code> method I got this error:</p>
  
  <pre><code>Warning: Illegal offset type in isset or empty.
  </code></pre>
  
  <p>I have no clue why this happening.</p>
  
  <p>If i comment <code>clear()</code> method, everything works fine.</p>
  
  <p>First I call <code>ProductController</code></p>
  
  <pre><code>public function postProductAction(Request $request)
  {
      if($jsonData = $this-&gt;requestToArray($request)){
          $productHandler = $this-&gt;get("admin.product_handler");
          $insertNews = $productHandler-&gt;insert($jsonData);
          if($insertNews === true) {
              return $this-&gt;jsonResponse-&gt;setData(array(
              "status" =&gt; true, "msg" =&gt; MessageConstants::SUCCESS_SEND_DATA));
          }
      }
      $this-&gt;jsonResponse-&gt;setStatusCode(204);
      return $this-&gt;jsonResponse-&gt;setData(
      array("status" =&gt; false, "msg" =&gt; MessageConstants::FAILED_RECEIVE_RESPONSE));
  }
  </code></pre>
  
  <p>Then call <code>ProductHandler</code> which set new product</p>
  
  <pre><code> $productRepo = new Products();
   $productRepo-&gt;setCarmodels(json_encode($data['ModelId']));
   $productRepo-&gt;setCategoryid($category);
   $productRepo-&gt;setDescription($data['Description']);
   $productRepo-&gt;setDiscount($data['Discount']);
   $productRepo-&gt;setDiscountprice($data['DiscountPrice']);
   $this-&gt;em-&gt;persist($productRepo);
   $this-&gt;em-&gt;flush($productRepo);
   $insertOther = $this-&gt;update($productRepo-&gt;getId(), $data);
   $this-&gt;em-&gt;clear($productRepo);
  </code></pre>
  
  <p><code>insertAnotfer</code> call update,because there is some action which require to get product id, so I need first to insert then do update.</p>
  
  <pre><code>$product = $productRepo-&gt;find((int)$id);
  $product-&gt;setCarmodels(json_encode($data['ModelId']));
  $product-&gt;setCategoryid($category);
  $product-&gt;setDescription($data['Description']);
  $product-&gt;setDiscount($data['Discount']);
  $product-&gt;setDiscountprice($data['DiscountPrice']);
  </code></pre>
  
  <p>In update I also call clear method</p>
  
  <pre><code>$this-&gt;em-&gt;flush($product);
  $this-&gt;em-&gt;clear($product);
  </code></pre>
  
  <p>And then I get this error. I tried to remove clear method from update but no luck. Error will not be trigger only if I set <code>clear()</code> method without entity in insert function.</p>