This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Created attachment 144001 [details] screenshot Symfony2 allows the user to create custom validator classes and apply them as annotations: http://symfony.com/doc/current/cookbook/validation/custom_constraint.html Such custom annotations need to be imported into the current namespace via the "use" statement. However, the editor does not recognize these "use" statements as being used in the code. (See the attached screenshot.) I would have marked this as an enhancement, except for this problem: if I then use the "Fix use statements" keyboard shortcut, the "use" statements for my custom annotations are removed. If I don't notice and then try to validate the object, I get a fatal error because the annotation classes cannot be found!
And that custom validator classes physically exists? Do you have such classes in your project?
Created attachment 144417 [details] Custom type annotation parser Proposed fix, but not sure how is this change save...
(In reply to Ondrej Brejla from comment #1) > And that custom validator classes physically exists? Do you have such > classes in your project? Yes, I wrote those custom validator classes and they are part of the same project.
Ok, so I improved it a bit in the dev build. If you go to Options -> PHP -> Annotations, you can check "Treat Unknown Annotations as Type Annotations (e.g. Symfony2 Custom Validators)" and then *all* unknown (any other annotation parser knows 'em) annotations are resolved as Type annotations. So it will match use statements properly ;) Fixed in web-main #b8bf50621882
(In reply to Ondrej Brejla from comment #4) > Ok, so I improved it a bit in the dev build. If you go to Options -> PHP -> > Annotations, you can check "Treat Unknown Annotations as Type Annotations > (e.g. Symfony2 Custom Validators)" and then *all* unknown (any other > annotation parser knows 'em) annotations are resolved as Type annotations. > So it will match use statements properly ;) > > Fixed in web-main #b8bf50621882 Wow! Thanks for the fast turnaround on this. I presume that it will go live with the 8.0 release (based on the Target Milestone)?
You are welcome :) Exactly! You can of course try it in the dev build when QA posts here a comment that it was integrated.
Integrated into 'main-silver', will be available in build *201401290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/b8bf50621882 User: Ondrej Brejla <obrejla@netbeans.org> Log: #240512 - "use" statements for custom annotations are not recognized
As a side note I'll add that to keep use statements for whatever reasons, use @see docblock with type, ie: /** * @Validator(MyType) * @see MyType */ public $myProperty; This will keep use statement even after applying "Fix use statements"