From 04bef3dd66dfe0dba3b282b2c4d10701f111ab23 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 12 Nov 2015 19:58:20 +0100 Subject: [PATCH] phpcs: Use __DIR__ constant instead of calling Replaced all dirname(__FILE__) by __DIR__ or added @codingStandardsIgnore Found by tests: https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull Change-Id: I90ff10f183ed60175fe580c43d73c0e57fd04234 --- includes/PHPVersionCheck.php | 2 ++ includes/PHPVersionError.php | 2 ++ index.php | 2 ++ maintenance/Maintenance.php | 2 ++ maintenance/install.php | 2 ++ maintenance/populateFilearchiveSha1.php | 2 +- mw-config/index.php | 2 ++ .../includes/resourceloader/ResourceLoaderFileModuleTest.php | 2 +- 8 files changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/PHPVersionCheck.php b/includes/PHPVersionCheck.php index 333d04065c..41e88c29d8 100644 --- a/includes/PHPVersionCheck.php +++ b/includes/PHPVersionCheck.php @@ -40,7 +40,9 @@ function wfEntryPointCheck( $entryPoint ) { wfPHPVersionError( $entryPoint, $mwVersion, $minimumVersionPHP, $phpVersion ); } + // @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) { + // @codingStandardsIgnoreEnd wfMissingVendorError( $entryPoint, $mwVersion ); } } diff --git a/includes/PHPVersionError.php b/includes/PHPVersionError.php index 007ea8941e..9fbcf8955b 100644 --- a/includes/PHPVersionError.php +++ b/includes/PHPVersionError.php @@ -21,4 +21,6 @@ * @deprecated 1.25 * @file */ +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound require_once dirname( __FILE__ ) . '/PHPVersionCheck.php'; +// @codingStandardsIgnoreEnd diff --git a/index.php b/index.php index 67bd0c9aae..24230923bc 100644 --- a/index.php +++ b/index.php @@ -32,7 +32,9 @@ // Bail on old versions of PHP, or if composer has not been run yet to install // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+. +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound require_once dirname( __FILE__ ) . '/includes/PHPVersionCheck.php'; +// @codingStandardsIgnoreEnd wfEntryPointCheck( 'index.php' ); require __DIR__ . '/includes/WebStart.php'; diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 8dad5dc1ff..7825ce950d 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -22,7 +22,9 @@ // Bail on old versions of PHP, or if composer has not been run yet to install // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+. +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php'; +// @codingStandardsIgnoreEnd wfEntryPointCheck( 'cli' ); /** diff --git a/maintenance/install.php b/maintenance/install.php index 212e42ab38..ae3074a4c8 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -23,7 +23,9 @@ // Checking for old versions of PHP is done in Maintenance.php // We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+ +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound require_once dirname( __FILE__ ) . '/Maintenance.php'; +// @codingStandardsIgnoreEnd define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' ); define( 'MEDIAWIKI_INSTALL', true ); diff --git a/maintenance/populateFilearchiveSha1.php b/maintenance/populateFilearchiveSha1.php index 850a5a5a4e..a3099f9615 100644 --- a/maintenance/populateFilearchiveSha1.php +++ b/maintenance/populateFilearchiveSha1.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once dirname( __FILE__ ) . '/Maintenance.php'; +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script to populate the fa_sha1 field. diff --git a/mw-config/index.php b/mw-config/index.php index be811dc980..31b201c4d2 100644 --- a/mw-config/index.php +++ b/mw-config/index.php @@ -22,7 +22,9 @@ // Bail on old versions of PHP, or if composer has not been run yet to install // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+. +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php'; +// @codingStandardsIgnoreEnd wfEntryPointCheck( 'mw-config/index.php' ); define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' ); diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index 9d97b28270..a6d1d05eff 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -21,7 +21,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { private static function getModules() { $base = array( - 'localBasePath' => realpath( dirname( __FILE__ ) ), + 'localBasePath' => realpath( __DIR__ ), ); return array( -- 2.20.1