PHP duplicate function name gives no errors

I had a very simple service class to perform some tasks:

class SomeService {
public function doSomething(){}

While adding some other functions, I was copy-and-pasting the doSomething(){} structure, and then renaming the new functions. I apparently forgot to rename one of the functions, and left it as doSomething(){}, which meant I had two functions with the same name.

This Service is being tested using SimpleTest framework for Unit Tests, and when running the tests via the browser, I saw nothing but a blank page. I searched through the PHP logs, nothing. Apache logs? Nothing.

After doing some debugging, I eventually narrowed it down to the SomeService class, which I promptly commented out everything, and I at least was able to see failures in my Unit Tests. After adding the functions back one by one, it become obvious of my goof, and once I removed the duplicate name all of my test passed again.

That was a few hours down the drain that could have been avoided with an extremely simple error message.

About the Author


View Posts →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.