Skip to content

Commit 508b043

Browse files
committed
Apply some suggestions
1 parent da74556 commit 508b043

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Context/FeatureContext.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,12 @@ private static function configure_sqlite( $dir ): void {
606606
$db_copy = $dir . '/wp-content/mu-plugins/sqlite-database-integration/db.copy';
607607
$db_dropin = $dir . '/wp-content/db.php';
608608

609+
$db_copy_contents = file_get_contents( $db_copy );
610+
611+
if ( false === $db_copy_contents ) {
612+
return;
613+
}
614+
609615
/* similar to https://github.com/WordPress/sqlite-database-integration/blob/3306576c9b606bc23bbb26c15383fef08e03ab11/activate.php#L95 */
610616
$file_contents = str_replace(
611617
array(
@@ -618,7 +624,7 @@ private static function configure_sqlite( $dir ): void {
618624
'sqlite-database-integration/load.php',
619625
'/mu-plugins/',
620626
),
621-
file_get_contents( $db_copy )
627+
$db_copy_contents
622628
);
623629

624630
file_put_contents( $db_dropin, $file_contents );
@@ -916,7 +922,7 @@ private function replace_invoke_wp_cli_with_php_args( $str ) {
916922
$phar_begin_len = strlen( $phar_begin );
917923
$bin_dir = getenv( 'WP_CLI_BIN_DIR' );
918924
$bin = Utils\is_windows() ? 'wp.bat' : 'wp';
919-
if ( false !== $bin_dir && file_exists( $bin_dir . '/wp' ) && file_get_contents( $bin_dir . '/wp', false, null, 0, $phar_begin_len ) === $phar_begin ) {
925+
if ( false !== $bin_dir && file_exists( $bin_dir . DIRECTORY_SEPARATOR . $bin ) && (string) file_get_contents( $bin_dir . DIRECTORY_SEPARATOR . $bin, false, null, 0, $phar_begin_len ) === $phar_begin ) {
920926
$phar_path = $bin_dir . $bin;
921927
} else {
922928
$src_dir = dirname( __DIR__, 2 );
@@ -1278,7 +1284,7 @@ public function background_proc( $cmd ): void {
12781284

12791285
if ( ! $status['running'] ) {
12801286
if ( Utils\is_windows() ) {
1281-
$stderr = file_get_contents( $stderr_file );
1287+
$stderr = (string) file_get_contents( $stderr_file );
12821288
$stderr = $stderr ? ': ' . $stderr : '';
12831289
} else {
12841290
$stderr = is_resource( $pipes[2] ) ? ( ': ' . stream_get_contents( $pipes[2] ) ) : '';
@@ -1879,7 +1885,7 @@ function wpcli_bootstrap_behat_feature_context(): void {
18791885
return;
18801886
}
18811887

1882-
$composer = json_decode( file_get_contents( $project_composer ) );
1888+
$composer = json_decode( (string) file_get_contents( $project_composer ) );
18831889
if ( empty( $composer->autoload->files ) ) {
18841890
return;
18851891
}

tests/tests/TestBehatTags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ private function remove_dir( $dir ): void {
4747

4848
foreach ( $iterator as $file ) {
4949
if ( $file->isDir() ) {
50-
rmdir( $file->getRealPath() );
50+
rmdir( $file->getPathname() );
5151
} else {
52-
unlink( $file->getRealPath() );
52+
unlink( $file->getPathname() );
5353
}
5454
}
5555

0 commit comments

Comments
 (0)