framework
framework copied to clipboard
Specific `InputBag` behavior
<?php
use Ramsey\Uuid\Uuid;
require __DIR__ . '/vendor/autoload.php';
$inputBag = new \Spiral\Http\Request\InputBag([
'test' => null
]);
$arrayObject = new \ArrayObject([
'test' => null
]);
var_dump('$inputBag', isset($inputBag['test']));
var_dump('$arrayObject', isset($arrayObject['test']));
$propertyInputBag = isset($inputBag['test']) && $inputBag['test'] !== null ? Uuid::fromString($inputBag['test']) : null;
$propertyArrayObject = isset($arrayObject['test']) ? Uuid::fromString($arrayObject['test']) : null;
// isset() PHP documentation:
// * <p>Determine if a variable is set and is not <b>NULL</b>.</p>
// Unexpected behavior.
Result:
string(9) "$inputBag"
bool(true)
string(12) "$arrayObject"
bool(false)
-
$propertyInputBag
using long form and may confuse developer...
It's normal behavior or it a bug?