Skip to content

Commit e2c471f

Browse files
committed
removed deprecated stuff
1 parent 754d299 commit e2c471f

21 files changed

+18
-208
lines changed

src/Application/PresenterFactory.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,4 @@ public function formatPresenterClass(string $presenter): string
120120
}
121121
return $mapping[0];
122122
}
123-
124-
125-
/**
126-
* Formats presenter name from class name.
127-
* @internal
128-
*/
129-
public function unformatPresenterClass(string $class): ?string
130-
{
131-
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
132-
foreach ($this->mapping as $module => $mapping) {
133-
$mapping = str_replace(['\\', '*'], ['\\\\', '(\w+)'], $mapping);
134-
if (preg_match("#^\\\\?$mapping[0]((?:$mapping[1])*)$mapping[2]$#Di", $class, $matches)) {
135-
return ($module === '*' ? '' : $module . ':')
136-
. preg_replace("#$mapping[1]#iA", '$1:', $matches[1]) . $matches[3];
137-
}
138-
}
139-
return null;
140-
}
141123
}

src/Application/Routers/Route.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,12 @@ class Route extends Nette\Routing\Route implements Nette\Routing\Router
4040
],
4141
];
4242

43-
/** @var int */
44-
private $flags;
45-
4643

4744
/**
4845
* @param string $mask e.g. '<presenter>/<action>/<id \d{1,3}>'
4946
* @param array|string|\Closure $metadata default values or metadata or callback for NetteModule\MicroPresenter
5047
*/
51-
public function __construct(string $mask, $metadata = [], int $flags = 0)
48+
public function __construct(string $mask, array|string|\Closure $metadata = [], int $flags = 0)
5249
{
5350
if (is_string($metadata)) {
5451
[$presenter, $action] = Nette\Application\Helpers::splitName($metadata);
@@ -66,12 +63,8 @@ public function __construct(string $mask, $metadata = [], int $flags = 0)
6663
];
6764
}
6865

69-
if ($flags) {
70-
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::addRoute(..., ..., $flags) instead.', E_USER_DEPRECATED);
71-
}
7266

7367
$this->defaultMeta += self::UI_META;
74-
$this->flags = $flags;
7568
parent::__construct($mask, $metadata);
7669
}
7770

@@ -106,10 +99,6 @@ public function match(Nette\Http\IRequest $httpRequest): ?array
10699
*/
107100
public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?string
108101
{
109-
if ($this->flags & self::ONE_WAY) {
110-
return null;
111-
}
112-
113102
$metadata = $this->getMetadata();
114103
if (isset($metadata[self::MODULE_KEY])) { // try split into module and [submodule:]presenter parts
115104
$presenter = $params[self::PRESENTER_KEY];
@@ -144,14 +133,6 @@ public function getConstantParameters(): array
144133
}
145134

146135

147-
/** @deprecated */
148-
public function getFlags(): int
149-
{
150-
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
151-
return $this->flags;
152-
}
153-
154-
155136
/********************* Inflectors ****************d*g**/
156137

157138

src/Application/Routers/RouteList.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* The router broker.
1717
*/
18-
class RouteList extends Nette\Routing\RouteList implements Nette\Routing\Router, \ArrayAccess, \Countable, \IteratorAggregate
18+
class RouteList extends Nette\Routing\RouteList implements Nette\Routing\Router, \ArrayAccess
1919
{
2020
private const PRESENTER_KEY = 'presenter';
2121

@@ -93,14 +93,6 @@ public function getModule(): ?string
9393
}
9494

9595

96-
/** @deprecated */
97-
public function count(): int
98-
{
99-
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
100-
return count($this->getRouters());
101-
}
102-
103-
10496
/**
10597
* @param mixed $index
10698
* @param Nette\Routing\Router $router
@@ -150,14 +142,6 @@ public function offsetUnset($index): void
150142
}
151143
$this->modify($index, null);
152144
}
153-
154-
155-
/** @deprecated */
156-
public function getIterator(): \ArrayIterator
157-
{
158-
trigger_error(__METHOD__ . '() is deprecated, use getRouters().', E_USER_DEPRECATED);
159-
return new \ArrayIterator($this->getRouters());
160-
}
161145
}
162146

163147

src/Application/Routers/SimpleRouter.php

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
*/
1919
final class SimpleRouter extends Nette\Routing\SimpleRouter implements Nette\Routing\Router
2020
{
21-
private const
22-
PRESENTER_KEY = 'presenter',
23-
MODULE_KEY = 'module';
21+
private const PRESENTER_KEY = 'presenter';
2422

25-
/** @var int */
26-
private $flags;
2723

28-
29-
public function __construct($defaults = [], int $flags = 0)
24+
public function __construct(array $defaults = [], int $flags = 0)
3025
{
3126
if (is_string($defaults)) {
3227
[$presenter, $action] = Nette\Application\Helpers::splitName($defaults);
@@ -39,35 +34,8 @@ public function __construct($defaults = [], int $flags = 0)
3934
];
4035
}
4136

42-
if (isset($defaults[self::MODULE_KEY])) {
43-
throw new Nette\DeprecatedException(__METHOD__ . '() parameter module is deprecated, use RouteList::withModule() instead.');
44-
} elseif ($flags) {
45-
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED);
46-
}
47-
48-
$this->flags = $flags;
4937
parent::__construct($defaults);
5038
}
51-
52-
53-
/**
54-
* Constructs absolute URL from array.
55-
*/
56-
public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?string
57-
{
58-
if ($this->flags & self::ONE_WAY) {
59-
return null;
60-
}
61-
return parent::constructUrl($params, $refUrl);
62-
}
63-
64-
65-
/** @deprecated */
66-
public function getFlags(): int
67-
{
68-
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
69-
return $this->flags;
70-
}
7139
}
7240

7341

src/Application/UI/Component.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ abstract class Component extends Nette\ComponentModel\Container implements Signa
3737
* Returns the presenter where this component belongs to.
3838
* @return Presenter
3939
*/
40-
public function getPresenter(): ?Presenter
40+
public function getPresenter(): Presenter
4141
{
42-
if (func_num_args()) {
43-
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getPresenterIfExists()', E_USER_DEPRECATED);
44-
$throw = func_get_arg(0);
45-
}
46-
return $this->lookup(Presenter::class, $throw ?? true);
42+
return $this->lookup(Presenter::class, throw: true);
4743
}
4844

4945

@@ -52,14 +48,13 @@ public function getPresenter(): ?Presenter
5248
*/
5349
public function getPresenterIfExists(): ?Presenter
5450
{
55-
return $this->lookup(Presenter::class, false);
51+
return $this->lookup(Presenter::class, throw: false);
5652
}
5753

5854

59-
/** @deprecated */
6055
public function hasPresenter(): bool
6156
{
62-
return (bool) $this->lookup(Presenter::class, false);
57+
return (bool) $this->lookup(Presenter::class, throw: false);
6358
}
6459

6560

src/Application/UI/Form.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@ protected function validateParent(Nette\ComponentModel\IContainer $parent): void
6565
/**
6666
* Returns the presenter where this component belongs to.
6767
*/
68-
final public function getPresenter(): ?Presenter
68+
final public function getPresenter(): Presenter
6969
{
70-
if (func_num_args()) {
71-
trigger_error(__METHOD__ . '() parameter $throw is deprecated, use getPresenterIfExists()', E_USER_DEPRECATED);
72-
$throw = func_get_arg(0);
73-
}
74-
return $this->lookup(Presenter::class, $throw ?? true);
70+
return $this->lookup(Presenter::class, throw: true);
7571
}
7672

7773

@@ -80,14 +76,13 @@ final public function getPresenter(): ?Presenter
8076
*/
8177
final public function getPresenterIfExists(): ?Presenter
8278
{
83-
return $this->lookup(Presenter::class, false);
79+
return $this->lookup(Presenter::class, throw: false);
8480
}
8581

8682

87-
/** @deprecated */
8883
public function hasPresenter(): bool
8984
{
90-
return (bool) $this->lookup(Presenter::class, false);
85+
return (bool) $this->lookup(Presenter::class, throw: false);
9186
}
9287

9388

src/Application/UI/Presenter.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @property string $view
2626
* @property string|bool $layout
2727
* @property-read \stdClass $payload
28-
* @property-read Nette\DI\Container $context
2928
* @property-read Nette\Http\Session $session
3029
* @property-read Nette\Security\User $user
3130
*/
@@ -109,9 +108,6 @@ abstract class Presenter extends Control implements Application\IPresenter
109108
/** @var array|null */
110109
private $lastCreatedRequestFlag;
111110

112-
/** @var Nette\DI\Container */
113-
private $context;
114-
115111
/** @var Nette\Http\IRequest */
116112
private $httpRequest;
117113

@@ -164,7 +160,6 @@ final public function getPresenterIfExists(): self
164160
}
165161

166162

167-
/** @deprecated */
168163
final public function hasPresenter(): bool
169164
{
170165
return true;
@@ -1348,7 +1343,6 @@ public function getFlashSession(): Http\SessionSection
13481343

13491344

13501345
final public function injectPrimary(
1351-
?Nette\DI\Container $context,
13521346
?Application\IPresenterFactory $presenterFactory,
13531347
?Nette\Routing\Router $router,
13541348
Http\IRequest $httpRequest,
@@ -1361,7 +1355,6 @@ final public function injectPrimary(
13611355
throw new Nette\InvalidStateException('Method ' . __METHOD__ . ' is intended for initialization and should not be called more than once.');
13621356
}
13631357

1364-
$this->context = $context;
13651358
$this->presenterFactory = $presenterFactory;
13661359
$this->router = $router;
13671360
$this->httpRequest = $httpRequest;
@@ -1372,20 +1365,6 @@ final public function injectPrimary(
13721365
}
13731366

13741367

1375-
/**
1376-
* Gets the context.
1377-
* @deprecated
1378-
*/
1379-
public function getContext(): Nette\DI\Container
1380-
{
1381-
if (!$this->context) {
1382-
throw new Nette\InvalidStateException('Context has not been set.');
1383-
}
1384-
trigger_error(__METHOD__ . '() is deprecated, use dependency injection.', E_USER_DEPRECATED);
1385-
return $this->context;
1386-
}
1387-
1388-
13891368
final public function getHttpRequest(): Http\IRequest
13901369
{
13911370
return $this->httpRequest;

src/Bridges/ApplicationDI/LatteExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function getConfigSchema(): Nette\Schema\Schema
3939
{
4040
return Expect::structure([
4141
'debugger' => Expect::anyOf(true, false, 'all'),
42-
'xhtml' => Expect::bool(false)->deprecated(),
4342
'macros' => Expect::arrayOf('string'),
4443
'templateClass' => Expect::string(),
4544
'strictTypes' => Expect::bool(false),
@@ -61,9 +60,7 @@ public function loadConfiguration()
6160
->getResultDefinition()
6261
->setFactory(Latte\Engine::class)
6362
->addSetup('setTempDirectory', [$this->tempDir])
64-
->addSetup('setAutoRefresh', [$this->debugMode])
65-
->addSetup('setContentType', [$config->xhtml ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML])
66-
->addSetup('Nette\Utils\Html::$xhtml = ?', [$config->xhtml]);
63+
->addSetup('setAutoRefresh', [$this->debugMode]);
6764

6865
if ($config->strictTypes) {
6966
$latteFactory->addSetup('setStrictTypes', [true]);

src/Bridges/ApplicationDI/RoutingExtension.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function getConfigSchema(): Nette\Schema\Schema
3535
return Expect::structure([
3636
'debugger' => Expect::bool(),
3737
'routes' => Expect::arrayOf('string'),
38-
'routeClass' => Expect::string()->deprecated(),
3938
'cache' => Expect::bool(false),
4039
]);
4140
}
@@ -52,14 +51,8 @@ public function loadConfiguration()
5251
$router = $builder->addDefinition($this->prefix('router'))
5352
->setFactory(Nette\Application\Routers\RouteList::class);
5453

55-
if ($this->config->routeClass) {
56-
foreach ($this->config->routes as $mask => $action) {
57-
$router->addSetup('$service[] = new ' . $this->config->routeClass . '(?, ?)', [$mask, $action]);
58-
}
59-
} else {
60-
foreach ($this->config->routes as $mask => $action) {
61-
$router->addSetup('$service->addRoute(?, ?)', [$mask, $action]);
62-
}
54+
foreach ($this->config->routes as $mask => $action) {
55+
$router->addSetup('$service->addRoute(?, ?)', [$mask, $action]);
6356
}
6457

6558
if ($this->name === 'routing') {

tests/Application/Application.run.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ Assert::noError(function () use ($httpRequest, $httpResponse) {
338338

339339
$errors = [];
340340

341-
$presenter->injectPrimary(null, $presenterFactory, $router, $httpRequest, $httpResponse);
342-
$errorPresenter->injectPrimary(null, $presenterFactory, $router, $httpRequest, $httpResponse);
341+
$presenter->injectPrimary($presenterFactory, $router, $httpRequest, $httpResponse);
342+
$errorPresenter->injectPrimary($presenterFactory, $router, $httpRequest, $httpResponse);
343343

344344
$app = new Application($presenterFactory, $router, $httpRequest, $httpResponse);
345345
$app->catchExceptions = true;

0 commit comments

Comments
 (0)