Skip to content

Commit

Permalink
Compatibility with fp4php/functional v5
Browse files Browse the repository at this point in the history
  • Loading branch information
klimick committed Nov 19, 2022
1 parent 59c3d50 commit b8bb91d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Toolkit/Assertion/Assertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace Fp\PsalmToolkit\Toolkit\Assertion;

use Fp\Functional\Option\Option;

use function Fp\Collection\at;
use function Fp\Evidence\of;

final class Assertions
{
Expand All @@ -24,7 +26,7 @@ public function __construct(private array $data = [])
*/
public function __invoke(string $name): Option
{
return at($this->data, $name)->filterOf($name);
return at($this->data, $name)->flatMap(of($name));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Fp\PsalmToolkit\Toolkit\Assertion\Issue\SeePsalmIssueAssertionFailed;
use Psalm\Internal\Analyzer\IssueData;
use Psalm\IssueBuffer;
use function Fp\Cast\asList;
use function Fp\Collection\filter;
use function Fp\Collection\reindex;

Expand Down Expand Up @@ -45,14 +46,14 @@ private static function handle(SeePsalmIssuesData $seePsalmIssues, HaveCodeAsser

$expectedIssues = reindex($seePsalmIssues->issues, self::toKeyFn());
$actualIssues = reindex($issuesData[$seePsalmIssues->code_location->file_path], self::toKeyFn());
$handledIssues = filter($actualIssues, self::isHandled($haveCodeAssertion, $expectedIssues), preserveKeys: true);
$handledIssues = filter($actualIssues, self::isHandled($haveCodeAssertion, $expectedIssues));

/** @psalm-suppress InternalProperty */
foreach ($handledIssues as $i) {
IssueBuffer::remove($i->file_path, $i->type, $i->from);
}

return filter($expectedIssues, fn(SeePsalmIssue $i) => !array_key_exists(self::toKey($i), $handledIssues));
return filter(asList($expectedIssues), fn(SeePsalmIssue $i) => !array_key_exists(self::toKey($i), $handledIssues));
}

/**
Expand Down

0 comments on commit b8bb91d

Please sign in to comment.