@@ -83,9 +83,8 @@ it** — and they do so in subtly different ways:
8383
8484This is the package's sharpest trap: a piece of control state travelling through
8585the payload, replicated across five sites. Any new ` Schema ` element must reproduce
86- the strip-and-honor dance or merging silently misbehaves. (There is a standing
87- idea to replace it with a declarative ` MergeMode::Replace ` ; DI carries its own
88- parallel ` PREVENT_MERGING ` constant. See ` docs/local/ideas/odstranit-prevent-merging.md ` .)
86+ the strip-and-honor dance or merging silently misbehaves. (DI carries its own
87+ parallel ` PREVENT_MERGING ` constant.)
8988
9089## One transform pipeline; ` assert ` /` castTo ` are sugar over ` transform `
9190
@@ -181,13 +180,20 @@ by validating dynamics eagerly.
181180
182181## ` Expect::from() ` mapping rules
183182
184- ` Expect::from($object) ` reflects ** constructor parameters if ` __construct `
185- exists, otherwise properties** — a class with a constructor has its properties
186- ignored entirely. Per item: uninitialized property / non-optional parameter →
187- ` required() ` ; a ` null ` default on a type that does not accept null → also
188- ` required() ` (not "default null"); an ** object** default recurses into a nested
189- ` from() ` ; anything else becomes ` default($def) ` . The type comes from
190- ` Helpers::getPropertyType ` (native type, then ` @var ` ), falling back to ` mixed ` .
183+ ` Expect::from() ` accepts an instance ** or a class name** (since 2.0) and
184+ reflects ** constructor parameters if ` __construct ` exists, otherwise
185+ properties** — a class with a constructor has its properties ignored entirely.
186+ Types come from ** native declarations only** (` Nette\Utils\Type::fromReflection ` ,
187+ fallback ` mixed ` ); phpDoc ` @var ` support was removed in 2.0. Per item:
188+
189+ - a non-nullable class-typed item recurses into ` from($thatClass) ` ** even
190+ without a default** (beware: ` class_exists ` is also true for enums, which
191+ then map badly);
192+ - no default (uninitialized property / non-optional parameter) → ` required() ` ;
193+ - an ** object** default recurses into a nested ` from($default) ` (instance-based);
194+ - any other default — including ` null ` — becomes ` default($def) ` (the 1.x rule
195+ "null default on a non-nullable type → ` required() ` " is gone).
196+
191197The result is a ` Structure ` with ` castTo($class) ` ** stacked after** the
192198constructor's built-in ` castTo('object') ` , so a completed value travels
193199array → ` stdClass ` → instance through the cast fork above.
@@ -207,4 +213,4 @@ array → `stdClass` → instance through the cast fork above.
207213| DI / integration hook | ` Processor::onNewContext ` , ` createContext ` |
208214| Error message rendering | ` Message::toString ` , ` Message::* ` code constants |
209215| Key schemas, ` isKey ` | ` Type::normalize ` /` validateItems ` , ` Context::isKey ` |
210- | Object-to-schema mapping | ` Expect::from ` , ` Helpers::getPropertyType ` |
216+ | Object-to-schema mapping | ` Expect::from ` (native types only) |
0 commit comments