From: Kunal Mehta Date: Sun, 14 Aug 2016 03:48:29 +0000 (-0700) Subject: HTMLForm: Use ObjectFactory instead of Reflection X-Git-Tag: 1.31.0-rc.0~6072 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=7f5c0cffd82ae7784c2dfc41a04bfd22547832df;p=lhc%2Fweb%2Fwiklou.git HTMLForm: Use ObjectFactory instead of Reflection ObjectFactory has a hack that constructs an object directly if there are less than 10 parameters, which there typically is for HTMLForm classes. This is faster than using ReflectionClass, and whenever ObjectFactory is updated to take advantage of the splat operator, this will automatically use it as well. And use ::class while we're at it. Change-Id: I7a696c127c237713448b165b9b4faee13f4ff88e --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index a7acd8b988..ff37e24e2f 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -275,14 +275,12 @@ class HTMLForm extends ContextSource { switch ( $displayFormat ) { case 'vform': - $reflector = new ReflectionClass( 'VFormHTMLForm' ); - return $reflector->newInstanceArgs( $arguments ); + return ObjectFactory::constructClassInstance( VFormHTMLForm::class, $arguments ); case 'ooui': - $reflector = new ReflectionClass( 'OOUIHTMLForm' ); - return $reflector->newInstanceArgs( $arguments ); + return ObjectFactory::constructClassInstance( OOUIHTMLForm::class, $arguments ); default: - $reflector = new ReflectionClass( 'HTMLForm' ); - $form = $reflector->newInstanceArgs( $arguments ); + /** @var HTMLForm $form */ + $form = ObjectFactory::constructClassInstance( HTMLForm::class, $arguments ); $form->setDisplayFormat( $displayFormat ); return $form; }