annotations icon indicating copy to clipboard operation
annotations copied to clipboard

Add Constants Support

Open jkufner opened this issue 5 years ago • 9 comments

Continuation of https://github.com/doctrine/annotations/pull/226. Original commits (excl. merges) cherry-picked onto 1.7 branch.

This pull request adds complete support for constant annotations. It should be the same as property annotations support.

All tests passing.

Example:

class SomeClass {
    /**
     * @SomeAnnotation
     */
    const SOME_CONSTANT = "foo";
}

$classRefl = new ClassReflection(SomeClass::class);
$constantRefl = $classRefl->getReflectionConstant('SOME_CONSTANT');
$annotations = $annotationReader->getConstantAnnotations($constantRefl);
// $annotations == [ new SomeAnnotation() ]

jkufner avatar Mar 27 '19 21:03 jkufner

I think something needs to be done about the commits. Please fixup commits that fix errors into commits that introduce them, and provide messages in english all the time.

greg0ire avatar Mar 27 '19 22:03 greg0ire

Ok, this should do the trick. I've also updated the pull request for 2.0 version (#264).

jkufner avatar Mar 28 '19 14:03 jkufner

I think new features for 1.x are out of question at this point when refactoring for 2.0 is already ongoing.

Majkl578 avatar Mar 28 '19 16:03 Majkl578

@Majkl578 Well, I've created two pull requests for both versions. So it can go to 1.7 and refactoring of this feature to 2.0 is already done.

The only differences are in Target enum instead of few constants and in removed readers. Moreover, I did not notice any changes in getMethodAnnotations() and getMethodAnnotation() methods, so I guess the refactoring didn't got too far to cause any troubles here.

jkufner avatar Mar 28 '19 18:03 jkufner

I think new features for 1.x are out of question at this point when refactoring for 2.0 is already ongoing.

Disagree: with how unclear the timeline for 2.0 is, it makes sense adding this to 1.x as well. I see no problem with releasing a final 1.x release at the same time as 2.0 is released, similar to how Symfony releases a minor release for the previous major along with a new major version.

alcaeus avatar Mar 29 '19 05:03 alcaeus

I've rebased the MR to the current master (v1.10.x). It seems to work fine as before :)

jkufner avatar May 03 '20 22:05 jkufner

@jkufner can you please fix the new conflicts?

greg0ire avatar Jan 01 '21 20:01 greg0ire

@greg0ire I've rebased it to the 1.12.x branch. I hope it still works, it's been a long time.

jkufner avatar Jan 04 '21 21:01 jkufner

I hope it still works, it's been a long time.

I'm afraid I have bad news for you :grimacing:

greg0ire avatar Jan 06 '21 21:01 greg0ire

Closing because we won't add new features to this library.

derrabus avatar Oct 05 '22 22:10 derrabus