Все же написано
https://www.php.net/manual/ru/function.count.php
If you want to run through large arrays don't use count() function in the loops , its a over head in performance,  copy the count() value into a variable and use that value in loops for a better performance.
Eg:
// Bad approach
for($i=0;$i<count($some_arr);$i++)
{
    // calculations
}
// Good approach
$arr_length = count($some_arr);
for($i=0;$i<$arr_length;$i++)
{
    // calculations
}
Пример #4 Объект, реализующий интерфейс Countable
Вот тут вы можете извернуться и как то закешировать значение
<?php
class CountOfMethods implements Countable
{
    private function someMethod()
    {
    }
    public function count(): int
    {
        return count(get_class_methods($this));
    }
}
$obj = new CountOfMethods();
var_dump(count($obj));
?>