You could replace null with a possible first and last date to ease comparing:
if (is_null($token['validfrom']) {
$token_validfrom = new DateTime('0000-01-01 00:00:00');
} else {
$token_validfrom = new DateTime($token['validfrom']);
}
if (is_null($token['validuntil']) {
$token_validuntil = new DateTime('9999-12-31 23:23:59');
} else {
$token_validuntil = new DateTime($token['validuntil']);
}
This way only your last line of comparison should be necessary:
return ($validfrom == $token_validfrom) || ($validfrom > $token_validfrom ? $validfrom < $token_validuntil : $token_validfrom < $validuntil);