Skip to content

Commit 9a7e20e

Browse files
committed
[DCOM-204] Fix include of entities inside PHAR.
1 parent 86bfc84 commit 9a7e20e

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ public function getAllClassNames()
219219
);
220220

221221
foreach ($iterator as $file) {
222-
$sourceFile = realpath($file[0]);
222+
$sourceFile = $file[0];
223+
224+
if ( ! preg_match('(^phar:)i', $sourceFile)) {
225+
$sourceFile = realpath($sourceFile);
226+
}
223227

224228
foreach ($this->excludePaths as $excludePath) {
225229
$exclude = str_replace('\\', '/', realpath($excludePath));
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Doctrine\Tests\Common\Persistence\Mapping;
4+
5+
use Doctrine\Common\Annotations\AnnotationReader;
6+
use Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver;
7+
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
8+
9+
class AnnotationDriverTest extends \PHPUnit_Framework_TestCase
10+
{
11+
public function testGetAllClassNames()
12+
{
13+
$reader = new AnnotationReader();
14+
$driver = new SimpleAnnotationDriver($reader, array(__DIR__ . '/_files/annotation'));
15+
16+
$classes = $driver->getAllClassNames();
17+
18+
$this->assertEquals(array('Doctrine\TestClass'), $classes);
19+
}
20+
}
21+
22+
class SimpleAnnotationDriver extends AnnotationDriver
23+
{
24+
protected $entityAnnotationClasses = array('Doctrine\Entity' => true);
25+
26+
public function loadMetadataForClass($className, ClassMetadata $metadata)
27+
{
28+
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Doctrine;
4+
5+
/**
6+
* @Doctrine\Entity
7+
*/
8+
class TestClass
9+
{
10+
}
11+
12+
/**
13+
* @Annotation
14+
*/
15+
class Entity
16+
{
17+
}

0 commit comments

Comments
 (0)