Code Modernization: Replace substr( PHP_OS, 0, 3 ) calls with PHP_OS_FAMILY.

The `PHP_OS_FAMILY` constant indicates the operating system family PHP was built for, and is available as of PHP 7.2.0.

Reference: [https://www.php.net/manual/en/reserved.constants.php#constant.php-os-family PHP Manual: Predefined Constants: PHP_OS_FAMILY].

Follow-up to [23255], [57753], [57985], [58678].

Props ayeshrajans, jrf.
See #61574.

git-svn-id: https://develop.svn.wordpress.org/trunk@58684 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2024-07-07 12:42:44 +00:00
parent 55e0fafbbf
commit e3e7fdbf7c
2 changed files with 4 additions and 4 deletions

View File

@ -2257,11 +2257,11 @@ function get_temp_dir() {
* @return bool Whether the path is writable.
*/
function wp_is_writable( $path ) {
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) {
if ( 'Windows' === PHP_OS_FAMILY ) {
return win_is_writable( $path );
} else {
return @is_writable( $path );
}
return @is_writable( $path );
}
/**

View File

@ -160,7 +160,7 @@ abstract class WP_Filesystem_Direct_UnitTestCase extends WP_UnitTestCase {
* @return bool Whether the operating system is Windows.
*/
public static function is_windows() {
return 'WIN' === substr( PHP_OS, 0, 3 );
return 'Windows' === PHP_OS_FAMILY;
}
/**