1414use Doctrine \Common \Annotations \AnnotationException ;
1515use PhpParser \Node ;
1616use PhpParser \NodeVisitor ;
17+ use Symfony \Component \Validator \Mapping \ClassMetadata ;
1718use Translation \Extractor \Model \SourceLocation ;
1819use Translation \Extractor \Visitor \Php \BasePHPVisitor ;
1920use Symfony \Component \Validator \Mapping \Factory \MetadataFactoryInterface ;
20- use Symfony \Component \Validator \MetadataFactoryInterface as LegacyMetadataFactoryInterface ;
2121
2222/**
2323 * @author Tobias Nyholm <[email protected] > 2424 */
2525final class ValidationAnnotation extends BasePHPVisitor implements NodeVisitor
2626{
2727 /**
28- * @var MetadataFactoryInterface|LegacyMetadataFactoryInterface
28+ * @var MetadataFactoryInterface
2929 */
3030 private $ metadataFactory ;
3131
@@ -37,16 +37,10 @@ final class ValidationAnnotation extends BasePHPVisitor implements NodeVisitor
3737 /**
3838 * ValidationExtractor constructor.
3939 *
40- * @param MetadataFactoryInterface|LegacyMetadataFactoryInterface $metadataFactory
40+ * @param MetadataFactoryInterface $metadataFactory
4141 */
42- public function __construct ($ metadataFactory )
42+ public function __construct (MetadataFactoryInterface $ metadataFactory )
4343 {
44- if (!(
45- $ metadataFactory instanceof MetadataFactoryInterface
46- || $ metadataFactory instanceof LegacyMetadataFactoryInterface
47- )) {
48- throw new \InvalidArgumentException (sprintf ('%s expects an instance of MetadataFactoryInterface ' , get_class ($ this )));
49- }
5044 $ this ->metadataFactory = $ metadataFactory ;
5145 }
5246
@@ -77,6 +71,7 @@ public function enterNode(Node $node)
7771 }
7872
7973 try {
74+ /** @var ClassMetadata $metadata */
8075 $ metadata = $ this ->metadataFactory ->getMetadataFor ($ name );
8176 } catch (AnnotationException $ e ) {
8277 $ this ->addError ($ node , 'Could not parse class "%s" for annotations. %s ' , $ this ->namespace , $ e ->getMessage ());
0 commit comments