FileFolders not documented - source code bug?

Permalink
Hi together,

I wanted to add some FileFolders programmatically to my File manager. This is not documented yet, so I had a look in the source code. I found the following snippet in the FileSystem class:

public function addFolder(FileFolder $folder, $name)
    {
        return $folder->add($name, $folder);
    }


But is it very unclear to me: What is the parent? What is the new folder? is $folder the parent and $name the name of the new folder to add?

So I searched further to find that FileFolder inherits from Category where i found:

public static function add($treeNodeCategoryName = '', $parent = false)
    {
        $node = parent::add($parent);
        $node->setTreeNodeName($treeNodeCategoryName);
        return $node;
    }


Category defines add as a static function. You CAN say $folder-> in PHP, but it is not quite correct, it SHOULD read Category::add() or at least FileFolder::add(), just to make clear the current object context is not important and not used in this method.

I searched even further and found, that Category inherits from Node. In Node there is also a "add"-method, with a complete different signature:

public static function add($parent = false)


Well, thats quite a mess. You can't overload methods in PHP.

I think from PHP5.3 and further we also have some kind of late static binding and depending on how you execute the "add"-method, you will get complete different results:

$object->add(...)
FileFolder::add(...)
Category::add(...)
Node::add(...)
self::add(...)
static::add(...)


Which add-method will be used? You can't tell. So at least the add-methods of Node and Category should have the same signature? It would be good to distinguish by name. The "add" of Node actually is a "createNew". The add-method of Category actually is a "createByName".

Anyone agrees with me? Or does anyone care anyway?

I'm quite disappointed that the tree API is very bad documented and has some real interface problems, as it is a very central API for the whole system.

Any opinions on this?

oimel
 
rklomp replied on at Permalink Reply
Same problem here.

I cannot find any documentation on FileFolders.

Apparently file permissions are now enforced via the folders where it used to be the filesets.
Since I cannot find any documentation on this I have still not been able to figure out how to assign my files to a folder instead of a fileset to be able to enforce the permissions again.