Hacker News new | ask | show | jobs
by Vendan 4070 days ago

  Fatal error: Argument 1 passed to myLog() must be of the type string, integer given, called in /home/vagrant/basic/main.php on line 9 and defined in /home/vagrant/basic/main.php on line 4
"HHVM says the error occurred on line 6 where PHP says it occurred on line 9. I prefer HHVM's approach here as it shows us where we called the function with the bad data, not where the function is defined that we are calling with bad data."

Hrm, PHP is telling you both line 4 and line 9, as where the function is defined and where it's being called with bad data, which is quite nice. In comparison, HHVM is saying line 6, which is a closing brace for the myLog function. In my books, PHP's approach is way way better then HHVM's

1 comments

It's hard to say what is better - oftentimes when you see a large stack trace for an error, it can be difficult to determine where the offending line is, especially on first glance. Personally, I think I agree with the author, but PHP 7 does look to give more information, which can be better in some situations.
However in this case line 6 is not the problem in any way (as the grandparent is saying). Looks like a bug in the error reporting?
Hmm, perhaps the opcode has the wrong line number attached to it. A bug report could be filed for that, probably a trivial fix.
I disagree - even if hack was reporting the correct line number it's only half the story, and is objectively worse for fixing the error.
Part of the point is that the article is just dead wrong. "I prefer HHVM's approach here as it shows us where we called the function with the bad data". HHVM says line 6, which is the end of the function, not where the function was called. In fact, they go on to state "not where the function is defined that we are calling with bad data." while still having said "PHP says it occurred on line 9" But line 9 IS where the function was called with bad data. The article misinterpreted the 2 errors...