From 3a3870908fe318c83b2c0ef7fca1f2244d365932 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 7 Jan 2020 17:50:36 +0100 Subject: [PATCH] class aliases are loaded on demand --- composer.json | 3 +-- src/Application/UI/Component.php | 3 +++ src/Application/UI/ComponentReflection.php | 3 +++ src/compatibility.php | 21 +++++++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index baf7148f7..d691e32b7 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,7 @@ "nette/latte": "<2.4" }, "autoload": { - "classmap": ["src/"], - "files": ["src/compatibility.php"] + "classmap": ["src/"] }, "minimum-stability": "dev", "extra": { diff --git a/src/Application/UI/Component.php b/src/Application/UI/Component.php index 426a37013..137f1945e 100644 --- a/src/Application/UI/Component.php +++ b/src/Application/UI/Component.php @@ -410,3 +410,6 @@ public function offsetUnset($name) } } } + + +class_exists(PresenterComponent::class); diff --git a/src/Application/UI/ComponentReflection.php b/src/Application/UI/ComponentReflection.php index 003a98f78..1f844e518 100644 --- a/src/Application/UI/ComponentReflection.php +++ b/src/Application/UI/ComponentReflection.php @@ -352,3 +352,6 @@ public function __call($name, $args) Nette\Utils\ObjectMixin::strictCall(get_class($this), $name); } } + + +class_exists(PresenterComponentReflection::class); diff --git a/src/compatibility.php b/src/compatibility.php index 49f2ebc5d..02c80e0b0 100644 --- a/src/compatibility.php +++ b/src/compatibility.php @@ -5,5 +5,22 @@ * Copyright (c) 2004 David Grudl (https://davidgrudl.com) */ -class_alias('Nette\Application\UI\Component', 'Nette\Application\UI\PresenterComponent'); -class_alias('Nette\Application\UI\ComponentReflection', 'Nette\Application\UI\PresenterComponentReflection'); +namespace Nette\Application\UI; + +if (false) { + /** @deprecated use Nette\Application\UI\Component */ + class PresenterComponent + { + } +} elseif (!class_exists(PresenterComponent::class)) { + class_alias(Component::class, PresenterComponent::class); +} + +if (false) { + /** @deprecated use Nette\Application\UI\ComponentReflection */ + class PresenterComponentReflection + { + } +} elseif (!class_exists(PresenterComponentReflection::class)) { + class_alias(ComponentReflection::class, PresenterComponentReflection::class); +}