for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Knp\Rad\AutoRegistration\Reflection;
use ReflectionClass;
class ClassAnalyzer
{
/**
* @param string $class
*
* @return bool Return TRUE if class don't have constructor (or without required parameter) and if class is not abstract, FALSE else
*/
public function canBeConstructed($class)
$class = $this->buildReflection($class);
if ($class->isInterface()) {
return false;
}
if ($class->isAbstract()) {
if (null === $constuctor = $class->getConstructor()) {
return true;
return 0 === $constuctor->getNumberOfRequiredParameters();
* @param string|ReflectionClass $class
* @return ReflectionClass
ReflectionClass|null
This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.
@return
private function buildReflection($class)
if (true === $class instanceof ReflectionClass) {
return $class;
if (true === class_exists($class)) {
return new ReflectionClass($class);
return;
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.