1
0
mirror of synced 2025-02-07 07:49:27 +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,17 +710,11 @@ 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) {
foreach ($this->getTraits($metadata) as $trait) {
if ($trait->hasProperty($property)) {
return true;
}
}
}
}
return (
isset($this->staticReflection[$metadata->name]) &&
@ -746,17 +740,11 @@ 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) {
foreach ($this->getTraits($metadata) as $trait) {
if ($trait->hasMethod($method)) {
return true;
}
}
}
}
return (
isset($this->staticReflection[$metadata->name]) &&
@ -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
*