Suppose you have this:
<?php
interface Type
{}
class SomeType implements Type
{}
class SomeOtherType implements Type
{}
Now, if you have an abstract class with an interface Typeas a constructor dependency, for example:
<?php
abstract class TypeUser
{
public function __construct(Type $type)
{}
}
Why PHP allows you to overload the constructor on specific classes as follows:
<?php
class SomeTypeUser extends TypeUser
{
public function __construct(SomeType $type)
{}
}
class SomeOtherTypeUser extends TypeUser
{
public function __construct(SomeOtherType $type)
{}
}
But this does not allow you to do the same for methods, only constructors - if you try to do this using non-constructor methods, does PHP throw an error Strict standards?
source
share