Solution:
Just drop double quotes around function call, and curly braces around variable name in foreach loop:
{if ($type == 1)}
{assign var="static_php_function_result" value=dbPay::getAll(null)}
{elseif ($type == 2)}
{assign var="static_php_function_result" value=dbPay::getSomething(null)}
{/if}
{foreach from=$static_php_function_result item=dbPay}
...
{/foreach}
Remember that it does not assign function for later call, but result to operate on.