Debian Codegraph @

extensions/Cite/tests/phpunit/TestUtils.php

raw symbols SCIP
1 <?php
2
3 namespace Cite\Tests;
4
5 use Cite\ReferenceStackItem;
6
7 /**
8 * @license GPL-2.0-or-later
9 */
10 class TestUtils {
11 /**
12 * Factory to create internal ref data structures from array fixtures.
13 */
14 public static function refFromArray( ?array $val ): ?ReferenceStackItem {
15 if ( $val === null ) {
16 return null;
17 }
18 $ref = new ReferenceStackItem();
19 foreach ( $val as $k => $v ) {
20 $ref->{$k} = $v;
21 }
22 return $ref;
23 }
24
25 /**
26 * @return array<string,array<string|int,?ReferenceStackItem>>
27 */
28 public static function refGroupsFromArray( array $refs ) {
29 return array_map(
30 fn ( $groupRefs ) => array_map( [ self::class, 'refFromArray' ], $groupRefs ),
31 $refs
32 );
33 }
34 }