Skip to content

Commit

Permalink
Add more type hints, bump PHP requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean90 committed Nov 19, 2024
1 parent 23f1e25 commit 4388f9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"php": ">=7.4"
"php": ">=8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0",
Expand Down
8 changes: 4 additions & 4 deletions translations-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function site_status_test_apcu_php_module( array $modules ): array {
add_filter( 'site_status_test_php_modules', __NAMESPACE__ . '\site_status_test_apcu_php_module' );

// Bail early if APCu is not available.
if ( ! function_exists( 'apcu_enabled' ) || ! apcu_enabled() ) {
if ( ! \function_exists( 'apcu_enabled' ) || ! apcu_enabled() ) {
return;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ function load_textdomain( ?bool $loaded, string $domain, string $mofile, ?string
return true;
}

$wp_textdomain_registry->set( $domain, $locale, dirname( $mofile ) );
$wp_textdomain_registry->set( $domain, $locale, \dirname( $mofile ) );

// Cache the translations.
$data = [
Expand Down Expand Up @@ -172,7 +172,7 @@ function load_textdomain( ?bool $loaded, string $domain, string $mofile, ?string
* @return bool|array<string,mixed> Returns true if something has effectively been added into the cache,
* false otherwise. Second syntax returns array with error keys.
*/
function cache_add( string $key, $data, int $expire = 0 ) {
function cache_add( string $key, mixed $data, int $expire = 0 ): bool|array {
// Alter provided expire values to be within -10%/+20% of the provided time,
// to spread expires over a wider window.
$expire = rand( \intval( $expire * 0.9 ), \intval( $expire * 1.2 ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand
Expand All @@ -188,6 +188,6 @@ function cache_add( string $key, $data, int $expire = 0 ) {
* Disambiguates a return of false, a storable value. Default null.
* @return mixed The stored variable or array of variables on success; false on failure.
*/
function cache_fetch( string $key, ?bool &$found = null ) {
function cache_fetch( string $key, ?bool &$found = null ): mixed {
return apcu_fetch( $key, $found );
}

0 comments on commit 4388f9d

Please sign in to comment.