Open
Description
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:
- introduce TypeInterface with required methods (or different name)
- make types implement it
- 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)
- 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)
- make TypeRegistry work with type instances instead of their class names (sounds good, but unsure about consequences)
- 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
- 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
- In 3.0, deprecate proxy methods from
Type
ToTypeRegistry
in favor of using theTypeRegistry
directly. - 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
)