Skip to content

Remove NULL handling in Type::cast() - #373

Merged
thekid merged 2 commits into
xp-framework:mainfrom
thekid:refactor/null-casts
Aug 23, 2026
Merged

Remove NULL handling in Type::cast()#373
thekid merged 2 commits into
xp-framework:mainfrom
thekid:refactor/null-casts

Conversation

@thekid

@thekid thekid commented Aug 23, 2026

Copy link
Copy Markdown
Member

This pull request changes the special handling in Type::Cast() which will return null when null is given, and changes it to work like the cast operators in PHP. The old behavior can be achieved with nullable types.

Examples

Primitives:

use lang\Primitive;

// Both now return an empty string
$r= (string)null; 
$r= Primitve::$STRING->cast(null);

Arrays:

use lang\Type;

// Both now return an empty array
$r= (array)null;
$r= Type::$ARRAY->cast(null);

Objects:

use lang\Type;

// Both now return an empty object
$r= (object)null;
$r= Type::$OBJECT->cast(null);

@thekid
thekid merged commit 926a2a8 into xp-framework:main Aug 23, 2026
14 checks passed
@thekid
thekid deleted the refactor/null-casts branch August 23, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant