From fd9178e4c3cd13e178d8805929490d899dfd5876 Mon Sep 17 00:00:00 2001 From: Vivek Ghaisas Date: Wed, 17 Jun 2015 16:28:51 +0300 Subject: [PATCH] Fix braces code style Bug: T102805 Change-Id: I7ce4c71dd605f9be79a630602391271bb269b962 --- includes/MimeMagic.php | 4 +++- includes/db/DatabaseMssql.php | 4 +++- includes/db/DatabasePostgres.php | 7 +++++-- includes/libs/eventrelayer/EventRelayer.php | 3 ++- .../MediaTransformInvalidParametersException.php | 3 ++- includes/page/Article.php | 4 +++- includes/profiler/ProfileSection.php | 3 ++- includes/profiler/Profiler.php | 7 +++++-- .../phpunit/includes/libs/ObjectFactoryTest.php | 16 ++++++++++++---- tests/phpunit/includes/site/SiteImporterTest.php | 6 +++--- 10 files changed, 40 insertions(+), 17 deletions(-) diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 0d907b7e31..3b065255a4 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -617,12 +617,14 @@ class MimeMagic { /** * Guess the MIME type from the file contents. * + * @todo Remove $ext param + * * @param string $file * @param mixed $ext * @return bool|string * @throws MWException */ - private function doGuessMimeType( $file, $ext ) { // TODO: remove $ext param + private function doGuessMimeType( $file, $ext ) { // Read a chunk of the file MediaWiki\suppressWarnings(); $f = fopen( $file, 'rb' ); diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index b5b682582a..85f1b96d99 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -1089,7 +1089,9 @@ class DatabaseMssql extends DatabaseBase { * @param string $s * @return string */ - public function strencode( $s ) { # Should not be called by us + public function strencode( $s ) { + // Should not be called by us + return str_replace( "'", "''", $s ); } diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 60999e5888..9ad76ab81b 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -1510,7 +1510,9 @@ SQL; return pg_unescape_bytea( $b ); } - function strencode( $s ) { # Should not be called by us + function strencode( $s ) { + // Should not be called by us + return pg_escape_string( $this->mConn, $s ); } @@ -1702,4 +1704,5 @@ SQL; } } // end DatabasePostgres class -class PostgresBlob extends Blob {} +class PostgresBlob extends Blob { +} diff --git a/includes/libs/eventrelayer/EventRelayer.php b/includes/libs/eventrelayer/EventRelayer.php index a3d214f80c..f95ba3f0e9 100755 --- a/includes/libs/eventrelayer/EventRelayer.php +++ b/includes/libs/eventrelayer/EventRelayer.php @@ -26,7 +26,8 @@ abstract class EventRelayer { /** * @param array $params */ - public function __construct( array $params ) {} + public function __construct( array $params ) { + } /** * @param string $channel diff --git a/includes/media/MediaTransformInvalidParametersException.php b/includes/media/MediaTransformInvalidParametersException.php index 15a2ca5546..6f9c2916d4 100644 --- a/includes/media/MediaTransformInvalidParametersException.php +++ b/includes/media/MediaTransformInvalidParametersException.php @@ -23,4 +23,5 @@ * * @ingroup Exception */ -class MediaTransformInvalidParametersException extends MWException {} +class MediaTransformInvalidParametersException extends MWException { +} diff --git a/includes/page/Article.php b/includes/page/Article.php index 11a3638fb9..5d7f365ab9 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -333,7 +333,9 @@ class Article implements Page { * @return string|bool String containing article contents, or false if null * @deprecated since 1.21, use WikiPage::getContent() instead */ - function fetchContent() { #BC cruft! + function fetchContent() { + // BC cruft! + ContentHandler::deprecated( __METHOD__, '1.21' ); if ( $this->mContentLoaded && $this->mContent ) { diff --git a/includes/profiler/ProfileSection.php b/includes/profiler/ProfileSection.php index 9062251021..d787edb702 100644 --- a/includes/profiler/ProfileSection.php +++ b/includes/profiler/ProfileSection.php @@ -39,5 +39,6 @@ class ProfileSection { * * @param string $name Name of the function to profile */ - public function __construct( $name ) {} + public function __construct( $name ) { + } } diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index 9983fece38..c65a3f9217 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -145,8 +145,11 @@ abstract class Profiler { } // Kept BC for now, remove when possible - public function profileIn( $functionname ) {} - public function profileOut( $functionname ) {} + public function profileIn( $functionname ) { + } + + public function profileOut( $functionname ) { + } /** * Mark the start of a custom profiling frame (e.g. DB queries). diff --git a/tests/phpunit/includes/libs/ObjectFactoryTest.php b/tests/phpunit/includes/libs/ObjectFactoryTest.php index 9220732565..a9d3cc1b20 100644 --- a/tests/phpunit/includes/libs/ObjectFactoryTest.php +++ b/tests/phpunit/includes/libs/ObjectFactoryTest.php @@ -26,7 +26,9 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { public function testClosureExpansionDisabled() { $obj = ObjectFactory::getObjectFromSpec( array( 'class' => 'ObjectFactoryTest_Fixture', - 'args' => array( function (){ return 'unwrapped'; }, ), + 'args' => array( function() { + return 'unwrapped'; + }, ), 'closure_expansion' => false, ) ); $this->assertInstanceOf( 'Closure', $obj->args[0] ); @@ -39,7 +41,9 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { public function testClosureExpansionEnabled() { $obj = ObjectFactory::getObjectFromSpec( array( 'class' => 'ObjectFactoryTest_Fixture', - 'args' => array( function (){ return 'unwrapped'; }, ), + 'args' => array( function() { + return 'unwrapped'; + }, ), 'closure_expansion' => true, ) ); $this->assertInternalType( 'string', $obj->args[0] ); @@ -47,7 +51,9 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { $obj = ObjectFactory::getObjectFromSpec( array( 'class' => 'ObjectFactoryTest_Fixture', - 'args' => array( function (){ return 'unwrapped'; }, ), + 'args' => array( function() { + return 'unwrapped'; + }, ), ) ); $this->assertInternalType( 'string', $obj->args[0] ); $this->assertSame( 'unwrapped', $obj->args[0] ); @@ -56,5 +62,7 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { class ObjectFactoryTest_Fixture { public $args; - public function __construct( /*...*/ ) { $this->args = func_get_args(); } + public function __construct( /*...*/ ) { + $this->args = func_get_args(); + } } diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php index 64b195d823..b11b1a9f6b 100644 --- a/tests/phpunit/includes/site/SiteImporterTest.php +++ b/tests/phpunit/includes/site/SiteImporterTest.php @@ -141,12 +141,12 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { /** * @dataProvider provideImportFromXML */ - public function testImportFromXML( $xml, array $expectedSites, $errorCount = 0 ) { + public function testImportFromXML( $xml, array $expectedSites, $errorCount = 0 ) { $importer = $this->newSiteImporter( $expectedSites, $errorCount ); $importer->importFromXML( $xml ); } - public function testImportFromXML_malformed() { + public function testImportFromXML_malformed() { $this->setExpectedException( 'Exception' ); $store = $this->getMock( 'SiteStore' ); @@ -154,7 +154,7 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { $importer->importFromXML( 'THIS IS NOT XML' ); } - public function testImportFromFile() { + public function testImportFromFile() { $foo = Site::newForType( Site::TYPE_UNKNOWN ); $foo->setGlobalId( 'Foo' ); -- 2.20.1