Resetting and moving the proposal writeup to a github hosted markdown file here: https://github.com/michael-lloyd-morris/php-modules-rfc/blob/main/php-modules.md
On Mon, May 5, 2025 at 12:44 AM Larry Garfield <la...@garfieldtech.com> wrote: > > > So before you get indignant and call me a liar ("You're 4 for 4 on > falsehoods"), perhaps consider how someone you know is "more intelligent" > than this can come away from your post understanding it so utterly > differently than what you intended. > I'm sorry for doing that. > > From your follow up statements, it seems that what you are proposing is > not "modules" in any sense used in any language I am familiar with. > Rather, you're proposing a symbol table hack to get around PHP's inability > to load two symbols with the same name, and using module terminology to > inaccurately describe it. (And thread terminology as well.) That is, it > seems your intent is that I can import arbitrary code from an arbitrary > package and shunt it off to a separate symbol table. But it's not clear if > you intend for the package author to have to do anything to enable that. > Your answers seem contradictory. > > For a concrete example, I'll offer my AttributeUtils library: > https://github.com/Crell/AttributeUtils/tree/master/src > > It has a whole bunch of interfaces, plus a few classes. We'll focus on a > subset of them for the moment. > > Analyzer.php (this is the main class someone uses) > AttributeParser.php (this is an internal class used by Analyzer, you > should never use it directly) > FromReflectionClass.php (an interface that other libraries implement to > trigger certain functionality in Analyzer) > > In answer to your question - assuming the module file is at the root of your src directory. <?php module \Crell\AnalyzerModule; export [ \Crell\Analyzer, \Crell\FromReflectionClass ]; ?> > Say I want to modularize this library, under your proposal. What would I, > as the library author, do exactly? Anything? How can I mark > AttributeParser as internal-only and thou-shalt-not-use-if-you're-not-me? > (That's the most common value of module systems, and the one most people in > PHP seem to think of, from what I've seen.) > > That library is used extensively by Serde (another of my libraries). If I > modularize AttributeUtils, then what changes does Serde need to make? On that end <?php require_module <path_to_Crell\AnalyzerModule>; $analyzer = new \Crell\AnalyzerModule::Analyzer(); ?> If the autoloader gets updated to identify and properly load modules (outside the scope of this RFC) the require_module statement can be dropped. If a use statement is desired it looks like this <?php use \Crell\AnalyzerModule::Analyzer; // This is legal for modules, not for static classes. $analyzer = new Analyzer(); ?> > What would it get out of doing so? > Nothing much - it just wouldn't be able to see as deeply into the AttributeUtils code.