I'm dabbling w/ a 'lightweight' PSR-0 AutoLoader for a WordPress Plugin, it runs fine on my local dev server, but when i push it up to one of WPEngine's staging servers, i get this:
Parse error: syntax error, unexpected '[', expecting ')' in /nas/wp/www/staging/ahsodesigns/wp-content/plugins/AhSoFunctionality/start.php on line 30
here's the AutoLoader,
// lightweight psr-0 autoloader
spl_autoload_register(function ($classname) {
// make sure we're only loading classes from our directory,
if (preg_match('/AhSo/',$classname)) {
$classname = ltrim($classname, "\\");
preg_match('/^(.+)?([^\\\\]+)$/U', $classname, $match);
$classname = str_replace("\\", "/", $match[1])
. str_replace(["\\", "_"], "/", $match[2])
. ".php";
include_once $classname;
}
});
the issue is on this line,
$classname = str_replace("\\", "/", $match[1])
. str_replace(["\\", "_"], "/", $match[2])
. ".php";
apparently it doesn't like the brackets... i've tried a few quick things, like moving the concatenation all to one line. no luck, i'm guessing it's probably some kind of php.ini thing, or maybe i've got a rogue line ending character in their that WPEngine's php config doesn't like. the file was built in phpStorm w/ Unix line separators '\n'. i wish i had more time to mess with it, but you know how that goes. thanks again stack. best. resource. ever.