Skip to content

Conversation

@mtarld
Copy link
Contributor

@mtarld mtarld commented Oct 14, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

This PR adds the support for virtual synthetic properties, which are basically values that are computed thanks to property metadata loaders only.
This could be useful for projects that are generating highly dynamic object shape, such as API Platform.

/cc @soyuka

@soyuka
Copy link
Contributor

soyuka commented Oct 17, 2025

Really great improvement, this is quite painful for now in API Platform as we use id everywhere and sometimes the property doesn't exist.

@mtarld mtarld force-pushed the feat/json-streamer-virtual-property branch from 27c57e0 to 2b9f9d1 Compare October 17, 2025 13:06
@chalasr
Copy link
Member

chalasr commented Oct 17, 2025

From https://www.php.net/manual/en/language.oop5.property-hooks.php

A property may be "backed" or "virtual". [...] A virtual property is one that has hooks and those hooks do not interact with the property itself. In this case, the hooks are effectively the same as methods, and the object does not use any space to store a value for that property.

Should we find another name?

@stof
Copy link
Member

stof commented Oct 17, 2025

The reason for the name is actually similar to the reason in property hooks (a JsonStreamer property that is either backed by a PHP property or not). But it might indeed cause confusion, especially when the 2 different layers are closely tied to each other.
I don't have an idea for a good alternate name though.

@GromNaN
Copy link
Member

GromNaN commented Oct 17, 2025

"synthetic" means that it is created from nothing, or from transforming other things.

@chalasr
Copy link
Member

chalasr commented Oct 17, 2025

I like it.

@mtarld mtarld force-pushed the feat/json-streamer-virtual-property branch from 2b9f9d1 to bb12653 Compare October 18, 2025 09:35
@mtarld mtarld changed the title [JsonStreamer] Add virtual properties support [JsonStreamer] Add synthetic properties support Oct 18, 2025
@mtarld
Copy link
Contributor Author

mtarld commented Oct 18, 2025

Updated with the synthetic name instead. It's a nice name, I like it as well, thanks for the review.

@GromNaN
Copy link
Member

GromNaN commented Oct 22, 2025

Thank you @mtarld.

@GromNaN GromNaN merged commit 742d742 into symfony:7.4 Oct 22, 2025
12 checks passed
@mtarld mtarld deleted the feat/json-streamer-virtual-property branch October 22, 2025 09:15
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants