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
This commit is contained in:
Sergey Biryukov
2023-09-11 04:51:09 +00:00
parent 858bd4b25f
commit aeba9d183d
5 changed files with 6 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
// Support the config file from the root of the develop repository.
if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
$config_file_path = dirname( dirname( $config_file_path ) );
$config_file_path = dirname( $config_file_path, 2 );
}
}
$config_file_path .= '/wp-tests-config.php';
@@ -79,7 +79,7 @@ if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) {
*/
if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) {
// Default location of the autoloader for WP core test runs.
$phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
$phpunit_polyfills_autoloader = dirname( __DIR__, 3 ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
$phpunit_polyfills_error = false;
// Allow for a custom installation location to be provided for plugin/theme integration tests.