title: How to get proper line number when using trigger_error in PHP?
body: <p>I am using trigger_error to "throw" errors in a custom class. My problem is that trigger_error prints out the line number where trigger_error was called. For example, given the following code:</p>
  
  <pre><code>01    &lt;?php
  02        class Test {
  03            function doAction() {
  04                $this-&gt;doSubAction();
  05            }
  06            
  07            function doSubAction() {
  08                if(true)
  09                    trigger_error('Custom error', E_USER_WARNING);
  10            }
  11        }
  12        
  13        $var = new Test();
  14        $var-&gt;doAction();
  15    ?&gt;
  </code></pre>
  
  <p>PHP will print out the following:</p>
  
  <blockquote>
    <p><strong>Warning:</strong> Custom error in <strong>test.php</strong> on line <strong>9</strong></p>
  </blockquote>
  
  <p>How would you make PHP return the line where the doAction() function was called (the method called outside the class, ignoring all calls made internally) as follows?</p>
  
  <blockquote>
    <p><strong>Warning:</strong> Custom error in <strong>test.php</strong> on line <strong>14</strong></p>
  </blockquote>
  
  <p><strong>Edit:</strong> Modified my example to be something a bit closer to what I'm trying to achieve.</p>