No, you don't call methods with "." in PHP. That's Java or some kind. Only thing I can think of using a "." is to concatenate a string in PHP.
The global template object $xf
inherits a lot of other objects such as the current visitor. And via template syntax you can both access methods and objects through ".". Template methods, though, have to follow a naming scheme which you can find in XF\Util\Php
public static function nameIndicatesReadOnly($name)
. visitor()
does not fit the scheme, so it get's rejected.