Skip to content

Commit

Permalink
tests: Add missing static analysis tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 14, 2021
1 parent facd4a4 commit fb641e8
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/static-analysis/when.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

declare(strict_types=1);

include __DIR__ . '/../../vendor/autoload.php';

use loophp\collection\Collection;
use loophp\collection\Contract\Collection as CollectionInterface;

/**
* @param CollectionInterface<int, string> $collection
*/
function whenConditionIsTrueT_checkList(CollectionInterface $collection): void
{
}

/**
* @param CollectionInterface<int, int> $collection
*/
function whenConditionIsFalseT_checkList(CollectionInterface $collection): void
{
}

whenConditionIsTrueT_checkList(
Collection::fromIterable(range('a', 'e'))
->when(
static fn() => true,
static fn() => range('a', 'e'),
static fn() => range('a', 'e')
)
);

whenConditionIsTrueT_checkList(
Collection::fromIterable(range('a', 'e'))
->when(
static fn() => true,
static fn() => range('a', 'e')
)
);

whenConditionIsFalseT_checkList(
Collection::fromIterable(range(0, 4))
->when(
static fn() => false,
static fn() => range(0, 4),
static fn() => range(0, 4)
)
);

0 comments on commit fb641e8

Please sign in to comment.