xref: /dokuwiki/_test/tests/Parsing/Lexer/RecordingHandler.php (revision 504c13e8df88563c11b3720b317991bc38835a35)
1*504c13e8SAndreas Gohr<?php
2*504c13e8SAndreas Gohr
3*504c13e8SAndreas Gohrnamespace dokuwiki\test\Parsing\Lexer;
4*504c13e8SAndreas Gohr
5*504c13e8SAndreas Gohruse dokuwiki\Parsing\Handler;
6*504c13e8SAndreas Gohr
7*504c13e8SAndreas Gohr/**
8*504c13e8SAndreas Gohr * Handler subclass that records all handleToken calls for later assertion
9*504c13e8SAndreas Gohr * instead of dispatching to mode objects.
10*504c13e8SAndreas Gohr */
11*504c13e8SAndreas Gohrclass RecordingHandler extends Handler
12*504c13e8SAndreas Gohr{
13*504c13e8SAndreas Gohr    /** @var array[] each entry is [method, match, state, pos] */
14*504c13e8SAndreas Gohr    public array $recorded = [];
15*504c13e8SAndreas Gohr
16*504c13e8SAndreas Gohr    /** @inheritdoc */
17*504c13e8SAndreas Gohr    public function handleToken($modeName, $match, $state, $pos, $originalModeName = '')
18*504c13e8SAndreas Gohr    {
19*504c13e8SAndreas Gohr        $this->recorded[] = [$modeName, $match, $state, $pos];
20*504c13e8SAndreas Gohr        return true;
21*504c13e8SAndreas Gohr    }
22*504c13e8SAndreas Gohr}
23