fix: regenerate stale class definitions dictionary (uninitialized $visibility)#1182
Open
hamidreza2005 wants to merge 1 commit into
Open
fix: regenerate stale class definitions dictionary (uninitialized $visibility)#1182hamidreza2005 wants to merge 1 commit into
hamidreza2005 wants to merge 1 commit into
Conversation
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.
Problem
Analyzing routes that return plain objects fails on a fresh build:
scramble:clear+scramble:exportandscramble:cacheall throw, so it is unrelated to the document cache from #1178.Root cause
ScrambleServiceProviderunserializes the shippeddictionaries/classMap.phpinto theIndexon every boot. That dictionary was generated before$visibility,$isStatic,$attributesand$declaringFileNamewere added toClassPropertyDefinition, so its blobs only contain two properties:...ClassPropertyDefinition":2:{s:4:"type";...s:11:"defaultType";N;}
unserialize()does not call the constructor, so the promotedreadonlydefaults are never applied and$visibilitystays uninitialized. The first access —PlainObjectToSchema.php:112— then fatals.Fix
Regenerate
dictionaries/classMap.phpviadictionaries/scripts/generate.php. The blobs now carry every property (ClassPropertyDefinition":8,visibilitypresent) and deserialize into complete objects.Test
Added
tests/Infer/Definition/ClassPropertyDefinitionTest.php, which unserializes every shipped blob and asserts each property is accessible. It fails against the stale dictionary and passes after regeneration.