If you are using the SPL FileInfo object and then try to create the path with mkdir, don't forget that mkdir expects a string as the first argument and NOT an object...
I have forgotten that very important rules and get only a permission deny to mkdir to create new directories but in fact, the issue was the fact that i wasn't passing a string to mkdir
$my_file = new SplFileInfo('path/to/file.txt') ;
// get path from file
$parent = $my_file->getPathInfo() ;
// check if path is directory or not
if($parent->isDir())
{
// create / open file.txt file
} else {
// if path/to does not exists, create the directory recursively
mkdir($parent, 0755, true) ; // THIS WON'T WORK because $parent is a SplFileInfo object.
// instead, get the path as a string
$path = $parent->getPathname() ;
mkdir($path, 0755, true) ; // THIS WILL WORK
}