Almost all integers in WordPress are treated as strings.
If you try to var_dump($post->ID);
inside a loop you notice also post id is a string.
Normally this is not a problem because of PHP auto type casting feature.
This can be a problem, when you do strict comparison, like 1 === $post->ID
or in_array(1, $ids, true);
but this never happen in core for integers (in core strict comparison is used only for some strings or to differe 0
from false
).
Out of core (plugin, themes), is close to impossible (and close to crazy) that someone code something like:
$found_posts === "1"
so feel free to return integers as integers, (that is the right way) you’ll have no problems: the reason that core sometimes is bad, is not a reason to being bad too.
Just be aware that if you want to use strict comparison (that’s better) you have to manual type cast any WordPress integer:
(int) $found_posts === 1