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

Change subject: PHP: Take advantage of PHP 5.5 understanding ( new Foo )->foo
......................................................................


PHP: Take advantage of PHP 5.5 understanding ( new Foo )->foo

Change-Id: I5cdc15cb7a6419e69ab57beda3084242eb99b698
---
M demos/widgets.php
M php/widgets/ButtonInputWidget.php
M php/widgets/CheckboxInputWidget.php
M php/widgets/ComboBoxInputWidget.php
M php/widgets/DropdownInputWidget.php
M php/widgets/RadioInputWidget.php
M php/widgets/TextInputWidget.php
M tests/phpunit/TagTest.php
8 files changed, 17 insertions(+), 39 deletions(-)

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



diff --git a/demos/widgets.php b/demos/widgets.php
index f5e1348..697df2a 100644
--- a/demos/widgets.php
+++ b/demos/widgets.php
@@ -434,15 +434,15 @@
                                # (recursively) made infusable.  We protect the 
FieldLayout
                                # by wrapping it with a new <div> Tag, so that 
it won't get
                                # rebuilt during infusion.
-                               $wrappedFieldLayout = new OOUI\Tag( 'div' );
-                               $wrappedFieldLayout->appendContent(
+                               $wrappedFieldLayout = ( new OOUI\Tag( 'div' ) )
+                                       ->appendContent(
                                                new OOUI\FieldLayout(
                                                        
$buttonStyleShowcaseWidget,
                                                        [
                                                                'align' => 'top'
                                                        ]
                                                )
-                               );
+                                       );
                                $demoContainer->appendContent( new 
OOUI\FieldsetLayout( [
                                        'infusable' => true,
                                        'label' => 'Button style showcase',
diff --git a/php/widgets/ButtonInputWidget.php 
b/php/widgets/ButtonInputWidget.php
index 583ac53..f9276df 100644
--- a/php/widgets/ButtonInputWidget.php
+++ b/php/widgets/ButtonInputWidget.php
@@ -72,9 +72,8 @@
                $type = in_array( $config['type'], [ 'button', 'submit', 
'reset' ] ) ?
                        $config['type'] :
                        'button';
-               $input = new Tag( $config['useInputTag'] ? 'input' : 'button' );
-               $input->setAttributes( [ 'type' => $type ] );
-               return $input;
+               $tag = $config['useInputTag'] ? 'input' : 'button';
+               return ( new Tag( $tag ) )->setAttributes( [ 'type' => $type ] 
);
        }
 
        /**
diff --git a/php/widgets/CheckboxInputWidget.php 
b/php/widgets/CheckboxInputWidget.php
index ef097dd..44167fd 100644
--- a/php/widgets/CheckboxInputWidget.php
+++ b/php/widgets/CheckboxInputWidget.php
@@ -33,9 +33,7 @@
        }
 
        protected function getInputElement( $config ) {
-               $input = new Tag( 'input' );
-               $input->setAttributes( [ 'type' => 'checkbox' ] );
-               return $input;
+               return ( new Tag( 'input' ) )->setAttributes( [ 'type' => 
'checkbox' ] );
        }
 
        /**
diff --git a/php/widgets/ComboBoxInputWidget.php 
b/php/widgets/ComboBoxInputWidget.php
index 0d8d3d2..1d84e0d 100644
--- a/php/widgets/ComboBoxInputWidget.php
+++ b/php/widgets/ComboBoxInputWidget.php
@@ -55,9 +55,9 @@
 
                $this->datalist->clearContent();
                foreach ( $options as $opt ) {
-                       $option = new Tag( 'option' );
-                       $option->setAttributes( [ 'value' => $opt['data'] ] );
-                       $option->appendContent( isset( $opt['label'] ) ? 
$opt['label'] : $opt['data'] );
+                       $option = ( new Tag( 'option' ) )
+                               ->setAttributes( [ 'value' => $opt['data'] ] )
+                               ->appendContent( isset( $opt['label'] ) ? 
$opt['label'] : $opt['data'] );
 
                        $this->options[] = $option;
                        $this->datalist->appendContent( $option );
diff --git a/php/widgets/DropdownInputWidget.php 
b/php/widgets/DropdownInputWidget.php
index c534ce4..0c43fa8 100644
--- a/php/widgets/DropdownInputWidget.php
+++ b/php/widgets/DropdownInputWidget.php
@@ -64,9 +64,9 @@
                $this->input->clearContent();
                foreach ( $options as $opt ) {
                        $optValue = $this->cleanUpValue( $opt['data'] );
-                       $option = new Tag( 'option' );
-                       $option->setAttributes( [ 'value' => $optValue ] );
-                       $option->appendContent( isset( $opt['label'] ) ? 
$opt['label'] : $optValue );
+                       $option = ( new Tag( 'option' ) )
+                               ->setAttributes( [ 'value' => $optValue ] )
+                               ->appendContent( isset( $opt['label'] ) ? 
$opt['label'] : $optValue );
 
                        if ( $value === $optValue ) {
                                $isValueAvailable = true;
diff --git a/php/widgets/RadioInputWidget.php b/php/widgets/RadioInputWidget.php
index c02f913..f35f22d 100644
--- a/php/widgets/RadioInputWidget.php
+++ b/php/widgets/RadioInputWidget.php
@@ -24,9 +24,7 @@
        }
 
        protected function getInputElement( $config ) {
-               $input = new Tag( 'input' );
-               $input->setAttributes( [ 'type' => 'radio' ] );
-               return $input;
+               return ( new Tag( 'input' ) )->setAttributes( [ 'type' => 
'radio' ] );
        }
 
        /**
diff --git a/php/widgets/TextInputWidget.php b/php/widgets/TextInputWidget.php
index cf29014..6b4b078 100644
--- a/php/widgets/TextInputWidget.php
+++ b/php/widgets/TextInputWidget.php
@@ -136,9 +136,7 @@
                if ( isset( $config['multiline'] ) && $config['multiline'] ) {
                        return new Tag( 'textarea' );
                } else {
-                       $input = new Tag( 'input' );
-                       $input->setAttributes( [ 'type' => $this->getSaneType( 
$config ) ] );
-                       return $input;
+                       return ( new Tag( 'input' ) )->setAttributes( [ 'type' 
=> $this->getSaneType( $config ) ] );
                }
        }
 
diff --git a/tests/phpunit/TagTest.php b/tests/phpunit/TagTest.php
index 8e81fe3..a1ddfd6 100644
--- a/tests/phpunit/TagTest.php
+++ b/tests/phpunit/TagTest.php
@@ -5,18 +5,6 @@
 use PHPUnit_Framework_TestCase;
 use OOUI\Tag;
 
-/**
- * Work around a peculiarity of PHP 5.3 syntax.
- *
- * @param mixed $item
- * @return mixed The very same $item
- */
-// @codingStandardsIgnoreStart
-function id( $item ) {
-       // @codingStandardsIgnoreEnd
-       return $item;
-}
-
 class TagTest extends PHPUnit_Framework_TestCase {
 
        /**
@@ -33,8 +21,7 @@
         * @covers Tag::hasClass
         */
        public function testClasses() {
-               $tag = new Tag();
-               $tag->addClasses( [ 'class1', 'class2' ] );
+               $tag = ( new Tag() )->addClasses( [ 'class1', 'class2' ] );
                $this->assertTrue( $tag->hasClass( 'class1' ) );
                $this->assertTrue( $tag->hasClass( 'class2' ) );
                $tag->removeClasses( [ 'class1' ] );
@@ -48,8 +35,7 @@
         * @covers Tag::removeAttributes
         */
        public function testAttributes() {
-               $tag = new Tag();
-               $tag->setAttributes( [
+               $tag = ( new Tag() )->setAttributes( [
                        'attr1' => 'foo',
                        'attr2' => 'bar',
                ] );
@@ -65,10 +51,9 @@
         * @covers Tag::ensureInfusableId
         */
        public function testEnsureInfusableId() {
-               $tag = new Tag();
+               $tag = ( new Tag() )->setAttributes( [ 'id' => 'foobar' ] );
                $tag2 = new Tag();
                $tag3 = new Tag();
-               $tag->setAttributes( [ 'id' => 'foobar' ] );
                $tag->ensureInfusableId();
                $tag2->ensureInfusableId();
                $tag3->ensureInfusableId();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5cdc15cb7a6419e69ab57beda3084242eb99b698
Gerrit-PatchSet: 3
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to