MediaWiki master
Wikimedia\StaticArrayWriter Class Reference

Format a static PHP array to be written to a file. More...

Public Member Functions

 create (array $data, $header='Automatically generated')
 

Static Public Member Functions

static encodeValue ( $value, $indent=0)
 Recursively turn one value into properly-indented PHP.
 
static write (array $data, $header)
 Create a PHP file that returns the array.
 
static writeClass (array $data, array $layout)
 Create an PHP class file with the array as a class constant.
 

Detailed Description

Format a static PHP array to be written to a file.

Stability: newable
Since
1.32

Definition at line 27 of file StaticArrayWriter.php.

Member Function Documentation

◆ create()

Wikimedia\StaticArrayWriter::create ( array $data,
$header = 'Automatically generated' )
Parameters
array$dataArray with keys/values to export
string$header
Returns
string PHP code

Definition at line 33 of file StaticArrayWriter.php.

References $header.

◆ encodeValue()

static Wikimedia\StaticArrayWriter::encodeValue ( $value,
$indent = 0 )
static

Recursively turn one value into properly-indented PHP.

Since
1.38
Parameters
mixed$value
int$indentIndentation level
Returns
string PHP code

Definition at line 137 of file StaticArrayWriter.php.

◆ write()

static Wikimedia\StaticArrayWriter::write ( array $data,
$header )
static

Create a PHP file that returns the array.

Since
1.35
Parameters
array$dataArray with keys/values to export
string$header
Returns
string PHP code

Definition at line 45 of file StaticArrayWriter.php.

References $header.

◆ writeClass()

static Wikimedia\StaticArrayWriter::writeClass ( array $data,
array $layout )
static

Create an PHP class file with the array as a class constant.

PHP classes can be autoloaded by name, which allows usage to be decoupled from the file path.

Since
1.37
Parameters
array$data
array{header:string,namespace:string,class:string,const:string}$layout
Returns
string PHP code

Definition at line 63 of file StaticArrayWriter.php.


The documentation for this class was generated from the following file: