beberlei / assert

Thin assertion library for use in libraries and business-model
Other
2.41k stars 188 forks source link

@aliasOf annotation error #251

Closed koutsoumposval closed 6 years ago

koutsoumposval commented 6 years ago

@aliaOf annotation in inArray method causing the failing error

Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@aliasOf" in method Assert\Assertion::inArray() was never imported. Did you maybe forget to add a "use" statement for this annotation?

Removing the annotation seems to work. Should we remove it? Is there another workaround?

rquadling commented 6 years ago

What is generating the error you are seeing?

koutsoumposval commented 6 years ago

As far as I can debug it, it seems to be caused from the doctrine/annotations package:

lib/Doctrine/Common/Annotations/DocParser.php at lines 661 and line 725 so it is not exactly an error but an incompatibility with Doctrine DocParser.

The initial command that triggers this error is bin console translation:extract (JMSTranslationBundle). I don't think that is relevant to this, I think docParser is responsible.

I felt like putting it here in order to see if anyone else faced it, because those 2 packages are widely used together. I haven't found anything about @aliasOf annotation for php, my IDE (php storm) is also complaining.

rquadling commented 6 years ago

I'm using PhpStorm 2018.1.1. No complaint with @aliasof.

A couple of suggestions.

  1. Change to * @aliasOf \Assert\Assertion::choice()
  2. Remove the @aliasof completely but make sure there's an @see.
koutsoumposval commented 6 years ago

I think no 2 is the actual fix. I can confirm that it solves the problem. A @see already exists.

rquadling commented 6 years ago

Can you try option 1 as the method name is sort of incorrect as this is not a function called choice(), but a method called \Assert\Assertion::choice().

rquadling commented 6 years ago

We use @aliasof in our documentation generation, so if it can stay, then that would be good. If not, the PR would need to amend bin/generate_method_docs.php accordingly.

koutsoumposval commented 6 years ago

@aliasOf \Assert\Assertion::choice() doesn't seem to solve the problem. I already tried it. I will look into and amend bin/generate_method_docs.php accordingly. If anyone has a workaround I would be very happy to hear.

rquadling commented 6 years ago

Thank you.