Issue Task Closed

#102263Return string version of Stringable objects in DataMapper::getPlainValue

Soren Malling 10/26/23, 09:39 updated 01/30/24, 08:30

Description

The DataMapper::getPlainValue expects a object to be a instance of TypeInterface in order to return a plain value.

The TypoInterface holds the `__toString` method – making it `a instance of Stringable`.

Objects/value objects coming from own extensions, not implementing the TypeInterface but being a `Stringable` (either by `implements \Stringable` or having the `__toString` method) throws the exception

`throw new UnexpectedTypeException(‘An object of class “’ . get_class($input) . ‘” could not be converted to a plain value.’, 1274799934);`

Suggestion here, being that the condition also allows a object being a stringable

From:
`if (TypeHandlingUtility::isCoreType($input)) {`

To:
`if (TypeHandlingUtility::isCoreType($input) || ($input instanceof \Stringable)) {`

Reviews 2

History 35

  1. Gerrit Code Review pushed patch set 1 for main to change 81576 status New Under Review 10/26/23, 09:55

  2. Oliver Hader changed category 10/26/23, 10:40

  3. Gerrit Code Review pushed patch set 1 for 12.4 to change 81579 10/26/23, 12:33

  4. Soren Malling commented and changed status Under Review Resolved done 0 % 100 % 10/26/23, 13:10

    Applied in changeset commit:d5043eb1214e40134f588eb16fe6174b0bee8984.

  5. Benni Mack changed status Resolved Closed 01/30/24, 08:30