• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wol-soft / php-json-schema-model-generator / 23453430579

23 Mar 2026 06:23PM UTC coverage: 98.58% (-0.02%) from 98.604%
23453430579

push

github

Enno Woortmann
Fix issue #98: wrong type hint and broken validation for nested object properties with anyOf/oneOf

When a nested object property has anyOf/oneOf whose branches add only constraints
(required, minProperties, maxProperties, patternProperties) rather than new named
properties, two bugs manifested:

1. The getter @return annotation referenced a generated _Merged_ class instead of
   the correct nested object class.
2. Valid inputs were wrongly rejected by an AnyOfException thrown at the parent
   schema level.

Root cause: AbstractPropertyProcessor::addComposedValueValidator was called for
non-root type:object properties, producing a duplicate composition validator at
the parent level. By the time this validator runs, the property value is already
an instantiated object, so branch instanceof checks against branch-specific classes
fail. It also injected the _Merged_ class name as a type hint decorator, overriding
the correct type set by ObjectProcessor.

Fix 1: Skip addComposedValueValidator entirely for non-root type:object properties.
ObjectProcessor already handles composition inside the nested schema via processSchema
with rootLevelComposition=true, so the parent-level duplication is unnecessary.

Fix 2: CompositionValidationPostProcessor was conditionally skipping method generation
when composition branches had no named properties (e.g. minProperties/maxProperties
branches). The validateComposition_N call was still emitted by the template, causing
a fatal "call to undefined method" error at runtime. The post-processor now always
generates validation methods for all composition validators in baseValidators, and
only skips setter-hook wiring when there are no trackable properties.

9 of 10 new or added lines in 2 files covered. (90.0%)

3889 of 3945 relevant lines covered (98.58%)

553.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.57
/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc