1
0
mirror of synced 2025-01-31 04:21:44 +03:00

fixed code duplication issue

This commit is contained in:
Adam Prager 2013-03-31 00:47:24 +01:00
parent 9797177193
commit 937ba6385e

View File

@ -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
*