Skip to content

Commit 393e343

Browse files
committed
class aliases are loaded on demand
1 parent 863f8a6 commit 393e343

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
"tracy/tracy": "<2.5"
4444
},
4545
"autoload": {
46-
"classmap": ["src/"],
47-
"files": ["src/compatibility.php"]
46+
"classmap": ["src/"]
4847
},
4948
"minimum-stability": "dev",
5049
"scripts": {

src/Application/UI/Component.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,6 @@ public function error(string $message = '', int $httpCode = Nette\Http\IResponse
312312
throw new Nette\Application\BadRequestException($message, $httpCode);
313313
}
314314
}
315+
316+
317+
class_exists(PresenterComponent::class);

src/Application/UI/ComponentReflection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,6 @@ public static function getClassesAndTraits(string $class): array
310310
return $res;
311311
}
312312
}
313+
314+
315+
class_exists(PresenterComponentReflection::class);

src/compatibility.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,22 @@
77

88
declare(strict_types=1);
99

10-
class_alias(Nette\Application\UI\Component::class, Nette\Application\UI\PresenterComponent::class);
11-
class_alias(Nette\Application\UI\ComponentReflection::class, Nette\Application\UI\PresenterComponentReflection::class);
10+
namespace Nette\Application\UI;
11+
12+
if (false) {
13+
/** @deprecated use Nette\Application\UI\Component */
14+
class PresenterComponent
15+
{
16+
}
17+
} elseif (!class_exists(PresenterComponent::class)) {
18+
class_alias(Component::class, PresenterComponent::class);
19+
}
20+
21+
if (false) {
22+
/** @deprecated use Nette\Application\UI\ComponentReflection */
23+
class PresenterComponentReflection
24+
{
25+
}
26+
} elseif (!class_exists(PresenterComponentReflection::class)) {
27+
class_alias(ComponentReflection::class, PresenterComponentReflection::class);
28+
}

0 commit comments

Comments
 (0)