Reputation: 1026
I've come across a very strange problem in a Laravel 4 application I'm building, although this question pertains more to PHP than Laravel: PHP is complaining that these methods are incompatible when both interface & class methods have exactly the same signature.
It should only complain if, for instance, the incorrect type hint is used, or there are an inconsistent number of arguments, but for some reason this is complaining when everything is done right. I can't see anyone else who has had this problem, can anyone see anything I'm not seeing?
The interface:
<?php
namespace Repository;
interface TillRepositoryInterface {
public static function allInVenue(Venue $venue);
public static function findByIdInVenue(Venue $venue);
}
The repository class that implements the interface:
<?php
class TillRepository extends BaseRepository implements Repository\TillRepositoryInterface {
public static function allInVenue(Venue $venue)
{
}
public static function findByIdInVenue(Venue $venue)
{
}
}
Upvotes: 2
Views: 3682
Reputation: 1026
Seems seconds after posting the question my brain switched on:
It was the fact that I was using a namespace in the interface, so (Venue $venue)
was actually (Repository\Venue $venue)
. Simply changing this:
public static function allInVenue(Venue $venue);
public static function findByIdInVenue(Venue $venue);
To this
public static function allInVenue(\Venue $venue);
public static function findByIdInVenue(\Venue $venue);
Solved the issue. Keeping this up in case anyone else stumbles across the same mistake, to avoid headaches
Upvotes: 11