Skip to content

Commit aeba9d1

Browse files
Code Modernization: Use dirname() with the $levels parameter.
PHP 7.0 introduced the `$levels` parameter to the `dirname()` function, which means nested calls to `dirname()` are no longer needed. Note: This is enforced by WPCS 3.0.0. Reference: [https://www.php.net/manual/en/function.dirname.php PHP Manual: dirname()]. Follow-up to [56141]. Props jrf. See #59161, #58831. git-svn-id: https://develop.svn.wordpress.org/trunk@56552 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 858bd4b commit aeba9d1

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/wp-admin/includes/theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function get_page_templates( $post = null, $post_type = 'page' ) {
156156
* @return string
157157
*/
158158
function _get_template_edit_filename( $fullpath, $containingfolder ) {
159-
return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
159+
return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
160160
}
161161

162162
/**

src/wp-admin/maint/repair.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
define( 'WP_REPAIRING', true );
99

10-
require_once dirname( dirname( __DIR__ ) ) . '/wp-load.php';
10+
require_once dirname( __DIR__, 2 ) . '/wp-load.php';
1111

1212
header( 'Content-Type: text/html; charset=utf-8' );
1313
?>

tests/phpunit/includes/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
1111
// Support the config file from the root of the develop repository.
1212
if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
13-
$config_file_path = dirname( dirname( $config_file_path ) );
13+
$config_file_path = dirname( $config_file_path, 2 );
1414
}
1515
}
1616
$config_file_path .= '/wp-tests-config.php';
@@ -79,7 +79,7 @@
7979
*/
8080
if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) {
8181
// Default location of the autoloader for WP core test runs.
82-
$phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
82+
$phpunit_polyfills_autoloader = dirname( __DIR__, 3 ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
8383
$phpunit_polyfills_error = false;
8484

8585
// Allow for a custom installation location to be provided for plugin/theme integration tests.

tests/phpunit/tests/filesystem/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function filter_fs_method( $method ) {
2424
return 'MockFS';
2525
}
2626
public function filter_abstraction_file( $file ) {
27-
return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php';
27+
return dirname( __DIR__, 2 ) . '/includes/mock-fs.php';
2828
}
2929

3030
public function test_is_MockFS_sane() {

tests/phpunit/tests/pomo/pluralForms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected static function parenthesize_plural_expression( $expression ) {
4343
* @group external-http
4444
*/
4545
public function test_regression( $lang, $nplurals, $expression ) {
46-
require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php';
46+
require_once dirname( __DIR__, 2 ) . '/includes/plural-form-function.php';
4747

4848
$parenthesized = self::parenthesize_plural_expression( $expression );
4949
$old_style = tests_make_plural_form_function( $nplurals, $parenthesized );

0 commit comments

Comments
 (0)