mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-22 11:32:38 +00:00
262fbe24eb
This encapsulation gives us field name, type validation and code documentation. This patch only affects ReferenceStack and continues to return approximately the same array outputs to callers. Some additional information is included and the placeholder column has a new name. Bug: T353451 Change-Id: I405fe7ac241f6991fd4c526bfbb58fbc34f2e147
35 lines
683 B
PHP
35 lines
683 B
PHP
<?php
|
|
|
|
namespace Cite\Tests;
|
|
|
|
use Cite\ReferenceStackItem;
|
|
|
|
/**
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class TestUtils {
|
|
/**
|
|
* Factory to create internal ref data structures from array fixtures.
|
|
*/
|
|
public static function refFromArray( ?array $val ): ?ReferenceStackItem {
|
|
if ( $val === null ) {
|
|
return null;
|
|
}
|
|
$ref = new ReferenceStackItem();
|
|
foreach ( $val as $k => $v ) {
|
|
$ref->{$k} = $v;
|
|
}
|
|
return $ref;
|
|
}
|
|
|
|
/**
|
|
* @return array<string,array<string|int,?ReferenceStackItem>>
|
|
*/
|
|
public static function refGroupsFromArray( array $refs ) {
|
|
return array_map(
|
|
fn ( $groupRefs ) => array_map( [ self::class, 'refFromArray' ], $groupRefs ),
|
|
$refs
|
|
);
|
|
}
|
|
}
|