Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Add AnnotationTransformer to allow configuration through PHP docblock annotations #35

Conversation

ScopeyNZ
Copy link

@ScopeyNZ ScopeyNZ commented May 23, 2019

Adds AnnotationTransformer which taks a list of classes and an array of AnnotationDefinitionInterfaces that can parse annotations in doc blocks and convert them into configuration.

This bumps PHP dependency to 7.1 in line with recent core trends and takes advantage of strict typing in new code.

@ScopeyNZ ScopeyNZ force-pushed the pulls/1.2/annotation-collector branch from fdefdd3 to b95de83 Compare May 23, 2019 23:25
Copy link
Contributor

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This RFC has been sitting dormant for a while now. I think if you mark each of the new APIs with @internal or something similar then we can merge it in and test it out before we publicise it as a new feature - since it has the potential to have quite an impact on how dependency injection is done in SilverStripe

/**
* AnnotationTransformer constructor.
* @param callable $classResolver
* @param array $annotationDefinitions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could annotate AnnotationDefinitionInterface[] here to make it clearer what is expected. Also worth adding a @throws for the exception if one of the entries isn't one of these interfaces

* @return MutableConfigCollectionInterface
* @throws \ReflectionException
*/
public function transform(MutableConfigCollectionInterface $collection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function transform(MutableConfigCollectionInterface $collection)
public function transform(MutableConfigCollectionInterface $collection): MutableConfigCollectionInterface

use ReflectionClass;
use ReflectionMethod;

interface AnnotationDefinitionInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a doc block to explain the purpose of classes implementing this interface

@emteknetnz
Copy link
Member

This pull request hasn't had any activity for a while. Are you going to be doing further work on it, or would you prefer to close it now?

@ScopeyNZ
Copy link
Author

ScopeyNZ commented Sep 1, 2020

I'm happy to work on it further if I get the indication it'll be merged 🙂 . This is part of a larger change request involving a couple of framework PRs:

silverstripe/silverstripe-framework#9006
silverstripe/silverstripe-framework#8564

@emteknetnz
Copy link
Member

emteknetnz commented Sep 8, 2020

I'd say pretty unlikely to be prioritized by Silverstripe CMS Squad at this stage because it doesn't seem to have an obvious benefit compared to something like fixing a bug. I could be totally wrong though. Would probably need to be a core committer thing. I've added the feedback-required/core-team label.

@ScopeyNZ
Copy link
Author

ScopeyNZ commented Sep 8, 2020

I'd argue that auto constructor DI is a pretty obvious benefit, but I understand that it's a bit abstract how this PR related to that feature. Anyway, I'm hoping that work/discussion on this PR is driven by silverstripe/silverstripe-framework#8564

@GuySartorelli
Copy link
Member

I'm going to close this - I think if we were to ever merge something like this today it would be using attributes rather than annotations

@GuySartorelli GuySartorelli deleted the pulls/1.2/annotation-collector branch December 14, 2023 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants