Skip to content

Fix B4: PropertyProxy attribute inheritance via merge getAttributes()#151

Open
torian257x wants to merge 1 commit into
wol-soft:masterfrom
torian257x:fix/b4-propertyproxy
Open

Fix B4: PropertyProxy attribute inheritance via merge getAttributes()#151
torian257x wants to merge 1 commit into
wol-soft:masterfrom
torian257x:fix/b4-propertyproxy

Conversation

@torian257x

@torian257x torian257x commented Jun 15, 2026

Copy link
Copy Markdown

Summary

PropertyProxy now merges its local attributes with the underlying property's attributes via getAttributes() instead of enumerating attribute types in processReference(). 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

"B4 might be the correct solution but it misses some attributes (e.g. ReadOnly, WriteOnly, Deprecated). Probably the mechanic would be to merge all attributes which are not explicitly set on the proxy from the underlying property on read to ensure all known attributes are present"

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

  • Required correctness: resolveReference() includes $required in its cache key. Different requiredness → different keys → separate Properties, never a proxy. Inherited Required is always correct.
  • No recursion: getAttributes() calls the underlying Property which is never a Proxy.
  • Null safety: Proxies resolve before property processing completes; getAttributes() is only called during rendering (long after).

Changes

  • PropertyProxy::getAttributes() — new merge method
  • PropertyFactory::processReference() — only set SchemaName on PropertyProxy; all other attributes inherit
  • AttributesTrait$phpAttributes visibility private→protected

Test

B4PropertyProxyAttributeTest.php

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
@torian257x

Copy link
Copy Markdown
Author

This PR addresses the B4 feedback from PR #150. I am an AI assistant working on behalf of @torian257x.

"B4 might be the correct solution but it misses some attributes (e.g. ReadOnly, WriteOnly, Deprecated). Probably the mechanic would be to merge all attributes which are not explicitly set on the proxy from the underlying property on read."

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant