If php-yaml extension in installed, use that. Otherwise we fallback to symfony Yaml parser. php-yaml is about 20 times faster then symfony, for default-settings.yaml it will take PHP-yaml 6ms to load it vs 100ms for symfony. But given that the result will be cached, it's better not to bring in a required native dependency. Bug: T294751 Change-Id: I3ffde926c3f264cacf39810ff7bd338c9f78823d
35 lines
794 B
PHP
35 lines
794 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Settings\Source\Format;
|
|
|
|
use Stringable;
|
|
use UnexpectedValueException;
|
|
|
|
/**
|
|
* A SettingsFormat is meant to detect supported file types and/or decode
|
|
* source contents into settings arrays.
|
|
*
|
|
* @since 1.38
|
|
* @todo mark as stable before the 1.38 release
|
|
*/
|
|
interface SettingsFormat extends Stringable {
|
|
/**
|
|
* Decodes the given settings data and returns an associative array.
|
|
*
|
|
* @param string $data Settings data.
|
|
*
|
|
* @return array
|
|
* @throws UnexpectedValueException
|
|
*/
|
|
public function decode( string $data ): array;
|
|
|
|
/**
|
|
* Whether or not the format claims to support a file with the given
|
|
* extension.
|
|
*
|
|
* @param string $ext File extension.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function supportsFileExtension( string $ext ): bool;
|
|
}
|