Skip to content

Refactor type system #2841

Open
Open
@greg0ire

Description

@greg0ire

Goals

  • use FQCNs instead of strings to identify types
  • have people implement one or more interfaces depending on their needs, instead of forcing them to use inheritance
  • move as much code as possible out of the abstract type (and ideally remove it completely)

Todo

From @Majkl578 on slack:

just a quick thought of a possible approach:

  1. introduce TypeInterface with required methods (or different name)
  2. make types implement it
  3. introduce some kind of Types enum-like empty class for implictly supported types, just like i.e. GeneratorType in ORM develop (edit: maybe this could stay in Type to lower BC implications and make Type an enum class in 3.0)
  4. introduce non-static TypeRegistry with no default types hardcoded in it - this would allow different connections/platforms use different type mappings (as @Ocramius suggested in https://symfony-devs.slack.com/archives/C3FQPE6LE/p1504362019000073)
  5. make TypeRegistry work with type instances instead of their class names (sounds good, but unsure about consequences)
  6. migrate Type:: to Types enum, keep BC by aliasing them and deprecate in 2,7 Extract constants for built-in types from Type to Types #3356
  7. migrate Type:: mechanics to TypeRegistry, keep BC by using private static TypeRegistry internally in 2.7 (some kittens may die during this process) Extract type factory and registry from Type into TypeRegistry #3354
  8. In 3.0, deprecate proxy methods from Type To TypeRegistry in favor of using the TypeRegistry directly.
  9. in 4.0 drop these BC hacks (so no more kittens die)

My thoughts:
Instead of introducing an ISP-violating TypeInterface rightaway, split it from the start into small interfaces, which should make canRequireSQLConversion and requiresSQLCommentHint irrelevant. Here is such an interface, please give me some feedback. Also, get rid of the methods that we do not really need like __toString or (getName)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions