Skip to content

Migrate Annotations to Attributes #308

Description

@homersimpsons

PHP Ecosystem is migrating from Annotations to Attributes. TDBM will follow this migration in the next major release, a rough plan is laid out below.

Annotations to attributes

The general idea is to store attributes (instead of annotations) in database comments (columns[methods] / tables[classes]).

We are okay to treat any comment line starting with #[ as an expected php attribute. We could also imagine that we stick to the @ in database. Serialization of the attribute content could work as-is in \TheCodingMachine\FluidSchema\Comment::addAnnotation

Providing a migration script for existing database comments is not in scope, but we may share one.

thecodingmachine/tdbm

  • Migrate \TheCodingMachine\TDBM\Utils\Annotation\AddInterface (and the like) to attributes
  • Migrate \TheCodingMachine\TDBM\Utils\Annotation\AnnotationParser to parse attributes
    • Here the path to parse attribute is not yes entirely specified, options are:
      1. eval + reflection: the generation process is rather scoped, that should do the trick
      2. token_get_all: it might be tedious, especially to create the attribute instance
      3. nikic/PHP-parser or roave/better-reflection: ideally we would avoid relying on external library for this
  • Update relevant documentation

Relevant parts of the code:

  • \TheCodingMachine\TDBM\Utils\ForeignKeyAnalyzerTrait::getAnnotations (and callers)

Potential blockers:

thecodingmachine/tdbm-fluid-schema-builder

TODO

Relevant parts of the code:

  • \TheCodingMachine\FluidSchema\Comment

thecodingmachine/tdbm-graphql

TODO

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions