fixed code duplication issue
This commit is contained in:
parent
9797177193
commit
937ba6385e
@ -710,15 +710,9 @@ public function __construct()
|
||||
}
|
||||
|
||||
// check traits for existing property
|
||||
if (class_exists($metadata->name)) {
|
||||
$reflClass = new \ReflectionClass($metadata->name);
|
||||
|
||||
if (method_exists($reflClass, 'getTraits')) {
|
||||
foreach ($reflClass->getTraits() as $trait) {
|
||||
if ($trait->hasProperty($property)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->getTraits($metadata) as $trait) {
|
||||
if ($trait->hasProperty($property)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,15 +740,9 @@ public function __construct()
|
||||
}
|
||||
|
||||
// check traits for existing method
|
||||
if (class_exists($metadata->name)) {
|
||||
$reflClass = new \ReflectionClass($metadata->name);
|
||||
|
||||
if (method_exists($reflClass, 'getTraits')) {
|
||||
foreach ($reflClass->getTraits() as $trait) {
|
||||
if ($trait->hasMethod($method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->getTraits($metadata) as $trait) {
|
||||
if ($trait->hasMethod($method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -764,6 +752,26 @@ public function __construct()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMetadataInfo $metadata
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTraits(ClassMetadataInfo $metadata)
|
||||
{
|
||||
if ($metadata->reflClass != null || class_exists($metadata->name)) {
|
||||
$reflClass = $metadata->reflClass == null
|
||||
? new \ReflectionClass($metadata->name)
|
||||
: $metadata->reflClass;
|
||||
|
||||
if (method_exists($reflClass, 'getTraits')) {
|
||||
return $reflClass->getTraits();
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMetadataInfo $metadata
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user