Commit 438efc5
committed
PHPC-1622: Use get_properties_for handler in ObjectId (prototype)
Replace the get_debug_info and get_properties handlers with a single
get_properties_for handler that dispatches by purpose:
- ZEND_PROP_PURPOSE_DEBUG, ARRAY_CAST, GET_OBJECT_VARS, VAR_EXPORT:
return a fresh temporary HashTable (no caching)
- ZEND_PROP_PURPOSE_SERIALIZE, JSON: return NULL, deferring to the
class's __serialize/__unserialize and JsonSerializable implementations
The get_properties handler is retained since foreach on non-Traversable
objects calls it directly, bypassing get_properties_for on all PHP
versions.
ZEND_PROP_PURPOSE_GET_OBJECT_VARS (added in PHP 8.4 as part of the
Property Hooks RFC) is guarded with #if PHP_VERSION_ID >= 80400; on
PHP 8.1-8.3 get_object_vars() reaches get_properties directly.
Add tests for the two previously untested purposes:
- bson-objectid-array_cast-001.phpt (ZEND_PROP_PURPOSE_ARRAY_CAST)
- bson-objectid-var_export-001.phpt (ZEND_PROP_PURPOSE_VAR_EXPORT)1 parent bb72111 commit 438efc5
File tree
3 files changed
+43
-8
lines changed- src/BSON
- tests/bson
3 files changed
+43
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | | - | |
258 | 257 | | |
259 | 258 | | |
260 | 259 | | |
| |||
269 | 268 | | |
270 | 269 | | |
271 | 270 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
278 | 277 | | |
279 | 278 | | |
280 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments