Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Framework\Constraint;
11
 
12
/**
13
 * @psalm-template CallbackInput of mixed
14
 *
15
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
16
 */
17
final class Callback extends Constraint
18
{
19
    /**
20
     * @var callable
21
     *
22
     * @psalm-var callable(CallbackInput $input): bool
23
     */
24
    private $callback;
25
 
26
    /** @psalm-param callable(CallbackInput $input): bool $callback */
27
    public function __construct(callable $callback)
28
    {
29
        $this->callback = $callback;
30
    }
31
 
32
    /**
33
     * Returns a string representation of the constraint.
34
     */
35
    public function toString(): string
36
    {
37
        return 'is accepted by specified callback';
38
    }
39
 
40
    /**
41
     * Evaluates the constraint for parameter $value. Returns true if the
42
     * constraint is met, false otherwise.
43
     *
44
     * @param mixed $other value or object to evaluate
45
     *
46
     * @psalm-param CallbackInput $other
47
     */
48
    protected function matches($other): bool
49
    {
50
        return ($this->callback)($other);
51
    }
52
}