Skip to content

Commit b67536e

Browse files
committed
Improve type hints
1 parent 1b43bb1 commit b67536e

File tree

7 files changed

+27
-94
lines changed

7 files changed

+27
-94
lines changed

src/Connector/NetteConnector.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ public function setContainerAccessor(callable $containerAccessor): void
3232

3333
/**
3434
* @param Request $request
35-
*
36-
* @return Response
3735
*/
38-
public function doRequest($request)
36+
public function doRequest($request): Response
3937
{
4038
$_COOKIE = $request->getCookies();
4139
$_SERVER = $request->getServer();

src/Http/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public function getMethod(): string
7171
return $this->request->getMethod();
7272
}
7373

74-
public function getPost(string $key = null)
74+
public function getPost(?string $key = null)
7575
{
7676
return $this->request->getPost(...func_get_args());
7777
}
7878

79-
public function getQuery(string $key = null)
79+
public function getQuery(?string $key = null)
8080
{
8181
return $this->request->getQuery(...func_get_args());
8282
}

src/Http/Response.php

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -31,69 +31,39 @@ public function reset(): void
3131
$this->headers = [];
3232
}
3333

34-
/**
35-
* @param int $code
36-
*
37-
* @return static
38-
*/
39-
public function setCode(int $code)
34+
public function setCode(int $code): Response
4035
{
4136
$this->code = $code;
4237

4338
return $this;
4439
}
4540

46-
/**
47-
* @return int
48-
*/
4941
public function getCode(): int
5042
{
5143
return $this->code;
5244
}
5345

54-
/**
55-
* @param string $name
56-
* @param string $value
57-
*
58-
* @return static
59-
*/
60-
public function setHeader(string $name, string $value)
46+
public function setHeader(string $name, string $value): Response
6147
{
6248
$this->headers[$name] = $value;
6349

6450
return $this;
6551
}
6652

67-
/**
68-
* @param string $name
69-
* @param string $value
70-
*
71-
* @return static
72-
*/
73-
public function addHeader(string $name, string $value)
53+
public function addHeader(string $name, string $value): Response
7454
{
7555
$this->headers[$name] = $value;
7656

7757
return $this;
7858
}
7959

80-
/**
81-
* @param string $type
82-
* @param string $charset
83-
*
84-
* @return static
85-
*/
86-
public function setContentType(string $type, string $charset = null)
60+
public function setContentType(string $type, ?string $charset = null): Response
8761
{
8862
$this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
8963

9064
return $this;
9165
}
9266

93-
/**
94-
* @param string $url
95-
* @param int $code
96-
*/
9767
public function redirect(string $url, int $code = self::S302_FOUND): void
9868
{
9969
$this->setCode($code);
@@ -102,10 +72,8 @@ public function redirect(string $url, int $code = self::S302_FOUND): void
10272

10373
/**
10474
* @param string|int|DateTime $time
105-
*
106-
* @return static
10775
*/
108-
public function setExpiration($time)
76+
public function setExpiration($time): Response
10977
{
11078
if (!$time) {
11179
$this->setHeader('Cache-Control', 's-maxage=0, max-age=0, must-revalidate');
@@ -121,55 +89,30 @@ public function setExpiration($time)
12189
return $this;
12290
}
12391

124-
/**
125-
* @return bool
126-
*/
12792
public function isSent(): bool
12893
{
12994
return false;
13095
}
13196

132-
/**
133-
* @param string $name
134-
*
135-
* @return mixed
136-
*/
13797
public function getHeader(string $name): ?string
13898
{
13999
return $this->headers[$name] ?? null;
140100
}
141101

142-
/**
143-
* @return array
144-
*/
145102
public function getHeaders(): array
146103
{
147104
return $this->headers;
148105
}
149106

150107
/**
151-
* @param string $name
152-
* @param string $value
153108
* @param string|int|DateTime $time
154-
* @param string $path
155-
* @param string $domain
156-
* @param bool $secure
157-
* @param bool $httpOnly
158-
*
159-
* @return self
160109
*/
161-
public function setCookie(string $name, string $value, $time, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null)
110+
public function setCookie(string $name, string $value, $time, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null): Response
162111
{
163112
return $this;
164113
}
165114

166-
/**
167-
* @param string $name
168-
* @param string $path
169-
* @param string $domain
170-
* @param bool $secure
171-
*/
172-
public function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null): void
115+
public function deleteCookie(string $name, ?string $path = null, ?string $domain = null, ?bool $secure = null): void
173116
{
174117
}
175118
}

src/Module/NetteApplicationModule.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class NetteApplicationModule extends Framework
3232
*/
3333
private $path;
3434

35-
public function _beforeSuite($settings = [])
35+
public function _beforeSuite($settings = []): void
3636
{
3737
$this->path = $settings['path'];
3838
}
3939

40-
public function _before(TestInterface $test)
40+
public function _before(TestInterface $test): void
4141
{
4242
$this->client = new NetteConnector();
4343
$this->client->setContainerAccessor(
@@ -53,7 +53,7 @@ function () {
5353
parent::_before($test);
5454
}
5555

56-
public function _after(TestInterface $test)
56+
public function _after(TestInterface $test): void
5757
{
5858
parent::_after($test);
5959

@@ -64,17 +64,11 @@ public function _after(TestInterface $test)
6464
$_COOKIE = [];
6565
}
6666

67-
/**
68-
* @param bool $followRedirects
69-
*/
7067
public function followRedirects(bool $followRedirects): void
7168
{
7269
$this->client->followRedirects($followRedirects);
7370
}
7471

75-
/**
76-
* @param string $url
77-
*/
7872
public function seeRedirectTo(string $url): void
7973
{
8074
if ($this->client->isFollowingRedirects()) {

src/Module/NetteDIModule.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class NetteDIModule extends Module
2323
*/
2424
public $onCreateContainer = [];
2525

26+
/**
27+
* @var array
28+
*/
2629
protected $config = [
2730
'configFiles' => [],
2831
'appDir' => null,
@@ -33,6 +36,9 @@ class NetteDIModule extends Module
3336
'newContainerForEachTest' => false,
3437
];
3538

39+
/**
40+
* @var array
41+
*/
3642
protected $requiredFields = [
3743
'tempDir',
3844
];
@@ -52,13 +58,13 @@ class NetteDIModule extends Module
5258
*/
5359
private $container;
5460

55-
public function _beforeSuite($settings = [])
61+
public function _beforeSuite($settings = []): void
5662
{
5763
$this->path = $settings['path'];
5864
$this->clearTempDir();
5965
}
6066

61-
public function _before(TestInterface $test)
67+
public function _before(TestInterface $test): void
6268
{
6369
if ($this->config['newContainerForEachTest']) {
6470
$this->clearTempDir();
@@ -67,12 +73,12 @@ public function _before(TestInterface $test)
6773
}
6874
}
6975

70-
public function _afterSuite()
76+
public function _afterSuite(): void
7177
{
7278
$this->stopContainer();
7379
}
7480

75-
public function _after(TestInterface $test)
81+
public function _after(TestInterface $test): void
7682
{
7783
if ($this->config['newContainerForEachTest']) {
7884
$this->stopContainer();
@@ -90,9 +96,6 @@ public function useConfigFiles(array $configFiles): void
9096
$this->configFiles = $configFiles;
9197
}
9298

93-
/**
94-
* @return Container
95-
*/
9699
public function getContainer(): Container
97100
{
98101
if (!$this->container) {
@@ -103,8 +106,6 @@ public function getContainer(): Container
103106
}
104107

105108
/**
106-
* @param string $service
107-
*
108109
* @return object
109110
*/
110111
public function grabService(string $service)

src/Tracy/Logger.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function __construct($config, $options)
2222
Debugger::$logDirectory = $this->getLogDir();
2323
}
2424

25-
public function testFail(FailEvent $e)
25+
public function testFail(FailEvent $event): void
2626
{
27-
Debugger::log($e->getFail());
27+
Debugger::log($event->getFail());
2828
}
2929

30-
public function testError(FailEvent $e)
30+
public function testError(FailEvent $event): void
3131
{
32-
Debugger::log($e->getFail());
32+
Debugger::log($event->getFail());
3333
}
3434
}

tests/functional/src/Fixtures/RouterFactory.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class RouterFactory
1515
{
16-
/**
17-
* @return IRouter
18-
*/
1916
public function create(): IRouter
2017
{
2118
$router = new RouteList();

0 commit comments

Comments
 (0)