MediaWiki REL1_32
StaticArrayWriterTest.php
Go to the documentation of this file.
1<?php
22
26class StaticArrayWriterTest extends PHPUnit\Framework\TestCase {
27 public function testCreate() {
28 $data = [
29 'foo' => 'bar',
30 'baz' => 'rawr',
31 "they're" => '"quoted properly"',
32 'nested' => [ 'elements', 'work' ],
33 'and' => [ 'these' => 'do too' ],
34 ];
35 $writer = new StaticArrayWriter();
36 $actual = $writer->create( $data, "Header\nWith\nNewlines" );
37 $expected = <<<PHP
38<?php
39// Header
40// With
41// Newlines
42return [
43 'foo' => 'bar',
44 'baz' => 'rawr',
45 'they\'re' => '"quoted properly"',
46 'nested' => [
47 0 => 'elements',
48 1 => 'work',
49 ],
50 'and' => [
51 'these' => 'do too',
52 ],
53];
54
55PHP;
56 $this->assertSame( $expected, $actual );
57 }
58}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
\Wikimedia\StaticArrayWriter
Format a static PHP array to be written to a file.
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by etc *css user provided css code *text plain text In PHP
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37