It should be mentioned that the function returns the name of the directory if "filename" is of type "directory". Hence
<?php
$info = new SplFileInfo('/path/to/');
var_dump($info->getFilename());
?>
should return "to"
The function name is kind of misleading here and I am glad to have it tried.