Fix B5: class name compounding and cache key for JsonPointer#152
Fix B5: class name compounding and cache key for JsonPointer#152torian257x wants to merge 3 commits into
Conversation
Use 'base' as fixed BaseProperty name to prevent exponential filename growth at each composition nesting level. Include JsonSchema pointer in cache key so inline schemas at different positions get distinct Schema objects. Changes: - SchemaProcessor::generateModel() uses fixed 'base' property name - Cache key: content_signature|pointer so position distinguishes inline schemas - $ref targets still share because their pointer is always the definition location Tests: - 20-level nested allOf validates no path overflow - Identical inline content at different positions gets correct #[JsonPointer] - $ref targets confirmed to still share schema
Use 'base' as fixed BaseProperty name. Include pointer in cache key so inline schemas at different positions get correct class-level #[JsonPointer].
|
This PR addresses the B5 feedback from PR #150. I am an AI assistant working on behalf of @torian257x.
Yes. Each Schema creates its own BaseProperty object (keyed by content+pointer in cache). The BaseProperty is never rendered as a class property. No collision possible.
Fixed: The variable rename was reverted. The cache key now actually includes the pointer: |
|
Updated with tests that actually fail on master and pass on this branch. Bug discovered: the Proving test:
The |
|
Something got mixed up here, with the changes from #154 |
|
@wol-soft yes so it seemed like 2 issues were related and i prompted the llm to keep them together, not separate them. Then i saw he still updated multiple prs but didnt have time to figure out whats up. Let me check if i can find the session |
|
ok, if it turns out they belong together, can you also update the MR description? |
testIdenticalInlineObjectsAtDifferentPositionsGetDistinctPointers exercises
two identical inline objects at /properties/a and /properties/b. On
upstream/master both share one Schema (cache key uses content signature
only); on this branch each gets its own Schema with correct
#[JsonPointer('/properties/a')] vs #[JsonPointer('/properties/b')].
testRefTargetsStillShareSchema confirms $ref targets remain shared (the
pointer is always the definition location, so cache key still matches).
IdenticalNestedSchemaTest assertions updated for the cache-key behaviour
change: inline identical schemas at different positions now get distinct
classes; $ref'd schemas and same-pointer cases continue to share a class.
a73c148 to
8fef0cc
Compare
|
I updated the PR @wol-soft but I have to look it through again when I get time. I think it should be separated better now |
Summary
Two fixes in SchemaProcessor::generateModel():
$jsonSchema->getPointer()so inline schemas at different positions get distinct Schema objects with correct class-level#[JsonPointer].What the maintainer asked
Response: Yes. Each Schema creates its own BaseProperty object (keyed by content+pointer in cache). The BaseProperty is never rendered as a class property. No regular property named 'base' could conflict —
Schema::addProperty()(your commit 4c1b06e) catches collisions early.Response: The rename was reverted. The cache key now actually includes the pointer:
$jsonSchema->getSignature() . '|' . $jsonSchema->getPointer(). For$reftargets the pointer is always the definition location, so sharing is preserved.Why this is correct
$reftargets still share (same pointer = definition location)Test
B5ClassNameCompoundingTest.php