jenkins-bot has submitted this change and it was merged.

Change subject: HTMLForm: Use ObjectFactory instead of Reflection
......................................................................


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
---
M includes/htmlform/HTMLForm.php
1 file changed, 4 insertions(+), 6 deletions(-)

Approvals:
  Florianschmidtwelzow: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index a7acd8b..ff37e24 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -275,14 +275,12 @@
 
                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;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/304685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a696c127c237713448b165b9b4faee13f4ff88e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to