Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP language barrier design problem
    primarykey
    data
    text
    <h2>Background</h2> <p>I need to design a set of utility classes that will ease out file system access to several types of remote services (Local, FTP, WebDAV, SVN, SSH), and I cannot seem to get a "perfect" design mostly because of a language barrier - I feel that every design path I have chosen was scraped because PHP did not have support for a specific feature.</p> <p>I find this frustrating and I'm out of ideas.</p> <h2>Requirements</h2> <p>A base abstract class or interface for <code>FileSystem</code> which every other file system type inherits. The <code>FileSystem</code> class (and it's subclasses) are a 'driver' that implement basic FS operations such as 'move', 'remove', 'create' and so on. </p> <p>Those driver operations should not be exposed to the class user, instead, <code>FileSystem</code> is also a factory that fetches file info records upon request.</p> <p>A file is also based on an abstract class or interface <code>File</code> and <code>Directory</code>, which the implementors of a <code>FileSystem</code> subclass may or may not subclass. Users of a <code>FileSystem</code> class do not 'care' about the type of a <code>File</code> (<code>SshFile</code> and <code>SvnFile</code> should work the same).</p> <p>The <code>File</code> (and <code>Directory</code>) class should be the one to talk to the file system driver that created it in some way without the user being able to do it manually through the <code>FileSystem</code> driver.</p> <h2>What I have tried</h2> <p>Naturally I made <code>FileSystem</code> an abstract class, then proceeded to code the class <code>File</code> and turns out that PHP has no <code>friend</code> support, so <code>File</code> cannot have access to <code>FileSystem</code>'s protected driver methods.</p> <p>Another idea that got scraped was a class inside a class - <code>FileSystem</code> and <code>FileSystem::File</code> - PHP does not have nested classes.</p> <p>Divide <code>FileSystem</code> into <code>FileSystemDriver</code> and <code>FileSystemFactory</code>, but that gets me into the same original problem.</p> <h2>300 Reputation points in bounty reward</h2> <p>To a solver of an original idea to PHP's lack of programming utilities needed for encapsulation.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload