mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup spl_autoload and use native autoloader (lowercase)
Rename lessphp for default autoloader
This commit is contained in:
parent
1cf7344ef5
commit
662eb59d40
4 changed files with 17 additions and 70 deletions
|
|
@ -5,34 +5,24 @@ if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
|
||||||
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
|
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
|
||||||
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
|
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
|
||||||
|
|
||||||
\define('RAINLOOP_INCLUDE_AS_API_DEF', isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API']);
|
|
||||||
|
|
||||||
function rainLoopSplAutoloadNamespaces() : array
|
|
||||||
{
|
|
||||||
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis', 'MailSo') :
|
|
||||||
array('RainLoop', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'MailSo');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sClassName
|
* @param string $sClassName
|
||||||
*/
|
*/
|
||||||
function rainLoopSplAutoloadRegisterFunction($sClassName) : void
|
function rainLoopSplAutoloadRegisterFunction($sClassName) : void
|
||||||
{
|
{
|
||||||
if ($sClassName && '\\' === $sClassName[0])
|
/** case-sensitive autoload */
|
||||||
{
|
$file = \strtr($sClassName, '\\', DIRECTORY_SEPARATOR) . '.php';
|
||||||
$sClassName = \substr($sClassName, 1);
|
// if ($file = \stream_resolve_include_path($file)) {
|
||||||
}
|
if (\is_file(RAINLOOP_APP_LIBRARIES_PATH . $file)) {
|
||||||
|
include_once RAINLOOP_APP_LIBRARIES_PATH . $file;
|
||||||
foreach (rainLoopSplAutoloadNamespaces() as $sNamespaceName)
|
|
||||||
{
|
|
||||||
if (0 === \strpos($sClassName, $sNamespaceName.'\\'))
|
|
||||||
{
|
|
||||||
include RAINLOOP_APP_LIBRARIES_PATH.\strtr($sClassName, '\\', '/').'.php';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false === \set_include_path(RAINLOOP_APP_LIBRARIES_PATH . PATH_SEPARATOR . \get_include_path())) {
|
||||||
|
exit('set_include_path() failed. Probably due to Apache config using php_admin_value instead of php_value');
|
||||||
|
}
|
||||||
|
\spl_autoload_extensions('.php');
|
||||||
|
\spl_autoload_register();
|
||||||
\spl_autoload_register('rainLoopSplAutoloadRegisterFunction');
|
\spl_autoload_register('rainLoopSplAutoloadRegisterFunction');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +40,7 @@ if (\class_exists('RainLoop\Api'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RAINLOOP_INCLUDE_AS_API_DEF)
|
if (!empty($_ENV['RAINLOOP_INCLUDE_AS_API']))
|
||||||
{
|
{
|
||||||
if (!\defined('APP_API_STARTED'))
|
if (!\defined('APP_API_STARTED'))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -625,10 +625,7 @@ class ServiceActions
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/lessphp/ctype.php';
|
$oLess = new \LessPHP\lessc();
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/lessphp/lessc.inc.php';
|
|
||||||
|
|
||||||
$oLess = new \RainLoopVendor\lessc();
|
|
||||||
$oLess->setFormatter('compressed');
|
$oLess->setFormatter('compressed');
|
||||||
|
|
||||||
$aResult = array();
|
$aResult = array();
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
if (!function_exists('ctype_digit'))
|
|
||||||
{
|
|
||||||
function ctype_digit($text)
|
|
||||||
{
|
|
||||||
if (is_string($text))
|
|
||||||
{
|
|
||||||
if ('' === $text)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !!preg_match('/^[\d]+$/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('ctype_space'))
|
|
||||||
{
|
|
||||||
function ctype_space($text)
|
|
||||||
{
|
|
||||||
if ('' === $text)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !!preg_match('/^[\s]+$/m', $text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('ctype_alnum'))
|
|
||||||
{
|
|
||||||
function ctype_alnum($sVar)
|
|
||||||
{
|
|
||||||
return !!preg_match('/^[a-zA-Z0-9]+$/', $sVar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace RainLoopVendor;
|
namespace LessPHP;
|
||||||
|
|
||||||
class stdClass extends \stdClass {};
|
class stdClass extends \stdClass {};
|
||||||
class Exception extends \Exception {};
|
class Exception extends \Exception {};
|
||||||
|
|
@ -1819,7 +1819,7 @@ class lessc {
|
||||||
$className = "lessc_formatter_$this->formatterName";
|
$className = "lessc_formatter_$this->formatterName";
|
||||||
}
|
}
|
||||||
|
|
||||||
$className = 'RainLoopVendor\\'.$className;
|
$className = 'LessPHP\\'.$className;
|
||||||
return new $className;
|
return new $className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2099,7 +2099,7 @@ class lessc_parser {
|
||||||
|
|
||||||
if (!self::$operatorString) {
|
if (!self::$operatorString) {
|
||||||
self::$operatorString =
|
self::$operatorString =
|
||||||
'('.implode('|', array_map(array('RainLoopVendor\\lessc', 'preg_quote'),
|
'('.implode('|', array_map(array('LessPHP\\lessc', 'preg_quote'),
|
||||||
array_keys(self::$precedence))).')';
|
array_keys(self::$precedence))).')';
|
||||||
|
|
||||||
$commentSingle = lessc::preg_quote(self::$commentSingle);
|
$commentSingle = lessc::preg_quote(self::$commentSingle);
|
||||||
|
|
@ -2329,7 +2329,7 @@ class lessc_parser {
|
||||||
protected function isDirective($dirname, $directives) {
|
protected function isDirective($dirname, $directives) {
|
||||||
// TODO: cache pattern in parser
|
// TODO: cache pattern in parser
|
||||||
$pattern = implode('|',
|
$pattern = implode('|',
|
||||||
array_map(array('RainLoopVendor\\lessc', 'preg_quote'), $directives));
|
array_map(array('LessPHP\\lessc', 'preg_quote'), $directives));
|
||||||
$pattern = '/^(-[a-z-]+-)?(' . $pattern . ')$/i';
|
$pattern = '/^(-[a-z-]+-)?(' . $pattern . ')$/i';
|
||||||
|
|
||||||
return preg_match($pattern, $dirname);
|
return preg_match($pattern, $dirname);
|
||||||
|
|
@ -2617,7 +2617,7 @@ class lessc_parser {
|
||||||
$this->eatWhiteDefault = false;
|
$this->eatWhiteDefault = false;
|
||||||
|
|
||||||
$stop = array("'", '"', "@{", $end);
|
$stop = array("'", '"', "@{", $end);
|
||||||
$stop = array_map(array('RainLoopVendor\\lessc', 'preg_quote'), $stop);
|
$stop = array_map(array('LessPHP\\lessc', 'preg_quote'), $stop);
|
||||||
// $stop[] = self::$commentMulti;
|
// $stop[] = self::$commentMulti;
|
||||||
|
|
||||||
if (!is_null($rejectStrs)) {
|
if (!is_null($rejectStrs)) {
|
||||||
Loading…
Add table
Add a link
Reference in a new issue