Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
PhpIniSink
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 set
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Settings\Config;
4
5use Wikimedia\NormalizedException\NormalizedExceptionTrait;
6
7/**
8 * Settings sink for values to pass to ini_set.
9 *
10 * @since 1.39
11 */
12class PhpIniSink {
13    use NormalizedExceptionTrait;
14
15    /**
16     * Sets a php runtime configuration value using ini_set().
17     * A PHP notice is triggered if setting the value fails.
18     *
19     * @param string $option
20     * @param string $value
21     * @return void
22     */
23    public function set( string $option, string $value ): void {
24        $result = ini_set( $option, $value );
25
26        if ( $result === false ) {
27            $msg = $this->getMessageFromNormalizedMessage(
28                'Could not set option: {option} with value: {value} to PHP_INI config.',
29                [
30                    'value' => $value,
31                    'option' => $option,
32                ]
33            );
34            trigger_error( $msg );
35        }
36    }
37
38}