TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
658 B

--TEST--
Symfony pattern: nullsafe method result array offset with coalesce
--FILE--
<?php
class SymfonyLikeStamp
{
public function __construct(private array $attributes)
{
}
public function getAttributes(): array
{
return $this->attributes;
}
}
function contentType(?SymfonyLikeStamp $stamp): ?string
{
return $stamp?->getAttributes()['content_type'] ?? null;
}
function main(): void
{
var_dump(contentType(null));
var_dump(contentType(new SymfonyLikeStamp([])));
var_dump(contentType(new SymfonyLikeStamp(['content_type' => 'application/json'])));
}
?>
--EXPECT--
NULL
NULL
string(16) "application/json"