schmittjoh / serializer

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

Fix - change the order of instantiation checks #1513

Closed rossriley closed 9 months ago

rossriley commented 10 months ago
Q A
Bug fix? yes
New feature? no
Doc updated no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1512
License MIT

Fix for issue described in #1512 all this does is rearrange the resolution logic so when a type is described as eg:

@var Product

The resolution order now will be:

  1. Look for a class in the current namespace called Product
  2. Parse the use statements and look for a class defined as Namespace\Example\Product
  3. Finally fallback to a class or interface defined in the global namespace \Product

Currently steps 1 and 3 are reversed and that effectively means that a precisely defined class is ignored in favour of a more loosely specified one.

scyzoryck commented 10 months ago

Just in case Coding Standards / Coding Standards (7.2) (pull_request) - fails also on master, so it will be fixed in separate PR :) Could you also add some test to make sure that this logic will be not lost in the future?

Best, scyzoryck.

goetas commented 9 months ago

@dgafka can you please have look here?

goetas commented 9 months ago

@rossriley could you please add a test?

dgafka commented 9 months ago

Ye, looks like an edge case with fine fix :)