title: PHP Fatal error: Call to a member function getId() on null - its supposed to be null (sometimes), how to handle correctly?
body: <p>Sometimes the expected result should be null, other times it's not (if it's not null, I want code function x to parse. If not null, code y parses).. not sure how to handle this appropriately:</p>
  
  <pre><code>$myID = is_object($widget-&gt;getParent()-&gt;getId()) ? $widget-&gt;getParent()-&gt;getId() : '';
  
  if (isset($myID)){
  //....code here
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>PHP Fatal error:  Call to a member function getId() on null in \htdocs\program\widget\Controller\WidgetController.php on line 212
  </code></pre>
  
  <p>Line 212:</p>
  
  <pre><code>$myID = is_object($widget-&gt;getParent()-&gt;getId()) ? $widget-&gt;getParent()-&gt;getId() : '';
  </code></pre>
  
  <p>I've also tried variations of:
      <code>is_object()</code>
      <code>is_array()</code>
      <code>null ==</code>
      <code>null !==</code></p>
  
  <p>None seem to allow the code to process as expected.</p>