Re[2]: [PEAR-DEV] New package proposal
| From: | Dmitry Koteroff | Date: | Mon, 31 May 2004 23:57:35 +0000 |
| Subject: | Re[2]: [PEAR-DEV] New package proposal | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-29823@lists.php.net to get a copy of this message | ||
>> > Purpose of my package is NOT beautifying PHP code. It is used on
>> > run-time, not while developing.
>> Anyway, shouldn't people be writing good code to begin with and not need
>> auto-correction on the fly? Come on, how hard is it to use the proper
>> class/file name?
CG> For Windows users who don't think about case and end up distributing their
CG> source to *NIX, this could be helpfull.
CG> However, I doubt that if said Windows user knew about this package, he'd
CG> know enough to use correct caps, hopefully.
You are talking about:
require_once "a.php";
require_once "A.php";
// included twice on Windows!
Yes. But the goal of this package is not to correct windows
names.
CG> The on-demand/ auto-loading features however do sound interresting,
CG> especially if the class'd do more then a simple _ to / translation and
CG> globbing the inc-path for that file.
Of course it does. In __autoload() method lovercase classname is
passed! My library searches for corresponding filename (in any
case) in the include_file directories ("_" is translated to "/")
and returns needed file name.
http://pear.php.net/pepr/pepr-proposal-show.php?id=82
http://php.dklab.ru/PEAR/NameScheme.php
function name2path($classname, $absolutize=false) {
$parts = explode("_", $classname.".".PEAR_NameScheme_ext);
foreach (PEAR_NameScheme::getInc($absolutize) as $libDir) {
$path = $libDir;
$found = true;
foreach ($parts as $part) {
$casePart = false;
$d = @opendir($path); if (!$d) continue;
while (false !== ($e = readdir($d))) {
if ($e == "." || $e == "..") continue;
if (!strcasecmp($e, $part)) {
$casePart = $e;
break;
}
}
closedir($d);
if ($casePart === false) { $found = false; break; }
$path .= "/".$casePart;
}
if ($found) {
if (!$absolutize) return substr($path, strlen($libDir)+1);
else return $path;
}
}
return false;
}
--
Best regards,
Dmitry Koteroff.