netresearch/jsonmapper — pull request #22 by barryvdh (2014-12-28 20:10:04+00:00)
Title: Check for Nullable types

Sometimes I want to cast a value to an int or string, but if the original value is null, I would like to get that. So I would typehint that as `int|null` or `string|null` or something.

This PR adds a check for a 'nullable' typehint, eg. when `null` is one of the options. When the type is nullable and the value is null, the property is set to null. When the type is not null, the nullable typehint is removed from the type, so that is can be matched to a class or simpletype. (So `int|null` becomes `int`)

This might not be the best way to do this (exploding, array_diffing etc), but I did this because I want to allow for multiple cases (`int|null`, `int|NULL` should match, `NullType` should not, only `null` should be nullable but return `null` as type still etc)