fix negated predicate decorated callable
This commit is contained in:
parent
61f934ffd7
commit
978a49091f
@ -108,12 +108,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Predicate/ConstantPredicate.php
|
||||
|
||||
-
|
||||
message: '#^Expression "\$this\-\>negated" on a separate line does not do anything\.$#'
|
||||
identifier: expr.resultUnused
|
||||
count: 1
|
||||
path: src/Predicate/NegatedPredicate.php
|
||||
|
||||
-
|
||||
message: '#^Method Kadet\\Functional\\Predicate\\NegatedPredicate\:\:__invoke\(\) has parameter \$args with no type specified\.$#'
|
||||
identifier: missingType.parameter
|
||||
|
||||
@ -39,6 +39,6 @@ class NegatedPredicate extends AbstractPredicate implements Decorator
|
||||
|
||||
public function getDecorated()
|
||||
{
|
||||
$this->negated;
|
||||
return $this->negated;
|
||||
}
|
||||
}
|
||||
40
tests/Collections/LibraryCallablesTest.php
Normal file
40
tests/Collections/LibraryCallablesTest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2026 Kacper Donat
|
||||
*
|
||||
* @author Kacper "Kadet" Donat <kacper@kadet.net>
|
||||
*
|
||||
* Full license available in separate LICENSE file
|
||||
*/
|
||||
|
||||
use Kadet\Functional as f;
|
||||
use Kadet\Functional\Collections as c;
|
||||
use Kadet\Functional\Predicates as p;
|
||||
|
||||
/**
|
||||
* The library's own callables (predicates, pipes, decorators) used as collection callbacks.
|
||||
*/
|
||||
class LibraryCallablesTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
// negated predicates
|
||||
|
||||
public function testFilterWithNegatedInternalFunction()
|
||||
{
|
||||
$this->assertSame([1 => 'x'], c\filter(f\not(is_numeric(...)))(['1', 'x']));
|
||||
}
|
||||
|
||||
public function testFilterWithNegatedClosure()
|
||||
{
|
||||
$this->assertSame([1], c\filter(f\not(fn ($x) => $x > 1))([1, 2]));
|
||||
}
|
||||
|
||||
public function testFilterWithNegatedPredicateMethod()
|
||||
{
|
||||
$this->assertSame([1], c\filter(p\gt(1)->not())([1, 2]));
|
||||
}
|
||||
|
||||
public function testRejectWithNegatedPredicate()
|
||||
{
|
||||
$this->assertSame([1 => 2], c\reject(p\gt(1)->not())([1, 2]));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user