On my local development machine (php 5.3.14) I can use a class like this:
<?php
namespace Shop\Repository;
use Shop\Entity\Day;
use Doctrine\ORM\EntityRepository;
class Product extends EntityRepository
{
// Code
}
The class is stored in /my/src/Shop/Repository/Product.php (PSR-0 compliant). I have also a Shop\Repository\Day located at /my/src/Shop/Repository/Day.php.
However, on my staging server (php 5.3.10) I get the following error:
PHP Fatal error: Cannot use Shop\Entity\Day as Day because the name is already in use in /my/src/Shop/Repository/Product.php on line 5
I can understand the message, if I alias my Shop\Entity\Day import to DayEntity, the code works. But I cannot understand the cause of the fatal error: why does this work on php 5.3.14 (or at least, with my configuration) and not with 5.3.10 (or at least, with the server’s configuration)?
I guess the problem is because in the namespace Shop\Repository there is already a Day loaded. But this has never lead to errors in my setup! What’s going on?
Here are some explanation I grabbed about this situation:
So you should try with get_included_files() to see on your server and station what are the differents because the order to load them is important
Those explanation are linked from this nice post which was commented by dmitry
Hope this could help