DDC-1247: Implement AnnotationDriver::addExcludePath #176

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
7 participants

This pull request passes (merged 664e2496 into 329d90a).

lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
@@ -191,6 +218,12 @@ public function getAllClassNames()
foreach ($iterator as $file) {
$sourceFile = realpath($file[0]);
+ foreach ($this->excludePaths as $dir) {
+ if (strpos($sourceFile, realpath($dir)) !== FALSE) {
@stof

stof Aug 27, 2012

Member

false should be written lowercased

Member

stof commented Aug 27, 2012

I would normalize the directory separators to / before comparing, so that the config does not need to be changed on windows just because of the string comparison (the config would always use /).

And please add some tests for this feature

This pull request passes (merged 9393cbc8 into 329d90a).

Contributor

Vrtak-CZ commented Aug 27, 2012

I've wanned to write tests, but I haven't found any existing for this class, so I've decided not to write any, because I don't know how to test it.

This pull request passes (merged 01b34d7 into 329d90a).

Member

stof commented Aug 27, 2012

hmm, indeed, others driver are tested but not this one.

Btw, the same feature should probably be added in the StaticPHPDriver

Any updates on this? Would like to see this merged into master, it's very annoying having Doctrine complain about annotations you don't even need.

@@ -191,6 +218,14 @@ public function getAllClassNames()
foreach ($iterator as $file) {
$sourceFile = realpath($file[0]);
+ foreach ($this->excludePaths as $excludePath) {
+ $exclude = str_replace('\\', '/', realpath($excludePath));
@Ocramius

Ocramius Nov 8, 2012

Owner

@stof are you sure these replacements are required? He's using realpath anyway...

@stof

stof Nov 8, 2012

Member

Well, there is an issue here: realpath will return false if you excludePath does not exist, and this will then break things for the check

+ foreach ($this->excludePaths as $excludePath) {
+ $exclude = str_replace('\\', '/', realpath($excludePath));
+ $current = str_replace('\\', '/', $sourceFile);
+ if (strpos($current, $exclude) !== false) {
@Ocramius

Ocramius Nov 8, 2012

Owner

@Vrtak-CZ missing empty newline before if

Owner

beberlei commented Feb 3, 2014

Merged into master

@beberlei beberlei closed this Feb 3, 2014

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment