Skip to content

Commit d36f845

Browse files
committed
improved coding style
1 parent e07f521 commit d36f845

File tree

114 files changed

+758
-751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+758
-751
lines changed

src/Application/Application.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ class Application extends Nette\Object
3131
/** @var string */
3232
public $errorPresenter;
3333

34-
/** @var callable[] function(Application $sender); Occurs before the application loads presenter */
34+
/** @var callable[] function (Application $sender); Occurs before the application loads presenter */
3535
public $onStartup;
3636

37-
/** @var callable[] function(Application $sender, \Exception $e = NULL); Occurs before the application shuts down */
37+
/** @var callable[] function (Application $sender, \Exception $e = NULL); Occurs before the application shuts down */
3838
public $onShutdown;
3939

40-
/** @var callable[] function(Application $sender, Request $request); Occurs when a new request is received */
40+
/** @var callable[] function (Application $sender, Request $request); Occurs when a new request is received */
4141
public $onRequest;
4242

43-
/** @var callable[] function(Application $sender, Presenter $presenter); Occurs when a presenter is created */
43+
/** @var callable[] function (Application $sender, Presenter $presenter); Occurs when a presenter is created */
4444
public $onPresenter;
4545

46-
/** @var callable[] function(Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */
46+
/** @var callable[] function (Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */
4747
public $onResponse;
4848

49-
/** @var callable[] function(Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */
49+
/** @var callable[] function (Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */
5050
public $onError;
5151

5252
/** @var Request[] */

src/Application/ErrorPresenter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace NetteModule;
99

10-
use Nette,
11-
Nette\Application,
12-
Tracy\ILogger;
10+
use Nette;
11+
use Nette\Application;
12+
use Tracy\ILogger;
1313

1414

1515
/**

src/Application/MicroPresenter.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace NetteModule;
99

10-
use Nette,
11-
Nette\Application,
12-
Nette\Application\Responses,
13-
Nette\Http,
14-
Latte;
10+
use Nette;
11+
use Nette\Application;
12+
use Nette\Application\Responses;
13+
use Nette\Http;
14+
use Latte;
1515

1616

1717
/**

src/Application/PresenterFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class PresenterFactory extends Nette\Object implements IPresenterFactory
3131

3232

3333
/**
34-
* @param callable function(string $class): IPresenter
34+
* @param callable function (string $class): IPresenter
3535
*/
3636
public function __construct($factory = NULL)
3737
{
38-
$this->factory = $factory ?: function($class) { return new $class; };
38+
$this->factory = $factory ?: function ($class) { return new $class; };
3939
}
4040

4141

src/Application/Responses/RedirectResponse.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Application\Responses;
99

10-
use Nette,
11-
Nette\Http;
10+
use Nette;
11+
use Nette\Http;
1212

1313

1414
/**

src/Application/Routers/CliRouter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Application\Routers;
99

10-
use Nette,
11-
Nette\Application;
10+
use Nette;
11+
use Nette\Application;
1212

1313

1414
/**

src/Application/Routers/Route.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace Nette\Application\Routers;
99

10-
use Nette,
11-
Nette\Application,
12-
Nette\Utils\Strings;
10+
use Nette;
11+
use Nette\Application;
12+
use Nette\Utils\Strings;
1313

1414

1515
/**

src/Application/Routers/SimpleRouter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Application\Routers;
99

10-
use Nette,
11-
Nette\Application;
10+
use Nette;
11+
use Nette\Application;
1212

1313

1414
/**

src/Application/UI/Presenter.php

+27-22
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
namespace Nette\Application\UI;
99

10-
use Nette,
11-
Nette\Application,
12-
Nette\Application\Responses,
13-
Nette\Http;
10+
use Nette;
11+
use Nette\Application;
12+
use Nette\Application\Responses;
13+
use Nette\Http;
1414

1515

1616
/**
@@ -48,7 +48,7 @@ abstract class Presenter extends Control implements Application\IPresenter
4848
/** @var int */
4949
public $invalidLinkMode;
5050

51-
/** @var callable[] function(Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */
51+
/** @var callable[] function (Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */
5252
public $onShutdown;
5353

5454
/** @var Nette\Application\Request */
@@ -225,17 +225,20 @@ public function run(Application\Request $request)
225225

226226
} catch (Application\AbortException $e) {
227227
// continue with shutting down
228-
if ($this->isAjax()) try {
229-
$hasPayload = (array) $this->payload; unset($hasPayload['state']);
230-
if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) {
231-
$this->snippetMode = TRUE;
232-
$this->response->send($this->httpRequest, $this->httpResponse);
233-
$this->sendPayload();
234-
235-
} elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload()
228+
if ($this->isAjax()) {
229+
try {
230+
$hasPayload = (array) $this->payload;
231+
unset($hasPayload['state']);
232+
if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) {
233+
$this->snippetMode = TRUE;
234+
$this->response->send($this->httpRequest, $this->httpResponse);
235+
$this->sendPayload();
236+
} elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload()
236237
$this->sendPayload();
238+
}
239+
} catch (Application\AbortException $e) {
237240
}
238-
} catch (Application\AbortException $e) { }
241+
}
239242

240243
if ($this->hasFlashSession()) {
241244
$this->getFlashSession()->setExpiration($this->response instanceof Responses\RedirectResponse ? '+ 30 seconds' : '+ 3 seconds');
@@ -314,7 +317,8 @@ public function processSignal()
314317

315318
try {
316319
$component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE);
317-
} catch (Nette\InvalidArgumentException $e) {}
320+
} catch (Nette\InvalidArgumentException $e) {
321+
}
318322

319323
if (isset($e) || $component === NULL) {
320324
throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.", NULL, isset($e) ? $e : NULL);
@@ -602,7 +606,7 @@ public function sendPayload()
602606

603607
/**
604608
* Sends JSON data to the output.
605-
* @param mixed $data
609+
* @param mixed
606610
* @return void
607611
* @throws Nette\Application\AbortException
608612
*/
@@ -735,7 +739,8 @@ public function canonicalize()
735739
if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
736740
try {
737741
$url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX');
738-
} catch (InvalidLinkException $e) {}
742+
} catch (InvalidLinkException $e) {
743+
}
739744
if (isset($url) && !$this->httpRequest->getUrl()->isEqual($url)) {
740745
$this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY));
741746
}
@@ -806,21 +811,21 @@ protected function createRequest($component, $destination, array $args, $mode)
806811
}
807812

808813
// 4) signal or empty
809-
if (!$component instanceof Presenter || substr($destination, -1) === '!') {
814+
if (!$component instanceof self || substr($destination, -1) === '!') {
810815
$signal = rtrim($destination, '!');
811816
$a = strrpos($signal, ':');
812817
if ($a !== FALSE) {
813818
$component = $component->getComponent(strtr(substr($signal, 0, $a), ':', '-'));
814819
$signal = (string) substr($signal, $a + 1);
815820
}
816821
if ($signal == NULL) { // intentionally ==
817-
throw new InvalidLinkException("Signal must be non-empty string.");
822+
throw new InvalidLinkException('Signal must be non-empty string.');
818823
}
819824
$destination = 'this';
820825
}
821826

822827
if ($destination == NULL) { // intentionally ==
823-
throw new InvalidLinkException("Destination must be non-empty string.");
828+
throw new InvalidLinkException('Destination must be non-empty string.');
824829
}
825830

826831
// 5) presenter: action
@@ -1314,7 +1319,7 @@ public function injectPrimary(Nette\DI\Container $context = NULL, Application\IP
13141319
Http\IRequest $httpRequest, Http\IResponse $httpResponse, Http\Session $session = NULL, Nette\Security\User $user = NULL, ITemplateFactory $templateFactory = NULL)
13151320
{
13161321
if ($this->presenterFactory !== NULL) {
1317-
throw new Nette\InvalidStateException("Method " . __METHOD__ . " is intended for initialization and should not be called more than once.");
1322+
throw new Nette\InvalidStateException('Method ' . __METHOD__ . ' is intended for initialization and should not be called more than once.');
13181323
}
13191324

13201325
$this->context = $context;
@@ -1368,7 +1373,7 @@ public function getSession($namespace = NULL)
13681373
{
13691374
if (!$this->session) {
13701375
throw new Nette\InvalidStateException('Service Session has not been set.');
1371-
}
1376+
}
13721377
return $namespace === NULL ? $this->session : $this->session->getSection($namespace);
13731378
}
13741379

src/Application/UI/PresenterComponentReflection.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Application\UI;
99

10-
use Nette,
11-
Nette\Application\BadRequestException;
10+
use Nette;
11+
use Nette\Application\BadRequestException;
1212

1313

1414
/**
@@ -101,11 +101,13 @@ public function hasCallableMethod($method)
101101
{
102102
$class = $this->getName();
103103
$cache = & self::$mcCache[strtolower($class . ':' . $method)];
104-
if ($cache === NULL) try {
105-
$cache = FALSE;
106-
$rm = new \ReflectionMethod($class, $method);
107-
$cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic();
108-
} catch (\ReflectionException $e) {
104+
if ($cache === NULL) {
105+
try {
106+
$cache = FALSE;
107+
$rm = new \ReflectionMethod($class, $method);
108+
$cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic();
109+
} catch (\ReflectionException $e) {
110+
}
109111
}
110112
return $cache;
111113
}
@@ -123,7 +125,7 @@ public static function combineArgs(\ReflectionFunctionAbstract $method, $args)
123125
if (isset($args[$name])) { // NULLs are ignored
124126
$res[$i++] = $args[$name];
125127
$type = $param->isArray() ? 'array' : ($param->isDefaultValueAvailable() ? gettype($param->getDefaultValue()) : 'NULL');
126-
if (!self::convertType($res[$i-1], $type)) {
128+
if (!self::convertType($res[$i - 1], $type)) {
127129
$mName = $method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' . $method->getName() : $method->getName();
128130
throw new BadRequestException("Invalid value for parameter '$name' in method $mName(), expected " . ($type === 'NULL' ? 'scalar' : $type) . ".");
129131
}

src/Bridges/ApplicationDI/ApplicationExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\ApplicationDI;
99

10-
use Nette,
11-
Nette\Application\UI;
10+
use Nette;
11+
use Nette\Application\UI;
1212

1313

1414
/**
@@ -140,7 +140,7 @@ private function findPresenters()
140140
$classFile = dirname($rc->getFileName()) . '/autoload_classmap.php';
141141
if (is_file($classFile)) {
142142
$this->getContainerBuilder()->addDependency($classFile);
143-
$classes = array_merge($classes, array_keys(call_user_func(function($path) {
143+
$classes = array_merge($classes, array_keys(call_user_func(function ($path) {
144144
return require $path;
145145
}, $classFile)));
146146
}

src/Bridges/ApplicationDI/LatteExtension.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\ApplicationDI;
99

10-
use Nette,
11-
Latte;
10+
use Nette;
11+
use Latte;
1212

1313

1414
/**
@@ -47,7 +47,7 @@ public function loadConfiguration()
4747
$config = $this->validateConfig($this->defaults);
4848
$container = $this->getContainerBuilder();
4949

50-
$latteFactory = $container->addDefinition($this->prefix('latteFactory'))
50+
$container->addDefinition($this->prefix('latteFactory'))
5151
->setClass('Latte\Engine')
5252
->addSetup('setTempDirectory', [$this->tempDir])
5353
->addSetup('setAutoRefresh', [$this->debugMode])
@@ -83,7 +83,7 @@ public function addMacro($macro)
8383

8484
$container = $this->getContainerBuilder();
8585
$container->getDefinition($this->prefix('latteFactory'))
86-
->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']);
86+
->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']);
8787
}
8888

8989
}

src/Bridges/ApplicationDI/RoutingExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function beforeCompile()
5858

5959
if ($this->debugMode && $this->config['debugger'] && $application = $container->getByType('Nette\Application\Application')) {
6060
$container->getDefinition($application)->addSetup('@Tracy\Bar::addPanel', [
61-
new Nette\DI\Statement('Nette\Bridges\ApplicationTracy\RoutingPanel')
61+
new Nette\DI\Statement('Nette\Bridges\ApplicationTracy\RoutingPanel'),
6262
]);
6363
}
6464
}

src/Bridges/ApplicationLatte/ILatteFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\ApplicationLatte;
99

10-
use Nette,
11-
Latte;
10+
use Nette;
11+
use Latte;
1212

1313

1414
interface ILatteFactory

src/Bridges/ApplicationLatte/Loader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\ApplicationLatte;
99

10-
use Nette,
11-
Latte;
10+
use Nette;
11+
use Latte;
1212

1313

1414
/**

src/Bridges/ApplicationLatte/Template.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\ApplicationLatte;
99

10-
use Nette,
11-
Latte;
10+
use Nette;
11+
use Latte;
1212

1313

1414
/**
@@ -105,7 +105,7 @@ public function registerHelperLoader($loader)
105105
{
106106
trigger_error(__METHOD__ . '() is deprecated, use dynamic getLatte()->addFilter().', E_USER_DEPRECATED);
107107
$latte = $this->latte;
108-
$this->latte->addFilter(NULL, function($name) use ($loader, $latte) {
108+
$this->latte->addFilter(NULL, function ($name) use ($loader, $latte) {
109109
if ($callback = call_user_func($loader, $name)) {
110110
$latte->addFilter($name, $callback);
111111
}

0 commit comments

Comments
 (0)