Annotated methods that are implemented using PHP magic methods are not recognized by "hasMethod".
<?php
class SomeClass
{
public function __call($name, $arguments)
{
echo "this is magic method: $name.\n";
}
public function codedMethod()
{
echo "this is coded method.\n";
}
}
$obj = new \SomeClass();
$obj->codedMethod();
$obj->annotatedMethod();
$ref = new ReflectionClass(\SomeClass::class);
echo "SomeClass has 'codedMethod': " . json_encode($ref->hasMethod('codedMethod')) . ".\n";
echo "SomeClass has 'annotatedMethod': " . json_encode($ref->hasMethod('annotatedMethod')) . ".\n";
?>
Output:
this is coded method.
this is magic method: annotatedMethod.
SomeClass has 'codedMethod': true.
SomeClass has 'annotatedMethod': false.