Skip to content

Commit e9a7cfa

Browse files
committed
coding style: fixes in code
1 parent 515cb84 commit e9a7cfa

35 files changed

Lines changed: 135 additions & 134 deletions

src/Application/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public function run()
8383
$this->processRequest($this->createInitialRequest());
8484
$this->onShutdown($this);
8585

86-
} catch (\Throwable $e) {
8786
} catch (\Exception $e) {
87+
} catch (\Throwable $e) {
8888
}
8989
if (isset($e)) {
9090
$this->onError($this, $e);
@@ -94,10 +94,10 @@ public function run()
9494
$this->onShutdown($this, $e);
9595
return;
9696

97-
} catch (\Throwable $e) {
98-
$this->onError($this, $e);
9997
} catch (\Exception $e) {
10098
$this->onError($this, $e);
99+
} catch (\Throwable $e) {
100+
$this->onError($this, $e);
101101
}
102102
}
103103
$this->onShutdown($this, $e);

src/Application/Responses/FileResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class FileResponse implements Nette\Application\IResponse
1717
{
1818
use Nette\SmartObject;
1919

20+
/** @var bool */
21+
public $resuming = true;
22+
2023
/** @var string */
2124
private $file;
2225

@@ -26,9 +29,6 @@ class FileResponse implements Nette\Application\IResponse
2629
/** @var string */
2730
private $name;
2831

29-
/** @var bool */
30-
public $resuming = true;
31-
3232
/** @var bool */
3333
private $forceDownload;
3434

src/Application/Routers/Route.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Route implements Application\IRouter
5050
self::PATTERN => '[^/]+',
5151
self::FILTER_OUT => [__CLASS__, 'param2path'],
5252
],
53-
'?#' => [ // default style for query parameters
53+
'?#' => [// default style for query parameters
5454
],
5555
'module' => [
5656
self::PATTERN => '[a-z][a-z0-9.-]*',
@@ -357,7 +357,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
357357
}
358358
$i--;
359359

360-
$name = $sequence[$i]; $i--; // parameter name
360+
$name = $sequence[$i--]; // parameter name
361361

362362
if ($name === ']') { // opening optional part
363363
$brackets[] = $url;
@@ -543,9 +543,9 @@ private function setMask($mask, array $metadata)
543543
continue;
544544
}
545545

546-
$pattern = trim($parts[$i]); $i--; // validation condition (as regexp)
547-
$default = $parts[$i]; $i--; // default value
548-
$name = $parts[$i]; $i--; // parameter name
546+
$pattern = trim($parts[$i--]); // validation condition (as regexp)
547+
$default = $parts[$i--]; // default value
548+
$name = $parts[$i--]; // parameter name
549549
array_unshift($sequence, $name);
550550

551551
if ($name[0] === '?') { // "foo" parameter

src/Application/UI/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function getParameterId($name)
229229

230230

231231
/** @deprecated */
232-
function getParam($name = null, $default = null)
232+
public function getParam($name = null, $default = null)
233233
{
234234
//trigger_error(__METHOD__ . '() is deprecated; use getParameter() instead.', E_USER_DEPRECATED);
235235
return func_num_args() ? $this->getParameter($name, $default) : $this->getParameters();

src/Application/UI/ComponentReflection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ComponentReflection extends \ReflectionClass
3939
public function getPersistentParams($class = null)
4040
{
4141
$class = $class === null ? $this->getName() : $class;
42-
$params = & self::$ppCache[$class];
42+
$params = &self::$ppCache[$class];
4343
if ($params !== null) {
4444
return $params;
4545
}
@@ -76,7 +76,7 @@ public function getPersistentParams($class = null)
7676
public function getPersistentComponents($class = null)
7777
{
7878
$class = $class === null ? $this->getName() : $class;
79-
$components = & self::$pcCache[$class];
79+
$components = &self::$pcCache[$class];
8080
if ($components !== null) {
8181
return $components;
8282
}
@@ -103,7 +103,7 @@ public function getPersistentComponents($class = null)
103103
public function hasCallableMethod($method)
104104
{
105105
$class = $this->getName();
106-
$cache = & self::$mcCache[strtolower($class . ':' . $method)];
106+
$cache = &self::$mcCache[strtolower($class . ':' . $method)];
107107
if ($cache === null) {
108108
try {
109109
$cache = false;

src/Application/UI/Control.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
abstract class Control extends Component implements IRenderable
1919
{
20+
/** @var bool */
21+
public $snippetMode;
22+
2023
/** @var ITemplateFactory */
2124
private $templateFactory;
2225

@@ -26,9 +29,6 @@ abstract class Control extends Component implements IRenderable
2629
/** @var array */
2730
private $invalidSnippets = [];
2831

29-
/** @var bool */
30-
public $snippetMode;
31-
3232

3333
/********************* template factory ****************d*g**/
3434

@@ -47,7 +47,8 @@ public function getTemplate()
4747
if ($this->template === null) {
4848
$value = $this->createTemplate();
4949
if (!$value instanceof ITemplate && $value !== null) {
50-
$class2 = get_class($value); $class = get_class($this);
50+
$class2 = get_class($value);
51+
$class = get_class($this);
5152
throw new Nette\UnexpectedValueException("Object returned by $class::createTemplate() must be instance of Nette\\Application\\UI\\ITemplate, '$class2' given.");
5253
}
5354
$this->template = $value;
@@ -118,15 +119,15 @@ public function redrawControl($snippet = null, $redraw = true)
118119

119120

120121
/** @deprecated */
121-
function invalidateControl($snippet = null)
122+
public function invalidateControl($snippet = null)
122123
{
123124
trigger_error(__METHOD__ . '() is deprecated; use $this->redrawControl($snippet) instead.', E_USER_DEPRECATED);
124125
$this->redrawControl($snippet);
125126
}
126127

127128

128129
/** @deprecated */
129-
function validateControl($snippet = null)
130+
public function validateControl($snippet = null)
130131
{
131132
trigger_error(__METHOD__ . '() is deprecated; use $this->redrawControl($snippet, false) instead.', E_USER_DEPRECATED);
132133
$this->redrawControl($snippet, false);

src/Application/UI/Link.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ public function __toString()
9292
try {
9393
return (string) $this->component->link($this->destination, $this->params);
9494

95-
} catch (\Throwable $e) {
9695
} catch (\Exception $e) {
96+
} catch (\Throwable $e) {
9797
}
9898
if (isset($e)) {
9999
if (func_num_args()) {
100100
throw $e;
101101
}
102-
trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
102+
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
103103
}
104104
}
105105
}

src/Application/UI/Presenter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ abstract class Presenter extends Control implements Application\IPresenter
4646
/** @var callable[] function (Presenter $sender, IResponse $response = null); Occurs when the presenter is shutting down */
4747
public $onShutdown;
4848

49-
/** @var Nette\Application\Request|null */
50-
private $request;
51-
52-
/** @var Nette\Application\IResponse */
53-
private $response;
54-
5549
/** @var bool automatically call canonicalize() */
5650
public $autoCanonicalize = true;
5751

5852
/** @var bool use absolute Urls or paths? */
5953
public $absoluteUrls = false;
6054

55+
/** @var Nette\Application\Request|null */
56+
private $request;
57+
58+
/** @var Nette\Application\IResponse */
59+
private $response;
60+
6161
/** @var array */
6262
private $globalParams;
6363

src/Bridges/ApplicationDI/PresenterFactoryCallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(Nette\DI\Container $container, $invalidLinkMode, $to
3939
*/
4040
public function __invoke($class)
4141
{
42-
$services = array_keys($this->container->findByTag('nette.presenter'), $class);
42+
$services = array_keys($this->container->findByTag('nette.presenter'), $class, true);
4343
if (count($services) > 1) {
4444
throw new Nette\Application\InvalidPresenterException("Multiple services of type $class found: " . implode(', ', $services) . '.');
4545

src/Bridges/ApplicationDI/RoutingExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
7676
$router->warmupCache();
7777
}
7878
$s = serialize($router);
79-
} catch (\Throwable $e) {
80-
throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e);
8179
} catch (\Exception $e) {
8280
throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e);
81+
} catch (\Throwable $e) {
82+
throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e);
8383
}
8484
$method->setBody('return unserialize(?);', [$s]);
8585
}

0 commit comments

Comments
 (0)