- App
- WoltLab Suite Core
Hallo zusammen,
ich erstelle diesen Vorschlag, als Vorschlag doch auch zeitgleich als Frage.
Wieso ist der Coding Style des WCFs an PSR-2 angelehnt, aber folgt dem Standard nicht ganz? Um mal ein aktuelles BSP zu zeigen was die Änderung erzeugen würde:
Display Spoiler
PHP
/**
* Includes the required util or exception classes automatically.
*
* @param string $className
* @see spl_autoload_register()
*/
public static final function autoload($className) {
$namespaces = explode('\\', $className);
if (count($namespaces) > 1) {
$applicationPrefix = array_shift($namespaces);
if ($applicationPrefix === '') {
$applicationPrefix = array_shift($namespaces);
}
if (isset(self::$autoloadDirectories[$applicationPrefix])) {
$classPath = self::$autoloadDirectories[$applicationPrefix] . implode('/', $namespaces) . '.class.php';
if (file_exists($classPath)) {
require_once($classPath);
}
else {
// If File doesn´t exists with .class.php try to find it without .class
$classPathWithoutClass = self::$autoloadDirectories[$applicationPrefix] . implode('/', $namespaces) . '.php';
if (file_exists($classPathWithoutClass)) {
require_once($classPathWithoutClass);
}
}
}
}
}
Display More
würde zu
PHP
/**
* Includes the required util or exception classes automatically.
*
* @param string $className
*
* @see spl_autoload_register()
*/
public static final function autoload($className)
{
$namespaces = explode('\\', $className);
if (count($namespaces) > 1) {
$applicationPrefix = array_shift($namespaces);
if ($applicationPrefix === '') {
$applicationPrefix = array_shift($namespaces);
}
if (isset(self::$autoloadDirectories[$applicationPrefix])) {
$classPath = self::$autoloadDirectories[$applicationPrefix] . implode('/', $namespaces) . '.class.php';
if (file_exists($classPath)) {
require_once($classPath);
} else {
// If File doesn´t exists with .class.php try to find it without .class
$classPathWithoutClass = self::$autoloadDirectories[$applicationPrefix] . implode('/', $namespaces) . '.php';
if (file_exists($classPathWithoutClass)) {
require_once($classPathWithoutClass);
}
}
}
}
}
Display More
Die Umsetzung sollte auch nicht allzu große Probleme bereiten, da es meist nur eine IDE Einstellung ist.
Liebe Grüße