theseer / Autoload

A lightweight php namespace aware autoload generator and phar archive builder
Other
388 stars 47 forks source link

Possible to ignore ALL class redeclarations? #41

Closed chr0n1x closed 11 years ago

chr0n1x commented 11 years ago

I know that it's crappy design to have multiple files redeclaring a single class (name), but is there a way for --tolerant to ignore all class re-declarations?

theseer commented 11 years ago

The behavior of your proposed feature would be undefined as there is no known order the files get processed (they get processed in the order the directoryIterator returns them, which is not sorted by say, filename or date or anything one would directly see). This would result in an unpredictable classname to file match ending up in the map.

Even if that wouldn't be a problem already, any (general purpose) autoloading code has no information to base a decision on which file to include - read: which implementation to pick. The only information supplied is the classname.

Your only chance would be a custom autoload handler for these classes. You can configure phpab to exclude files from the resultset based on file masks. So in case they have something in common within their filename, this would be the way to go. Once theses classes got skipped, you can register your additional custom autoload handler. phpab's autoload code does not require to be the only one in the system.

tl;dr No. As this would cause unpredictable results and cause collisions in the generated map used by the autoloader.

chr0n1x commented 11 years ago

that makes sense. thank you!