schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 589 forks source link

"Can't use incorrect type integer for collection" on PHPDoc-typed integer, boolean or double #1489

Closed outtersg closed 1 year ago

outtersg commented 1 year ago
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

Steps required to reproduce the problem

  1. Have the DocBlockTypeResolver activated (infer_types_from_doc_block: true)
  2. Have a Doctrine entity with an member attribute that is:
    • typed with PHPDoc (@var integer) as an integer (not int)
    • computed, not persistent (no ORM mapping)
    • serializable (@Serializer annotations, for e.g. Groups or SerializedName; but no type, for which we rely on PHPDoc)
  3. Try to generate metadata cache

Expected Result

Actual Result

Cause

isPrimitiveType() does not know the alternative, long names that are part of PHPDoc: integer, boolean, double. As such it avoids all kind of typing in DoctrineTypeDriver::setType() and ends considering those members as a collection (= behaviour for anything not being detected as a primitive, scalar, type).

scyzoryck commented 1 year ago

Fixed 3.26.0 :)