Removed more functional-php usages

This commit is contained in:
Alejandro Celaya
2023-11-30 14:34:21 +01:00
parent 549c6605f0
commit bff4bd12ae
20 changed files with 156 additions and 91 deletions

View File

@@ -27,9 +27,8 @@ use Shlinkio\Shlink\Core\Visit\Model\Visitor;
use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer;
use Throwable;
use function array_walk;
use function count;
use function Functional\each;
use function Functional\noop;
class NotifyVisitToRabbitMqTest extends TestCase
{
@@ -77,7 +76,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
{
$visitId = '123';
$this->em->expects($this->once())->method('find')->with(Visit::class, $visitId)->willReturn($visit);
each($expectedChannels, function (string $method): void {
array_walk($expectedChannels, function (string $method): void {
$this->updatesGenerator->expects($this->once())->method($method)->with(
$this->isInstanceOf(Visit::class),
)->willReturn(Update::forTopicAndPayload('', []));
@@ -153,7 +152,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
yield 'legacy non-orphan visit' => [
true,
$visit = Visit::forValidShortUrl(ShortUrl::withLongUrl('https://longUrl'), Visitor::emptyInstance()),
noop(...),
static fn () => null,
function (MockObject & PublishingHelperInterface $helper) use ($visit): void {
$helper->method('publishUpdate')->with(self::callback(function (Update $update) use ($visit): bool {
$payload = $update->payload;
@@ -170,7 +169,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
yield 'legacy orphan visit' => [
true,
Visit::forBasePath(Visitor::emptyInstance()),
noop(...),
static fn () => null,
function (MockObject & PublishingHelperInterface $helper): void {
$helper->method('publishUpdate')->with(self::callback(function (Update $update): bool {
$payload = $update->payload;

View File

@@ -32,8 +32,8 @@ use stdClass;
use Symfony\Component\Console\Style\StyleInterface;
use function count;
use function Functional\some;
use function Shlinkio\Shlink\Core\contains;
use function Shlinkio\Shlink\Core\some;
use function sprintf;
use function str_contains;

View File

@@ -20,8 +20,8 @@ use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
use Shlinkio\Shlink\Importer\Sources\ImportSource;
use function array_map;
use function Functional\every;
use function range;
use function Shlinkio\Shlink\Core\every;
use function strlen;
use function strtolower;

View File

@@ -16,9 +16,6 @@ use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Middleware\TrimTrailingSlashMiddleware;
use function Functional\compose;
use function Functional\const_function;
class TrimTrailingSlashMiddlewareTest extends TestCase
{
private MockObject & RequestHandlerInterface $requestHandler;
@@ -34,7 +31,10 @@ class TrimTrailingSlashMiddlewareTest extends TestCase
ServerRequestInterface $inputRequest,
callable $assertions,
): void {
$arg = compose($assertions, const_function(true));
$arg = static function (...$args) use ($assertions): bool {
$assertions(...$args);
return true;
};
$this->requestHandler->expects($this->once())->method('handle')->with($this->callback($arg))->willReturn(
new Response(),
);