Skip to content

Commit c0c9804

Browse files
committed
Fix all types
1 parent 2fc44b2 commit c0c9804

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ parameters:
77
- tiny-nav-menu-cache.php
88
- tiny-translation-cache.php
99
ignoreErrors:
10-
# - '#^Function do_action invoked with [345] parameters, 1-2 required\.$#'
1110
- '#^Function apply_filters invoked with [345] parameters, 2 required\.$#'
11+
- '#^Function do_action invoked with [345] parameters, 1-2 required\.$#'
1212
-
1313
path: tiny-nav-menu-cache.php
1414
message: '#^Access to an undefined property object::\$menu_id\.$#'

tiny-cache.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function tiny_cache_skip_cache() {
3232
*
3333
* @param string $more_link_text
3434
* @param bool $strip_teaser
35+
* @return void
3536
*/
3637
function the_content_cached( $more_link_text = null, $strip_teaser = false ) {
3738

@@ -50,6 +51,7 @@ function the_content_cached( $more_link_text = null, $strip_teaser = false ) {
5051

5152
// Cache hit.
5253
if ( $found ) {
54+
/** @var string $cached */
5355
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
5456
print $cached;
5557

@@ -81,6 +83,7 @@ function the_content_cached( $more_link_text = null, $strip_teaser = false ) {
8183
*
8284
* @param string $more_link_text
8385
* @param bool $strip_teaser
86+
* @return string
8487
*/
8588
function get_the_content_cached( $more_link_text = null, $strip_teaser = false ) {
8689

@@ -97,6 +100,7 @@ function get_the_content_cached( $more_link_text = null, $strip_teaser = false )
97100

98101
// Cache hit.
99102
if ( $found ) {
103+
/** @var string $cached */
100104
return $cached;
101105
}
102106

@@ -148,6 +152,7 @@ function tiny_cache_save_the_content( $content ) {
148152
* @param string $slug
149153
* @param string $name
150154
* @param string $version_hash
155+
* @return void
151156
*/
152157
function get_template_part_cached( $slug, $name = null, $version_hash = '' ) {
153158

@@ -174,6 +179,7 @@ function get_template_part_cached( $slug, $name = null, $version_hash = '' ) {
174179

175180
// Cache hit.
176181
if ( $found ) {
182+
/** @var string $cached */
177183
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
178184
print $cached;
179185

@@ -199,6 +205,7 @@ function get_template_part_cached( $slug, $name = null, $version_hash = '' ) {
199205
* Delete cached content by ID.
200206
*
201207
* @param int $post_id
208+
* @return void
202209
*/
203210
function tiny_cache_delete_the_content( $post_id ) {
204211

@@ -211,6 +218,7 @@ function tiny_cache_delete_the_content( $post_id ) {
211218
* @param string $new_status
212219
* @param string $old_status
213220
* @param \WP_Post $post
221+
* @return void
214222
*/
215223
function tiny_cache_post_transition( $new_status, $old_status, $post ) {
216224

@@ -224,6 +232,8 @@ function tiny_cache_post_transition( $new_status, $old_status, $post ) {
224232

225233
/**
226234
* Hook cache delete actions.
235+
*
236+
* @return void
227237
*/
228238
function tiny_cache_actions() {
229239

tiny-translation-cache.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ public function __construct() {
2626
add_action( 'muplugins_loaded', array( $this, 'init' ) );
2727
}
2828

29+
/**
30+
* @return void
31+
*/
2932
public function init() {
3033

3134
add_filter( 'override_load_textdomain', array( $this, 'load_textdomain' ), 30, 3 );
3235
}
3336

37+
/**
38+
* @param bool $override
39+
* @param string $domain
40+
* @param string $mofile
41+
* @return bool
42+
*/
3443
public function load_textdomain( $override, $domain, $mofile ) {
3544

3645
// Copied from core
@@ -39,8 +48,9 @@ public function load_textdomain( $override, $domain, $mofile ) {
3948

4049
$mo = new \MO();
4150
$key = $this->get_key( $domain, $mofile );
42-
$found = null;
51+
$found = false;
4352
// @TODO Compress stored data unserialize() and gzinflate( $ )
53+
/** @var array{entries?: string, headers?: array<mixed>} $cache */
4454
$cache = wp_cache_get( $key, self::GROUP, false, $found );
4555

4656
if ( $found && isset( $cache['entries'], $cache['headers'] ) ) {
@@ -73,13 +83,21 @@ public function load_textdomain( $override, $domain, $mofile ) {
7383
return true;
7484
}
7585

86+
/**
87+
* @param string $domain
88+
* @param string $mofile
89+
* @return string
90+
*/
7691
private function get_key( $domain, $mofile ) {
7792

7893
// @FIXME Why do we need text domain? Isn't the full path exact enough?
7994
// Hash of text domain and .mo file path
8095
return md5( $domain . $mofile );
8196
}
8297

98+
/**
99+
* @return void
100+
*/
83101
private function exit_with_instructions() {
84102

85103
$doc_root = isset( $_SERVER['DOCUMENT_ROOT'] ) ? $_SERVER['DOCUMENT_ROOT'] : ABSPATH; // WPCS: input var, sanitization ok.

0 commit comments

Comments
 (0)