|
2 | 2 | namespace GT\WebEngine; |
3 | 3 |
|
4 | 4 | use Closure; |
5 | | -use Gt\Http\ResponseStatusException\ClientError\ClientErrorException; |
6 | | -use Gt\Http\ResponseStatusException\ResponseStatusException; |
7 | | -use Gt\Logger\Log; |
8 | | -use Gt\Logger\LogConfig; |
9 | | -use Gt\Logger\LogHandler\StdErrHandler; |
10 | | -use Gt\Logger\LogLevel; |
| 5 | +use GT\Http\ResponseStatusException\ClientError\ClientErrorException; |
| 6 | +use GT\Http\ResponseStatusException\ResponseStatusException; |
| 7 | +use GT\Logger\Log; |
| 8 | +use GT\Logger\LogConfig; |
| 9 | +use GT\Logger\LogHandler\StdErrHandler; |
| 10 | +use GT\Logger\LogLevel; |
11 | 11 | use Throwable; |
12 | 12 | use ErrorException; |
13 | 13 | use ReflectionMethod; |
|
16 | 16 | use GT\WebEngine\Redirection\Redirect; |
17 | 17 | use GT\WebEngine\Dispatch\Dispatcher; |
18 | 18 | use GT\WebEngine\Dispatch\DispatcherFactory; |
19 | | -use Gt\Config\Config; |
20 | | -use Gt\Config\ConfigFactory; |
21 | | -use Gt\Http\Request; |
22 | | -use Gt\Http\RequestFactory; |
23 | | -use Gt\Http\Response; |
24 | | -use Gt\Http\Stream; |
25 | | -use Gt\ProtectedGlobal\Protection; |
| 19 | +use GT\Config\Config; |
| 20 | +use GT\Config\ConfigFactory; |
| 21 | +use GT\Http\Request; |
| 22 | +use GT\Http\RequestFactory; |
| 23 | +use GT\Http\Response; |
| 24 | +use GT\Http\Stream; |
| 25 | +use GT\ProtectedGlobal\Protection; |
26 | 26 | use Psr\Http\Message\ServerRequestInterface; |
27 | 27 |
|
28 | 28 | /** |
@@ -216,28 +216,17 @@ private function finish( |
216 | 216 |
|
217 | 217 | /** |
218 | 218 | * Registers a namespace compatibility autoloader to bridge the |
219 | | - * Gt -> GT namespace transition. |
| 219 | + * legacy-to-GT namespace transition. |
220 | 220 | * |
221 | 221 | * As part of the PHP.GT rebranding for WebEngine v5, all references to |
222 | 222 | * "GT" are being standardised to uppercase. However, the framework |
223 | 223 | * consists of 40+ repositories that cannot all be refactored |
224 | 224 | * simultaneously. This compatibility layer allows new code to reference |
225 | 225 | * classes using the GT\ namespace while the underlying packages still |
226 | | - * define classes with the Gt\ namespace. |
| 226 | + * define classes with the legacy namespace casing. |
227 | 227 | */ |
228 | 228 | private function gtCompatibility():void { |
229 | | - spl_autoload_register(function(string $class):void { |
230 | | - if(str_starts_with($class, 'GT\\')) { |
231 | | - $legacyClass = 'Gt' . substr($class, 2); |
232 | | - // Trigger autoloading for the legacy class |
233 | | - spl_autoload_call($legacyClass); |
234 | | - // Only create alias if it was loaded and target doesn't already exist |
235 | | - if((class_exists($legacyClass, false) || interface_exists($legacyClass, false) || trait_exists($legacyClass, false)) |
236 | | - && !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)) { |
237 | | - class_alias($legacyClass, $class); |
238 | | - } |
239 | | - } |
240 | | - }, true, true); |
| 229 | + registerNamespaceCompatibilityAutoloader(); |
241 | 230 | } |
242 | 231 |
|
243 | 232 | private function protectGlobals():void { |
|
0 commit comments