Skip to content

Commit 14f6ce4

Browse files
janbarasekdg
authored andcommitted
Fix $this to self:: in case of static method. (#224)
* Fix $this to self:: in case of static method. * Presenter: Replace $this and self:: to static:: in static methods
1 parent 08250b2 commit 14f6ce4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Application/UI/Presenter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ public function run(Application\Request $request): Application\IResponse
188188
}
189189

190190
$this->initGlobalParameters();
191-
$this->checkRequirements($this->getReflection());
191+
$this->checkRequirements(static::getReflection());
192192
$this->onStartup($this);
193193
$this->startup();
194194
if (!$this->startupCheck) {
195-
$class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName();
195+
$class = static::getReflection()->getMethod('startup')->getDeclaringClass()->getName();
196196
throw new Nette\InvalidStateException("Method $class::startup() or its descendant doesn't call parent::startup().");
197197
}
198198
// calls $this->action<Action>()
199-
$this->tryCall($this->formatActionMethod($this->action), $this->params);
199+
$this->tryCall(static::formatActionMethod($this->action), $this->params);
200200

201201
// autoload components
202202
foreach ($this->globalParams as $id => $foo) {
@@ -218,7 +218,7 @@ public function run(Application\Request $request): Application\IResponse
218218
$this->beforeRender();
219219
$this->onRender($this);
220220
// calls $this->render<View>()
221-
$this->tryCall($this->formatRenderMethod($this->view), $this->params);
221+
$this->tryCall(static::formatRenderMethod($this->view), $this->params);
222222
$this->afterRender();
223223

224224
// save component tree persistent state
@@ -506,7 +506,7 @@ public function formatLayoutTemplateFiles(): array
506506
}
507507
[$module, $presenter] = Helpers::splitName($this->getName());
508508
$layout = $this->layout ?: 'layout';
509-
$dir = dirname($this->getReflection()->getFileName());
509+
$dir = dirname(static::getReflection()->getFileName());
510510
$dir = is_dir("$dir/templates") ? $dir : dirname($dir);
511511
$list = [
512512
"$dir/templates/$presenter/@$layout.latte",
@@ -526,7 +526,7 @@ public function formatLayoutTemplateFiles(): array
526526
public function formatTemplateFiles(): array
527527
{
528528
[, $presenter] = Helpers::splitName($this->getName());
529-
$dir = dirname($this->getReflection()->getFileName());
529+
$dir = dirname(static::getReflection()->getFileName());
530530
$dir = is_dir("$dir/templates") ? $dir : dirname($dir);
531531
return [
532532
"$dir/templates/$presenter/$this->view.latte",
@@ -740,7 +740,7 @@ final protected function createRequest(Component $component, string $destination
740740

741741
$this->lastCreatedRequest = $this->lastCreatedRequestFlag = null;
742742

743-
$parts = $this->parseDestination($destination);
743+
$parts = static::parseDestination($destination);
744744
$path = $parts['path'];
745745
$args = $parts['args'] ?? $args;
746746

@@ -1151,7 +1151,7 @@ protected function getGlobalState(string $forClass = null): array
11511151
*/
11521152
public function saveState(array &$params, ComponentReflection $reflection = null): void
11531153
{
1154-
($reflection ?: $this->getReflection())->saveState($this, $params);
1154+
($reflection ?: static::getReflection())->saveState($this, $params);
11551155
}
11561156

11571157

0 commit comments

Comments
 (0)