From 9bfa7303627983c13607536aae839e7e0ebb0968 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 30 Jun 2020 09:30:09 +0200 Subject: [PATCH] Add compatibility layer from leafo/scssphp to scssphp/scssphp The basic usage of this compatibility layer appears to work well: A CSS file can be compiled from the default style, without needing any additional adjustments. What this compatibility layer cannot do is rewrite the Exceptions that are thrown by scssphp/scssphp. A strict catch block catching a specific Exception, such as `\Leafo\ScssPhp\Exception\ParserException` will not match the aliased `ScssPhp\ScssPhp\Exception\ParserException`. Resolves #3398 --- wcfsetup/install/files/lib/core.functions.php | 10 ++++++++++ .../files/lib/system/style/scssphp/scss.inc.php | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/core.functions.php b/wcfsetup/install/files/lib/core.functions.php index 6e53aacb03..adfe6593a2 100644 --- a/wcfsetup/install/files/lib/core.functions.php +++ b/wcfsetup/install/files/lib/core.functions.php @@ -17,6 +17,16 @@ namespace { // set autoload function spl_autoload_register([WCF::class, 'autoload']); + spl_autoload_register(function ($className) { + /** + * @deprecated 5.3 This file is a compatibility layer mapping from Leafo\\ to ScssPhp\\ + */ + $leafo = 'Leafo\\'; + if (substr($className, 0, strlen($leafo)) === $leafo) { + class_alias('ScssPhp\\'.substr($className, strlen($leafo)), $className, true); + } + }); + /** * Escapes a string for use in sql query. * diff --git a/wcfsetup/install/files/lib/system/style/scssphp/scss.inc.php b/wcfsetup/install/files/lib/system/style/scssphp/scss.inc.php index c7038bfcd4..2916dee430 100644 --- a/wcfsetup/install/files/lib/system/style/scssphp/scss.inc.php +++ b/wcfsetup/install/files/lib/system/style/scssphp/scss.inc.php @@ -1,2 +1,5 @@