title: PHP Object could not be converted to int
body: <p>I just upgraded from PHP 5.3 to PHP 5.5 and I'm facing a warning that I didn't get before when casting an Object to a int using the __toString() method.</p>
  
  <p>The sample code is</p>
  
  <pre><code>&lt;?php
  
  class MyObject {
      protected $_id;
      public function setId($id) { $this-&gt;_id = $id; }
      public function __toString() { return (string)$this-&gt;_id; }
  }
  
  $e = new MyObject();
  $e-&gt;setId("50");
  if($e == "50") echo "50 == 50 as String\n";
  else echo "50 !== 50 as String\n";
  
  $e-&gt;setId(50);
  if($e == 50) echo "50 == 50 as Integer\n";
  else echo "50 !== 50 as Integer\n";
  
  $e-&gt;setId("50");
  if($e == 50) echo "50 == 50 as String = Integer\n";
  else echo "50 !== 50 as String = Integer\n";
  
  $e-&gt;setId(50);
  if($e == "50") echo "50 == 50 as Integer = String\n";
  else echo "50 !== 50 as Integer = String\n";
  </code></pre>
  
  <p>The output in my server is</p>
  
  <pre><code>50 == 50 as String
  50 !== 50 as Integer
  50 !== 50 as String = Integer
  50 == 50 as Integer = String
  </code></pre>
  
  <p>While I was expecting all of them to be true. The notices I get while running it are:</p>
  
  <pre><code>Object of class MyObject could not be converted to int
  </code></pre>
  
  <p>They are triggered by the lines that contain the code</p>
  
  <pre><code>($e == 50)
  </code></pre>
  
  <p>It's this intended? Is there any variable I can set in the PHP ini to make it work differently?
  Do I just need to learn to deal with it and review all my code that may use Objects as Integers in some codes?</p>