Is there a way to redefine a type hint to a descendant class when extending an abstract class?
<p>I will be using the following example to illustrate my question:</p>

<pre><code>class Attribute {}

class SimpleAttribute extends Attribute {}



abstract class AbstractFactory {
    abstract public function update(Attribute $attr, $data);
}

class SimpleFactory extends AbstractFactory {
   public function update(SimpleAttribute $attr, $data);

}
</code></pre>

<p>If you try to run this, PHP will throw a fatal error, saying that the <code>Declaration of SimpleFactory::update() must be compatible with that of AbstractFactory::update()</code></p>

<p>I understand exactly what this means: That <code>SimpleFactory::update()</code>s method signature must exactly match that of its parent abstract class. </p>

<p>However, my question: Is there any way to allow the concrete method (in this case, <code>SimpleFactory::update()</code>) to redefine the type hint to a valid descendant of the original hint?</p>

<p>An example would be the <code>instanceof</code> operator, which would return true in the following case:</p>

<pre><code>SimpleAttribute instanceof Attribute // =&gt; true
</code></pre>

<p>I do realize that as a work around, I could make the type hint the same in the concrete method, and do an instanceof check in the method body itself, but is there a way to simply enforce this at the signature level?</p>
