Conversation
This function can convert an array of paths into an array of Mapping objects by reflecting on declared classes, just as the AnnotationDriver does.
[ci skip] [skip ci]
|
|
||
| $mappings = []; | ||
| $declared = get_declared_classes(); | ||
| foreach ($declared as $className) { |
There was a problem hiding this comment.
@patrickbrouwers moved inner loop outside the $paths loop, so it recursively iterates all paths, then iterates over declared classes once.
| foreach ($declared as $className) { | ||
| $rc = new ReflectionClass($className); | ||
| $sourceFile = $rc->getFileName(); | ||
| if ($sourceFile === false || !array_key_exists($sourceFile, $includedFiles)) { |
There was a problem hiding this comment.
@patrickbrouwers switched to key check instead of in_array. Had to use the boolean check to avoid php native classes crashing the array_key_exists check.
| "gedmo/doctrine-extensions": "^2.4" | ||
| }, | ||
| "autoload": { | ||
| "files": ["src/helpers.php"], |
There was a problem hiding this comment.
@patrickbrouwers there's no other way to load functions, right? I couldn't find documentation of namespaced functions in composer docs.
Oh, this probably breaks in php 5.5, so we should bump anyway.
There was a problem hiding this comment.
Commited bump in here so travis doesn't fail on phpunit run.
| { | ||
| $includedFiles = []; | ||
|
|
||
| foreach ($paths as $path) { |
There was a problem hiding this comment.
@patrickbrouwers I'm pretty sure we should be able to replace this loop with another iterator, so that we iterate recursively over each path, instead of building the full iterator chain for each path in the array.
|
@guiwoda Any reason why this wasn't merged? |
This PR adds a function that can convert an array of paths into an array of Mapping objects by reflecting on declared classes, just as the AnnotationDriver does.
The FluentDriver API is almost unchanged. To support receiving already-instanced Mapping objects, the
addMappingmethods had to be relaxed. Took the opportunity to refactor that relaxation to the lowest-level method, but this could be rolled back if BC matters.We are debating between this and #48 😄