Fix B4: PropertyProxy attribute inheritance via merge getAttributes()#151
Fix B4: PropertyProxy attribute inheritance via merge getAttributes()#151torian257x wants to merge 1 commit into
Conversation
PropertyProxy now merges its local attributes with the underlying property's attributes via getAttributes(). When the same FQCN is in both, local wins. This replaces the previous approach of enumerating attribute types in processReference(), which missed ReadOnly/WriteOnly/Deprecated and would miss any future attribute types added by PostProcessors. Changes: - PropertyProxy::getAttributes() - new merge method - PropertyFactory::processReference() - only set SchemaName on proxy; all other attributes inherit via merge - AttributesTrait: $phpAttributes visibility private->protected so PropertyProxy can access the local attribute list
|
This PR addresses the B4 feedback from PR #150. I am an AI assistant working on behalf of @torian257x.
Approach: PropertyProxy::getAttributes() now merges local proxy attributes with the underlying property's attributes via a generic merge. When the same attribute FQCN appears in both lists, the proxy's local version wins. This covers ReadOnly, WriteOnly, Deprecated and any future attribute types automatically. The old approach (enumerating SchemaName, JsonPointer, Required in processReference()) was removed. SchemaName is still set per-instance on the proxy. Everything else inherits. Why correct: resolveReference() includes $required in its cache key, so different requiredness produces separate Properties (never a proxy). Inherited Required is always correct. |
Summary
PropertyProxy now merges its local attributes with the underlying property's attributes via
getAttributes()instead of enumerating attribute types inprocessReference(). When the same FQCN appears in both lists, the proxy's local version wins (SchemaName, JsonPointer). All other attributes (Required, ReadOnly, WriteOnly, Deprecated) are inherited from the underlying.What the maintainer asked
Response: The previous approach enumerated attribute types for explicit overwrite on the proxy. This missed ReadOnly, WriteOnly, and Deprecated. The new
PropertyProxy::getAttributes()merge covers ALL attribute types generically. PostProcessors that add attributes to the underlying property (now or in the future) will automatically appear on the proxy. Local wins: SchemaName and JsonPointer are set per-instance. Everything else inherits.Why this is correct
resolveReference()includes$requiredin its cache key. Different requiredness → different keys → separate Properties, never a proxy. Inherited Required is always correct.getAttributes()calls the underlying Property which is never a Proxy.getAttributes()is only called during rendering (long after).Changes
$phpAttributesvisibility private→protectedTest
B4PropertyProxyAttributeTest.php