nonDbFakerStub on items with ref#112
Merged
Merged
Conversation
cebe
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: FK faker detection, JSONB sub-property key derivation, and allOf handling
1. FK detection via
attribute->referenceinstead of_idsuffix (FakerStubResolver.php)The
_id-suffix heuristic generated invalid PHP for JSONB sub-properties with a$ref(e.g.
payment_method→payment_method_id, butattribute->referencewas empty →\common\models\::find()).Now uses
!empty($this->attribute->reference)— set only when an actual$ref/allOf[$ref]resolves to a model.Before (workaround — plain integer, no
$ref, FK relation not expressed in spec):After (correct —
$refused directly, keypayment_method_idderived automatically):Also works with
allOf(e.g. to add a description):2. New private
resolveElement()— correct key derivation for JSONB sub-properties (FakerStubResolver.php)fakeForObject()used the raw spec property name as key. FK sub-properties now go throughresolveElement(), which runsAttributeResolver→Attribute::asReference()— the same_idsuffix logic as for top-level FK columns. Returns bothcolumnNameandfakerStub.aElementFaker()delegates to it.Using the YAML from point 1, the generated faker code is:
3.
fakeForObjectdepth default: 1 → 0;reindentArrayMapForObjectline shift fixed (FakerStubResolver.php)Default
1caused wrong indentation for top-level object attributes. Now0;fakeForArrayexplicitly passes
1.reindentArrayMapForObjectnow shifts all continuation lines (not justthe first), and
}, range(1, n)is written on one line.4.
allOfhandling:elseifchain → independentifblocks (PropertySchema.php)The
elseifchain applied only the first matching optional attribute from anallOfentry.Four independent
ifblocks now apply all present attributes in one pass.