Re: [Wikitech-l] Service wiring conventions in extensions

2020-07-15 Thread Gergo Tisza
I'd go for something like /* TranslateServices.php */ public static function wrap( MediaWikiServices $services ) { return new self( $services ); } /* ServiceWiring.php */ 'Translate:TranslatablePageParser' => function ( MediaWikiServices $services ) { return new TranslatablePageParser(

Re: [Wikitech-l] Service wiring conventions in extensions

2020-07-15 Thread Daniel Kinzler
Hi Niklas! > Do you see any downsides of using code like below instead? > > 'Translate:TranslatablePageParser' => function (): TranslatablePageParser { > $services = TranslateServices::getInstance(); > return new TranslatablePageParser( > $services->getParsingPlaceholderFactory() ); > },

[Wikitech-l] Service wiring conventions in extensions

2020-07-15 Thread Niklas Laxström
The example below works, and I see it used in some extensions, but it has no autocompletion and not catching typos. Services.php: class TranslateServices implements ContainerInterface { public function getParsingPlaceholderFactory(): ParsingPlaceholderFactory { return $this->container-