class Callback
Same name in this branch
- 11.1.x vendor/symfony/validator/Constraints/Callback.php \Symfony\Component\Validator\Constraints\Callback
- 11.1.x core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
@psalm-template CallbackInput of mixed
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Framework\Constraint\Constraint implements \Countable, \PHPUnit\Framework\SelfDescribing
- class \PHPUnit\Framework\Constraint\Callback extends \PHPUnit\Framework\Constraint\Constraint
Expanded class hierarchy of Callback
3 files declare their use of Callback
- Assert.php in vendor/
phpunit/ phpunit/ src/ Framework/ Assert.php - Functions.php in vendor/
phpunit/ phpunit/ src/ Framework/ Assert/ Functions.php - Parameters.php in vendor/
phpunit/ phpunit/ src/ Framework/ MockObject/ Runtime/ Rule/ Parameters.php
19 string references to 'Callback'
- Callback::getDefaultOption in vendor/
symfony/ validator/ Constraints/ Callback.php - Returns the name of the default option.
- ConstraintManager::registerDefinitions in core/
lib/ Drupal/ Core/ Validation/ ConstraintManager.php - Callback for registering definitions for constraints shipped with Symfony.
- CreateWidgetTypeCallbackSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ MySource/ Sniffs/ Objects/ CreateWidgetTypeCallbackSniff.php - Processes this test, when one of its tokens is encountered.
- d6_action.yml in core/
modules/ system/ migrations/ d6_action.yml - core/modules/system/migrations/d6_action.yml
- d6_block.yml in core/
modules/ block/ migrations/ d6_block.yml - core/modules/block/migrations/d6_block.yml
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ Constraint/ Callback.php, line 20
Namespace
PHPUnit\Framework\ConstraintView source
final class Callback extends Constraint {
/**
* @psalm-var callable(CallbackInput $input): bool
*/
private readonly mixed $callback;
/**
* @psalm-param callable(CallbackInput $input): bool $callback
*/
public function __construct(callable $callback) {
$this->callback = $callback;
}
/**
* Returns a string representation of the constraint.
*/
public function toString() : string {
return 'is accepted by specified callback';
}
/**
* @psalm-suppress ArgumentTypeCoercion
*/
public function isVariadic() : bool {
foreach ((new ReflectionFunction(Closure::fromCallable($this->callback)))
->getParameters() as $parameter) {
if ($parameter->isVariadic()) {
return true;
}
}
return false;
}
/**
* Evaluates the constraint for parameter $value. Returns true if the
* constraint is met, false otherwise.
*
* @psalm-param CallbackInput $other
*
* @psalm-suppress InvalidArgument
*/
protected function matches(mixed $other) : bool {
if ($this->isVariadic()) {
return ($this->callback)(...$other);
}
return ($this->callback)($other);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Callback::$callback | private | property | @psalm-var callable(CallbackInput $input): bool | ||
Callback::isVariadic | public | function | @psalm-suppress ArgumentTypeCoercion | ||
Callback::matches | protected | function | Evaluates the constraint for parameter $value. Returns true if the constraint is met, false otherwise. |
Overrides Constraint::matches | |
Callback::toString | public | function | Returns a string representation of the constraint. | Overrides SelfDescribing::toString | |
Callback::__construct | public | function | @psalm-param callable(CallbackInput $input): bool $callback | ||
Constraint::additionalFailureDescription | protected | function | Return additional failure description where needed. | 7 | |
Constraint::count | public | function | Counts the number of constraint elements. | 3 | |
Constraint::evaluate | public | function | Evaluates the constraint for parameter $other. | 7 | |
Constraint::exporter | protected | function | |||
Constraint::fail | protected | function | Throws an exception for the given compared value and test description. | 1 | |
Constraint::failureDescription | protected | function | Returns the description of the failure. | 51 | |
Constraint::failureDescriptionInContext | protected | function | Returns the description of the failure when this constraint appears in context of an $operator expression. |
||
Constraint::reduce | protected | function | Reduces the sub-expression starting at $this by skipping degenerate sub-expression and returns first descendant constraint that starts a non-reducible sub-expression. |
2 | |
Constraint::toStringInContext | protected | function | Returns a custom string representation of the constraint object when it appears in context of an $operator expression. |
||
Constraint::valueToTypeStringFragment | protected | function | @psalm-return non-empty-string |