fzaninotto/Faker — Issue #23: Faker uses methods named the same as the class name
Author: chrismsnz
Created: 2011-11-24 22:33:59+00:00
State: open

Hi

I'm currently working on using Faker for a project using PHP 5.3.2 and I'm running into an issue.

According to [this documentation on PHP's constructor](http://nz.php.net/__construct#example-170), PHP versions < 5.3.3 will use a method named the same as a class if it can not find a `__construct` method in that class.

This is an issue with Faker as most of the providers have a method in them with the same name as the class, which will cause these versions of PHP to call the method. e.g. the `Faker\Provider\Address` class has an `address()` method. It leads to errors such as:

```PHP Fatal error: Call to a member function parse() on a non-object in faker/src/Faker/Provider/Address.php on line 91```

Defining a `__construct` method that just calls the parent constructor works, but throws a PHP strict standards notice:

```PHP Strict Standards: Redefining already defined constructor for class Faker\Provider\Address in faker/src/Faker/Provider/Address.php on line 93```

Is there a solution that allows you to keep your architecture but ignores this php backwards compatibility shim?

Cheers,
Chris.