Skip to content

fix: regenerate stale class definitions dictionary (uninitialized $visibility)#1182

Open
hamidreza2005 wants to merge 1 commit into
dedoc:mainfrom
hamidreza2005:main
Open

fix: regenerate stale class definitions dictionary (uninitialized $visibility)#1182
hamidreza2005 wants to merge 1 commit into
dedoc:mainfrom
hamidreza2005:main

Conversation

@hamidreza2005

Copy link
Copy Markdown

Problem

Analyzing routes that return plain objects fails on a fresh build:

Typed property Dedoc\Scramble\Infer\Definition\ClassPropertyDefinition::$visibility must not be accessed before initialization
src/Support/TypeToSchemaExtensions/PlainObjectToSchema.php:112

scramble:clear + scramble:export and scramble:cache all throw, so it is unrelated to the document cache from #1178.

Root cause

ScrambleServiceProvider unserializes the shipped dictionaries/classMap.php into the Index on every boot. That dictionary was generated before $visibility, $isStatic, $attributes and $declaringFileName were added to ClassPropertyDefinition, so its blobs only contain two properties:

...ClassPropertyDefinition":2:{s:4:"type";...s:11:"defaultType";N;}

unserialize() does not call the constructor, so the promoted readonly defaults are never applied and $visibility stays uninitialized. The first access — PlainObjectToSchema.php:112 — then fatals.

Fix

Regenerate dictionaries/classMap.php via dictionaries/scripts/generate.php. The blobs now carry every property (ClassPropertyDefinition":8, visibility present) 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.

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