Feature/doctrine annotations#1681
Conversation
- Added doctrine/common dependency to composer.json - Updated travis configuration to ensure dependencies from composer are installed before running tests (suggested by ocramius) - Modified test autoloader to use composer + StandardAutoloader
- Listener that receives an event with: - class - content - raw - If class is registered with this parser, passes the raw string to the Doctrine\Common DocParser in order to retrieve an annotation object
- AnnotationManager now:
- Composes an EventManager
- createAnnotation() triggers the createAnnotation event, passing an
event with "class", "content", and "raw" parameters representing the
annotation requested. First listener to return an object halts the
event, and that object is returned.
- AnnotationScanner adds a third element to the $annotation array
representing the "raw" annotation. This array is then passed to
createAnnotation(), and if a non-false value is returned, appended to
the collection.
- Added GenericAnnotationParser, which operates in the style originally
posited by Ralph.
- Created ParserInterface
- defines onCreateAnnotation(), registerAnnotation(), and
registerAnnotations()
- refactored GenericAnnotationParser and DoctrineAnnotationParser to
follow above interface; removed constructor from
GenericAnnotationParser, and made registerAnnotation accept string
class names.
- Added attach() method to AnnotationManager; allows attaching a parser
instance to the createAnnotation event.
- Added tests for GenericAnnotationParser and DoctrineAnnotationParser - Modified AnnotationManager tests to test a mixed annotation situation - Discovered an issue with DoctrineAnnotationParser; needed to provide a loader to AnnotationRegistry that attempts to autoload an annotation class in order for the functionality to work with namespaced annotation classes.
- Modified setAnnotationManager() to create a DoctrineAnnotationParser instance and seed it with the ZF form annotation classes - Removed AbstractAnnotation - Created AbstractStringAnnotation and AbstractArrayAnnotation to handle basic validation of annotation values - Refactored all annotation classes to use constructor-based initialization - Fixed tests to demonstrate Doctrine-style annotation syntax
…tions
- Modified createDefaultAnnotationManager()
- creates a GenericAnnotationParser instance, and seeds it with the
Inject annotation
- attaches the GenericAnnotationParser to the created
AnnotationManager
- AnnotationScanner test was refactored to follow new AnnotationManger+Parser API - PropertyReflection test was refactored to follow new AnnotationManger+Parser API
- If composer autoloader is missing, simply use the standard autoloader
- Abstract annotation implementations needed to import the Zend\Form\Exception namespace in order for exception classes to resolve
|
Current build status: http://travis-ci.org/#!/weierophinney/zf2/builds/1738713 -- passing. |
There was a problem hiding this comment.
I was thinking that after the meeting and the discussions doctrine/commont won't be a requirement for zf2
There was a problem hiding this comment.
We have to put it here for the repo itself, as it's a dependency for one of the components. For the packages we build, it will be a requirement on packages for Zend\Code only (and by extension, and components depending on it).
There was a problem hiding this comment.
I think that "suggest" is enough
There was a problem hiding this comment.
Changed to add "suggests" and "require-dev", and to move the dep out of "require".
- Marked doctrine/common via require-dev and suggests in composer.json - Updated travis config to pass --dev flag to composer - Added test constant flags to test configuration to skip annotation tests unless flag is true
There was a problem hiding this comment.
If $annotation is a string you already know the $class. I suggest treat this as an else of the first if
There was a problem hiding this comment.
Thanks for the suggestion; fixed now.
|
How is resolved when exists two annotations with the same name but provided by different applications? |
- Made CS changes suggested by Maks3w
|
@Maks3w re: 2 annotations with same name, provided by different applications -- not an issue. Annotations always are resolved to a fully qualified class name; within ZF2, we do this by expanding the annotation name based on the import statements and namespace defined in the class file. Doctrine does similarly, but has additional mechanisms. |
|
Any hints on how to install the Doctrine dependency, so that I can run the unit tests? |
|
@akrabat Using composer run "php composer.phar install --dev" |
This PR does several things: