tags:

views:

234

answers:

1

Using PHP 5.3.0.

I know you can get errors pointing to line 0 when executing code from the shell (with php -a or php -r). I also know you can get line 0 errors when an exception is thrown during the process of executing a custom exception handler. These are logical reasons why PHP might not be able to provide me with a line number for an error. But now I'm getting line 0 errors even though I'm not doing either of those other two things. This sort of thing:

Fatal error: Call to a member function items() on a non-object in /Users/ole/pap/gtd/fu/lib/tree.php on line 0

I'm not asking for help debugging my code here just for the reason why PHP might not be giving me a proper line number for these errors. Anyway, that last error turned out to actually be on line 237 (just a simple case of not variable spelt incorrectly).

So what I did was deliberately reintroduced the error and put in a call to debug_print_backtrace(). Here's what I got:

#0  FuTreeSerializer->serialize(FuLinkedTreeNodeList Object ([outer] => ,[items] => Array ([0] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => bar,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => zim,[next] => ,[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => ,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[1] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => bar,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => zim,[next] => ,[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ( *RECURSION*,[prev] => ,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[2] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => zim,[next] => ,[prev] => FuTreeNode Object ( *RECURSION*,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => bar,[next] => FuTreeNode Object ( *RECURSION*,[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ( *RECURSION*,[prev] => ,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[3] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => zim,[next] => ,[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ( *RECURSION*,[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => bar,[next] => FuTreeNode Object ( *RECURSION*,[prev] => FuTreeNode Object ([outer] => ,[inners] => FuLinkedTreeNodeList Object ([outer] => FuTreeNode Object ( *RECURSION*,[items] => Array ()),[value] => foo,[next] => FuTreeNode Object ( *RECURSION*,[prev] => ,[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*),[ofList] => FuLinkedTreeNodeList Object ( *RECURSION*))), -1) called at [/Users/ole/pap/gtd/fu/lib/tree.php:128]
#1  FuLinkedTreeNodeList->asStr() called at [/Users/ole/pap/gtd/fu/spec/tree.php:52]
#2  FuTreeNodeSpec->_select()
#3  ReflectionMethod->invoke(FuTreeNodeSpec Object ([methodPatterns] => Array ([run] => /^_/,[skip] => /^skip/i),[specCallTrace] => Array ([0] => Array ([function] => __call,[class] => PweVerifierInjecter,[object] => PweVerifierInjecter Object ([spec] => FuTreeNodeSpec Object ( *RECURSION*,[subj] => 1),[type] => ->,[args] => Array ([0] => shouldBe,[1] => Array ([0] => 1))),[1] => Array ([file] => /Users/ole/pap/gtd/fu/spec/tree.php,[line] => 47,[function] => shouldBe,[class] => PweVerifierInjecter,[object] => PweVerifierInjecter Object ([spec] => FuTreeNodeSpec Object ( *RECURSION*,[subj] => 1),[type] => ->,[args] => Array ([0] => 1)),[2] => Array ([function] => _list_equality,[class] => FuTreeNodeSpec,[object] => FuTreeNodeSpec Object ( *RECURSION*,[type] => ->,[args] => Array ()),[3] => Array ([file] => /Users/ole/pap/gtd/fu/lib/pwe.php,[line] => 187,[function] => invoke,[class] => ReflectionMethod,[object] => ReflectionMethod Object ([name] => _list_equality,[class] => FuTreeNodeSpec),[type] => ->,[args] => Array ([0] => FuTreeNodeSpec Object ( *RECURSION*)),[4] => Array ([file] => /Users/ole/pap/gtd/fu/lib/pwe.php,[line] => 192,[function] => each,[class] => PweSpec,[object] => FuTreeNodeSpec Object ( *RECURSION*,[type] => ->,[args] => Array ([0] => ReflectionMethod Object ([name] => _list_equality,[class] => FuTreeNodeSpec))),[5] => Array ([file] => /Users/ole/pap/gtd/fu/lib/pwe.php,[line] => 207,[function] => runMethods,[class] => PweSpec,[object] => FuTreeNodeSpec Object ( *RECURSION*,[type] => ->,[args] => Array ()),[6] => Array ([file] => /Users/ole/pap/gtd/fu/lib/pwe.php,[line] => 35,[function] => run,[class] => PweSpec,[object] => FuTreeNodeSpec Object ( *RECURSION*,[type] => ->,[args] => Array ([0] => PweTracker Object ([passes] => 33,[failures] => 0,[skips] => 0))),[7] => Array ([file] => /Users/ole/pap/gtd/fu/-,[line] => 4,[function] => runDefined,[class] => PweRunner,[object] => PweRunner Object ([specPattern] => /Spec$/i),[type] => ->,[args] => Array ())),[tracker] => PweTracker Object ([passes] => 33,[failures] => 0,[skips] => 0),[activeMethod] => ReflectionMethod Object ([name] => _select,[class] => FuTreeNodeSpec))) called at [/Users/ole/pap/gtd/fu/lib/pwe.php:187]
#4  PweSpec->each(ReflectionMethod Object ([name] => _select,[class] => FuTreeNodeSpec)) called at [/Users/ole/pap/gtd/fu/lib/pwe.php:192]
#5  PweSpec->runMethods() called at [/Users/ole/pap/gtd/fu/lib/pwe.php:207]
#6  PweSpec->run(PweTracker Object ([passes] => 33,[failures] => 0,[skips] => 0)) called at [/Users/ole/pap/gtd/fu/lib/pwe.php:35]
#7  PweRunner->runDefined() called at [/Users/ole/pap/gtd/fu/-:4]

If you scroll to the right there you'll see that there's loads of recursion my data structures (this is to be expected with the code I'm working on). But otherwise this isn't a particularly long stack.

After a google around I managed to find some guy's error log who seems to have the same problem.

I tried searching for information about this on PHP bugs but the search system isn't powerful enough to allow me to search for "on line 0" without wanting to omit some of the terms; important ones.

+2  A: 

Since it seems I am unable to add a comment I will comment here. You say it is vanilla php, but if there are libraries then it's possible they are overloading the error message and an error's taking place in the error handling code, otherwise, unique problem, to zero in I would try to make intentional errors through the code and see when and where it stops properly reporting. Tedious I know but it can/will let you zero in on the answer.

Chisum
Thanks Chisum, you could be on to something. I might try some stuff now.
Ollie Saunders
Sure thing, just let me know how it works out :) Quite curious myself.
Chisum
Ever figure it out? I don't know if this is worthy of an answer award rofl but trying to clean up my answers ;)
Chisum