The expression $value of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
29
$attribute = new StandardAttribute($name, $value);
30
} else {
31
$attribute = new BooleanAttribute($name);
32
}
33
34
return new Arbitrary($this->name, $this->attributes->add($attribute), $this->children);
35
}
36
37
public function withChild(ElementInterface $element): Arbitrary
38
{
39
return new Arbitrary($this->name, $this->attributes, $this->children->add($element));
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: