Skip to content

Commit e9b82c8

Browse files
committed
Revert update to Nette 3.0
1 parent fe60978 commit e9b82c8

File tree

4 files changed

+82
-31
lines changed

4 files changed

+82
-31
lines changed

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@
1414
"require": {
1515
"php": "^7.1.0",
1616
"codeception/codeception": "^2.3.2",
17-
"nette/bootstrap": "^3.0.0",
18-
"nette/di": "^3.0.0@dev",
19-
"nette/http": "^3.0.0@dev"
17+
"nette/bootstrap": "^2.4.0",
18+
"nette/di": "^2.4.0",
19+
"nette/http": "^2.4.0"
2020
},
2121
"require-dev": {
2222
"friendsofphp/php-cs-fixer": "^2.8.0",
23-
"nette/application": "^3.0.0",
24-
"nette/caching": "^3.0.0",
25-
"latte/latte": "^3.0.0",
23+
"nette/application": "^2.4.0",
24+
"nette/caching": "^2.4.0",
25+
"latte/latte": "^2.4.0",
2626
"phpstan/phpstan": "^0.9.0",
2727
"phpstan/phpstan-nette": "^0.9.0",
2828
"tracy/tracy": "^2.4.0"
2929
},
30-
"minimum-stability": "alpha",
3130
"autoload": {
3231
"psr-4": {
3332
"Arachne\\Codeception\\": "src"

src/Http/Request.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public function reset(): void
3636
$this->request = $this->factory->createHttpRequest();
3737
}
3838

39-
public function getCookie(string $key)
39+
public function getCookie($key, $default = null)
4040
{
41-
return $this->request->getCookie($key);
41+
return $this->request->getCookie($key, $default);
4242
}
4343

4444
public function getCookies(): array
4545
{
4646
return $this->request->getCookies();
4747
}
4848

49-
public function getFile(string $key)
49+
public function getFile($key)
5050
{
5151
return $this->request->getFile($key);
5252
}
@@ -56,9 +56,9 @@ public function getFiles(): array
5656
return $this->request->getFiles();
5757
}
5858

59-
public function getHeader(string $header): ?string
59+
public function getHeader($header, $default = null): ?string
6060
{
61-
return $this->request->getHeader($header);
61+
return $this->request->getHeader($header, $default);
6262
}
6363

6464
public function getHeaders(): array
@@ -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($key = null, $default = null)
7575
{
7676
return $this->request->getPost(...func_get_args());
7777
}
7878

79-
public function getQuery(?string $key = null)
79+
public function getQuery($key = null, $default = null)
8080
{
8181
return $this->request->getQuery(...func_get_args());
8282
}
@@ -106,7 +106,7 @@ public function isAjax(): bool
106106
return $this->request->isAjax();
107107
}
108108

109-
public function isMethod(string $method): bool
109+
public function isMethod($method): bool
110110
{
111111
return $this->request->isMethod($method);
112112
}

src/Http/Response.php

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Arachne\Codeception\Http;
66

7-
use Nette\Http\Helpers;
87
use Nette\Http\IResponse;
8+
use Nette\Http\Response as HttpResponse;
99
use Nette\Utils\DateTime;
1010

1111
/**
@@ -31,40 +31,62 @@ public function reset(): void
3131
$this->headers = [];
3232
}
3333

34-
public function setCode(int $code): self
34+
/**
35+
* @param int $code
36+
*/
37+
public function setCode($code): self
3538
{
3639
$this->code = $code;
3740

3841
return $this;
3942
}
4043

41-
public function getCode(): int
44+
/**
45+
* @return int
46+
*/
47+
public function getCode()
4248
{
4349
return $this->code;
4450
}
4551

46-
public function setHeader(string $name, string $value): self
52+
/**
53+
* @param string $name
54+
* @param string $value
55+
*/
56+
public function setHeader($name, $value): self
4757
{
4858
$this->headers[$name] = $value;
4959

5060
return $this;
5161
}
5262

53-
public function addHeader(string $name, string $value): self
63+
/**
64+
* @param string $name
65+
* @param string $value
66+
*/
67+
public function addHeader($name, $value): self
5468
{
5569
$this->headers[$name] = $value;
5670

5771
return $this;
5872
}
5973

60-
public function setContentType(string $type, ?string $charset = null): self
74+
/**
75+
* @param string $type
76+
* @param string $charset
77+
*/
78+
public function setContentType($type, $charset = null): self
6179
{
6280
$this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
6381

6482
return $this;
6583
}
6684

67-
public function redirect(string $url, int $code = self::S302_FOUND): void
85+
/**
86+
* @param string $url
87+
* @param int $code
88+
*/
89+
public function redirect($url, $code = self::S302_FOUND): void
6890
{
6991
$this->setCode($code);
7092
$this->setHeader('Location', $url);
@@ -84,35 +106,65 @@ public function setExpiration($time): self
84106

85107
$time = DateTime::from($time);
86108
$this->setHeader('Cache-Control', 'max-age='.($time->format('U') - time()));
87-
$this->setHeader('Expires', Helpers::formatDate($time));
109+
$this->setHeader('Expires', HttpResponse::date($time));
88110

89111
return $this;
90112
}
91113

92-
public function isSent(): bool
114+
/**
115+
* @return bool
116+
*/
117+
public function isSent()
93118
{
94119
return false;
95120
}
96121

97-
public function getHeader(string $name): ?string
122+
/**
123+
* @param string $name
124+
* @param mixed $default
125+
*
126+
* @return mixed
127+
*/
128+
public function getHeader($name, $default = null)
98129
{
99-
return $this->headers[$name] ?? null;
130+
return isset($this->headers[$name]) ? $this->headers[$name] : $default;
100131
}
101132

102-
public function getHeaders(): array
133+
/**
134+
* @return array
135+
*/
136+
public function getHeaders()
103137
{
104138
return $this->headers;
105139
}
106140

107141
/**
142+
* @param string $name
143+
* @param string $value
108144
* @param string|int|DateTime $time
145+
* @param string $path
146+
* @param string $domain
147+
* @param bool $secure
148+
* @param bool $httpOnly
149+
*
150+
* @return self
109151
*/
110-
public function setCookie(string $name, string $value, $time, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null): self
152+
public function setCookie($name, $value, $time, $path = null, $domain = null, $secure = null, $httpOnly = null)
111153
{
112154
return $this;
113155
}
114156

115-
public function deleteCookie(string $name, ?string $path = null, ?string $domain = null, ?bool $secure = null): void
157+
/**
158+
* @param string $name
159+
* @param string $path
160+
* @param string $domain
161+
* @param bool $secure
162+
*/
163+
public function deleteCookie($name, $path = null, $domain = null, $secure = null)
164+
{
165+
}
166+
167+
public function removeDuplicateCookies()
116168
{
117169
}
118170
}

tests/functional/src/Fixtures/ArticlePresenter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class ArticlePresenter extends Presenter
1313
{
1414
public function actionRedirect(): void
1515
{
16-
$this->redirectPermanent('page');
16+
$this->redirect(301, 'page');
1717
}
1818

19-
public function formatTemplateFiles(): array
19+
public function formatTemplateFiles()
2020
{
2121
$name = $this->getName();
2222
$presenter = substr($name, strrpos(':'.$name, ':'));

0 commit comments

Comments
 (0)