-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostconditionViolation.php
More file actions
38 lines (34 loc) · 1.08 KB
/
Copy pathPostconditionViolation.php
File metadata and controls
38 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Rasuvaeff\PropertyTesting\StateMachine;
use RuntimeException;
/**
* Thrown by {@see StateMachine::check()} when a command's
* {@see Command::postCondition()} returns false.
*
* Carries the executed trace (command labels up to and including the failing
* one), the failing command, and the pre-state model and observed result, so
* the property runner surfaces exactly which step of the sequence broke.
*
* @api
*/
final class PostconditionViolation extends RuntimeException
{
/**
* @param list<string> $trace Labels of the commands executed up to and including the failing one.
*/
public function __construct(
public readonly array $trace,
public readonly int $step,
public readonly Command $command,
public readonly mixed $model,
public readonly mixed $result,
) {
parent::__construct(sprintf(
'Postcondition failed at step %d for command %s; sequence: [%s]',
$step,
(string) $command,
implode(', ', $trace),
));
}
}