Skip to content

Commit

Permalink
Add TypedFieldMapper for automatic mapping of typed PHP fields to DBA…
Browse files Browse the repository at this point in the history
…L types (doctrine#10313)

Previously, only a predefined set of automatic mappings was allowed, such as int, float, boolean, DateTime etc.
With this extension, it is possible to supply custom TypedFieldMapper implementation which takes as parameter the ReflectionProperty of a given field and decides the appropriate mapping.
A new configuration option was added to set and get the TypedFieldMapper.
The old logic was moved into a class DefaultTypedFieldMapper which is used by default when no mapper is supplied.
The selected TypedFieldMapper is passed into ClassMetadataInfo constructor. If empty, the DefaultTypedFieldMapper is used.
There is also ChainTypedFieldMapper class which allows chaining multiple TypedFieldMappers and apply them in a cascade (always if a field gets type assigned by the earlier mapper in the list, it will not be changed later).
  • Loading branch information
michnovka authored and n-e-m-a-nj-a committed Jan 27, 2023
1 parent a24c43e commit 652c531
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,11 @@
<code>strrpos($className, '\\')</code>
</PossiblyFalseOperand>
</file>
<file src="lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php">
<PropertyTypeCoercion occurrences="1">
<code>array_merge(self::DEFAULT_TYPED_FIELD_MAPPINGS, $typedFieldMappings)</code>
</PropertyTypeCoercion>
</file>
<file src="lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php">
<DeprecatedMethod>
<code>canEmulateSchemas</code>
Expand Down

0 comments on commit 652c531

Please sign in to comment.