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.
39 lines
889 B
39 lines
889 B
--TEST--
|
|
Symfony pattern: array_uintersect with spaceship comparator for nested arrays
|
|
--FILE--
|
|
<?php
|
|
|
|
class SymfonyLikeListenerPass
|
|
{
|
|
public function intersectListeners(array $expected, array $actual): array
|
|
{
|
|
return array_uintersect($expected, $actual, static fn (array $a, array $b) => $a <=> $b);
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$pass = new SymfonyLikeListenerPass();
|
|
|
|
var_dump(array_values($pass->intersectListeners(
|
|
[
|
|
['event' => 'request', 'method' => 'onRequest'],
|
|
['event' => 'response', 'method' => 'onResponse'],
|
|
],
|
|
[
|
|
['event' => 'response', 'method' => 'onResponse'],
|
|
['event' => 'terminate', 'method' => 'onTerminate'],
|
|
]
|
|
)));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
array(1) {
|
|
[0]=>
|
|
array(2) {
|
|
["event"]=>
|
|
string(8) "response"
|
|
["method"]=>
|
|
string(10) "onResponse"
|
|
}
|
|
}
|
|
|