public function isValid($name)
{
if (parent::isValid($name)) {
return true;
}
if (is_array($name)) {
list($cls, $method) = $name;
if (is_object($cls)) {
return false;
// No need to convert
}
if (is_array($method)) {
return true;
// Need to convert
}
} elseif (is_string($name) && strpos($name, '::') > 0) {
list($cls, $method) = explode('::', $name);
} else {
return false;
// Can't handle this, maybe already callable
}
if (isset($this->classmap[$cls])) {
return true;
// Will use service definition
}
if (!class_exists($cls) || !method_exists($cls, $method)) {
return false;
// Can't handle this
}
$refMethod = new \ReflectionMethod($cls, $method);
if ($refMethod->isStatic()) {
return false;
// Already valid
}
$constructor = $refMethod->getDeclaringClass()->getConstructor();
// We can create the class if no constructor params, else can't handle it
return $constructor === null || $constructor->getNumberOfRequiredParameters() === 0;
}