phasync
SealedObject / seal

Method

SealedObject::seal

What json_decode() (without assoc) returned, with its objects replaced by SealedObjects; the objects inside one are wrapped when first read.

Description#

public static SealedObject::seal(
    mixed $value
): mixed

Parameters#

$value mixed

Return values#

mixed

Examples#

Example 1Seal a decoded value
use Swerve\Util\SealedObject;

$value = SealedObject::seal(json_decode('[{"id": 1, "tags": {"a": true}}, "text", 3]'));

echo get_debug_type($value), "\n";                 // a list stays an array
echo get_debug_type($value[0]), "\n";              // its objects are sealed
echo get_debug_type($value[0]->tags), "\n";
echo $value[1], ' ', $value[2], "\n";
Output
array
Swerve\Util\SealedObject
Swerve\Util\SealedObject
text 3