PHP XSLTProcessor并将数据传递给PHP函数

I need to access some XSL data from registered PHP function in XSLTProcessor. I found how to pass current node into the function.

XSL:

<xsl:value-of select="php:function('foo', node())" />

PHP:

function foo($node)
{
    # Here we go, we got DOMNode array and as a consequence - DOMDocument
    var_dump($node);
}

OK, this part works fine. Problem is in the second part: I need to pass into PHP function all XSL variables that are visible at the call point. Or, I need to obtain XSL variable value by name from PHP function somehow. And here is the problem - I can't find how to do that. May be some special XPath request? Or some special function? Or some special trick? Or something else?