1
0
mirror of https://github.com/danog/amp.git synced 2024-12-05 21:38:54 +01:00
amp/examples/psalm/call.php

49 lines
773 B
PHP

<?php
use function Amp\call;
use function Amp\delay;
use function Amp\Promise\wait;
/**
* @return void
*/
function accept(string $param)
{
}
$coroutine = call(function (): \Generator {
yield delay(10);
return 123;
});
// psalm-expect InvalidScalarArgument
accept(wait($coroutine));
// psalm-expect InvalidArgument
accept(call(function (): \Generator {
yield delay(10);
return 'foobar';
}));
// psalm-expect InvalidScalarArgument
accept(wait(call(function (): int {
return 42;
})));
// wait unwraps the promise, so this is accepted
accept(wait(call(function (): \Generator {
yield delay(10);
return 'foobar';
})));
// wait unwraps the promise, so this is accepted
accept(wait(call(function (): string {
return 'foobar';
})));