diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 61c697f62..21d033e7e 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -125,22 +125,27 @@ class ProxyFactory * @param string $toDir The target directory of the proxy classes. If not specified, the * directory configured on the Configuration of the EntityManager used * by this factory is used. + * @return int Number of generated proxies. */ public function generateProxyClasses(array $classes, $toDir = null) { $proxyDir = $toDir ?: $this->_proxyDir; $proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR); + $num = 0; foreach ($classes as $class) { /* @var $class ClassMetadata */ - if ($class->isMappedSuperclass) { + if ($class->isMappedSuperclass || $class->reflClass->isAbstract()) { continue; } $proxyFileName = $this->getProxyFileName($class->name, $proxyDir); $this->_generateProxyClass($class, $proxyFileName, self::$_proxyClassTemplate); + $num++; } + + return $num; } /** diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php index ace2bb57b..894d500fe 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php @@ -155,6 +155,20 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals(1, substr_count($classCode, 'function __sleep')); } + /** + * @group DDC-1771 + */ + public function testSkipAbstractClassesOnGeneration() + { + $cm = new \Doctrine\ORM\Mapping\ClassMetadata(__NAMESPACE__ . '\\AbstractClass'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->assertNotNull($cm->reflClass); + + $num = $this->_proxyFactory->generateProxyClasses(array($cm)); + + $this->assertEquals(0, $num, "No proxies generated."); + } + public function testNoConfigDir_ThrowsException() { $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); @@ -183,3 +197,8 @@ class SleepClass return array('id'); } } + +abstract class AbstractClass +{ + +}