Skip to content

Conversation

@falkenhawk
Copy link
Member

@falkenhawk falkenhawk commented Apr 27, 2019

  • adds possibility to disable features which are not used
  • useAnnotations(boolean) toggle on autowire() helper to enable/disable reading annotations on specific definitions
  • default behaviour does not change (backwards compatibility)

Available flags for $builder->useAnnotations(true, $flags):

  • AnnotationBasedAutowiring::ALL - all annotations enabled (default)
  • AnnotationBasedAutowiring::IMPLICIT - enable on implicit definitions (not specified in container config)
  • AnnotationBasedAutowiring::EXPLICIT - enable on all autowire definitions (which are written in DI config) by default
  • AnnotationBasedAutowiring::INJECTABLE - read @Injectable annotations for classes
  • AnnotationBasedAutowiring::PROPERTIES - read @Inject annotations for properties
  • AnnotationBasedAutowiring::METHODS - read @Inject annotations for methods' parameters

We are using the following combination of options:

$builder = new DI\ContainerBuilder();
$builder->useAnnotations(true, AnnotationBasedAutowiring::IMPLICIT | AnnotationBasedAutowiring::PROPERTIES);

It that case it means that:

  1. Annotations will be read when a class is not explicitly defined in definitions file
  2. annotations will be disabled by default for classes defined in definitions file, autowire()->useAnnotations() to enable annotations
  3. @Injectable is skipped for performance
  4. @Inject on properties will be read only when annotations are enabled for an entry (either on implicit definitions or explicit with useAnnotations())
  5. @Inject on methods will be skipped for performance - as we don't use them

@falkenhawk falkenhawk requested a review from a team April 27, 2019 20:25
@falkenhawk falkenhawk self-assigned this Apr 27, 2019
- adds possibility to disable features which are not used
- useAnnotations(boolean) toggle on autowire() helper to enable/disable reading annotations on specific definitions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant