-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7774Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
<?php
use JMS\Serializer\Annotation as JMS;
final class DemoFile
{
#[JMS\Type('DoctrineDocumentReference')]
protected $dynamicRef;
}Responsible rules
ObjectTypedPropertyFromJMSSerializerAttributeTypeRector
Expected Behavior
Rector should only replace the property type with DoctrineDocumentReference, if that class can actually be resolved.
I our project we have a custom JMS Subscribing Handler that defines the JMS type and returns a dynamic type (based on what has been serialized before).
Sample code:
class DoctrineReferenceHandler implements SubscribingHandlerInterface
{
private const CLASS_FIELD = 'class';
private const ID_FIELD = 'id';
public static function getSubscribingMethods(): array
{
return [
[
'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION,
'format' => 'json',
'type' => 'DoctrineDocumentReference',
'method' => 'serialize',
],
[
'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION,
'format' => 'json',
'type' => 'DoctrineDocumentReference',
'method' => 'deserialize',
],
];
}
// ...
}