Skip to content

Commit 9381a43

Browse files
committed
return types
1 parent 568e85a commit 9381a43

File tree

4 files changed

+63
-58
lines changed

4 files changed

+63
-58
lines changed

src/Http/Config/Request.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Valar\Http\Config;
77

8+
use Mvc5\Http;
89
use Psr\Http\Message\StreamInterface;
910
use Psr\Http\Message\UriInterface;
1011

@@ -18,7 +19,7 @@ trait Request
1819
/**
1920
*
2021
*/
21-
use \Mvc5\Http\Config\Request;
22+
use Http\Config\Request;
2223

2324
/**
2425
* @return StreamInterface|mixed
@@ -107,19 +108,19 @@ function hasHeader($name) : bool
107108

108109
/**
109110
* @param StreamInterface $body
110-
* @return mixed|self
111+
* @return Http\Request|mixed
111112
*/
112-
function withBody(StreamInterface $body)
113+
function withBody(StreamInterface $body) : Http\Request
113114
{
114115
return $this->with(BODY, $body);
115116
}
116117

117118
/**
118119
* @param $name
119120
* @param $value
120-
* @return mixed|self
121+
* @return Http\Request|mixed
121122
*/
122-
function withAddedHeader($name, $value)
123+
function withAddedHeader($name, $value) : Http\Request
123124
{
124125
$header = $this[HEADERS][$name] ?? null;
125126

@@ -137,55 +138,55 @@ function withAddedHeader($name, $value)
137138
/**
138139
* @param $name
139140
* @param $value
140-
* @return mixed|self
141+
* @return Http\Request|mixed
141142
*/
142-
function withHeader($name, $value)
143+
function withHeader($name, $value) : Http\Request
143144
{
144145
return $this->with(HEADERS, $this->headers()->with($name, $value));
145146
}
146147

147148
/**
148149
* @param $name
149-
* @return mixed|self
150+
* @return Http\Request|mixed
150151
*/
151-
function withoutHeader($name)
152+
function withoutHeader($name) : Http\Request
152153
{
153154
return $this->with(HEADERS, $this->headers()->without($name));
154155
}
155156

156157
/**
157158
* @param $method
158-
* @return mixed|self
159+
* @return Http\Request|mixed
159160
*/
160-
function withMethod($method)
161+
function withMethod($method) : Http\Request
161162
{
162163
return $this->with(METHOD, $method);
163164
}
164165

165166
/**
166167
* @param $version
167-
* @return mixed|self
168+
* @return Http\Request|mixed
168169
*/
169-
function withProtocolVersion($version)
170+
function withProtocolVersion($version) : Http\Request
170171
{
171172
return $this->with(VERSION, $version);
172173
}
173174

174175
/**
175176
* @param $requestTarget
176-
* @return mixed|self
177+
* @return Http\Request|mixed
177178
*/
178-
function withRequestTarget($requestTarget)
179+
function withRequestTarget($requestTarget) : Http\Request
179180
{
180181
return $this->with(TARGET, $requestTarget);
181182
}
182183

183184
/**
184185
* @param UriInterface $uri
185186
* @param bool $preserveHost
186-
* @return mixed|self
187+
* @return Http\Request|mixed
187188
*/
188-
function withUri(UriInterface $uri, $preserveHost = false)
189+
function withUri(UriInterface $uri, $preserveHost = false) : Http\Request
189190
{
190191
$host = $uri->getHost();
191192

src/Http/Config/Response.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Valar\Http\Config;
77

8+
use Mvc5\Http;
89
use Psr\Http\Message\StreamInterface;
910

1011
use function implode;
@@ -17,10 +18,10 @@ trait Response
1718
/**
1819
*
1920
*/
20-
use \Mvc5\Http\Config\Response;
21+
use Http\Config\Response;
2122

2223
/**
23-
* @return mixed|StreamInterface
24+
* @return StreamInterface|mixed
2425
*/
2526
function getBody()
2627
{
@@ -94,19 +95,19 @@ function hasHeader($name) : bool
9495

9596
/**
9697
* @param StreamInterface $body
97-
* @return mixed|self
98+
* @return Http\Response|mixed
9899
*/
99-
function withBody(StreamInterface $body)
100+
function withBody(StreamInterface $body) : Http\Response
100101
{
101102
return $this->with(BODY, $body);
102103
}
103104

104105
/**
105106
* @param $name
106107
* @param $value
107-
* @return mixed|self
108+
* @return Http\Response|mixed
108109
*/
109-
function withAddedHeader($name, $value)
110+
function withAddedHeader($name, $value) : Http\Response
110111
{
111112
$header = $this[HEADERS][$name] ?? null;
112113

@@ -124,37 +125,37 @@ function withAddedHeader($name, $value)
124125
/**
125126
* @param $name
126127
* @param $value
127-
* @return mixed|self
128+
* @return Http\Response|mixed
128129
*/
129-
function withHeader($name, $value)
130+
function withHeader($name, $value) : Http\Response
130131
{
131132
return $this->with(HEADERS, $this->headers()->with($name, $value));
132133
}
133134

134135
/**
135136
* @param $name
136-
* @return mixed|self
137+
* @return Http\Response|mixed
137138
*/
138-
function withoutHeader($name)
139+
function withoutHeader($name) : Http\Response
139140
{
140141
return $this->with(HEADERS, $this->headers()->without($name));
141142
}
142143

143144
/**
144145
* @param $version
145-
* @return mixed|self
146+
* @return Http\Response|mixed
146147
*/
147-
function withProtocolVersion($version)
148+
function withProtocolVersion($version) : Http\Response
148149
{
149150
return $this->with(VERSION, $version);
150151
}
151152

152153
/**
153154
* @param $code
154155
* @param string $reasonPhrase
155-
* @return mixed|self
156+
* @return Http\Response|mixed
156157
*/
157-
function withStatus($code, $reasonPhrase = '')
158+
function withStatus($code, $reasonPhrase = '') : Http\Response
158159
{
159160
return $this->with([STATUS => $code, REASON => $reasonPhrase]);
160161
}

src/Http/Config/ServerRequest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Valar\Http\Config;
77

88
use Mvc5\Cookie\HttpCookies;
9+
use Mvc5\Http;
910

1011
use const Mvc5\{ ARGS, ATTRIBUTES, COOKIES, DATA, FILES, SERVER };
1112

@@ -77,54 +78,54 @@ function getUploadedFiles() : array
7778
/**
7879
* @param $name
7980
* @param $value
80-
* @return mixed|self
81+
* @return Http\Request|mixed
8182
*/
82-
function withAttribute($name, $value)
83+
function withAttribute($name, $value) : Http\Request
8384
{
8485
return $this->with(ATTRIBUTES, with($this->getAttributes(), $name, $value));
8586
}
8687

8788
/**
8889
* @param $name
89-
* @return mixed|self
90+
* @return Http\Request|mixed
9091
*/
91-
function withoutAttribute($name)
92+
function withoutAttribute($name) : Http\Request
9293
{
9394
return $this->with(ATTRIBUTES, without($this->getAttributes(), $name));
9495
}
9596

9697
/**
9798
* @param array $cookies
98-
* @return mixed|self
99+
* @return Http\Request|mixed
99100
*/
100-
function withCookieParams(array $cookies)
101+
function withCookieParams(array $cookies) : Http\Request
101102
{
102103
return $this->with(COOKIES, new HttpCookies($cookies));
103104
}
104105

105106
/**
106107
* @param $data
107-
* @return mixed|self
108+
* @return Http\Request|mixed
108109
*/
109-
function withParsedBody($data)
110+
function withParsedBody($data) : Http\Request
110111
{
111112
return $this->with(DATA, $data);
112113
}
113114

114115
/**
115116
* @param array $query
116-
* @return mixed|self
117+
* @return Http\Request|mixed
117118
*/
118-
function withQueryParams(array $query)
119+
function withQueryParams(array $query) : Http\Request
119120
{
120121
return $this->with(ARGS, $query);
121122
}
122123

123124
/**
124125
* @param array $uploadedFiles
125-
* @return mixed|self
126+
* @return Http\Request|mixed
126127
*/
127-
function withUploadedFiles(array $uploadedFiles)
128+
function withUploadedFiles(array $uploadedFiles) : Http\Request
128129
{
129130
return $this->with(FILES, $uploadedFiles);
130131
}

src/Http/Config/Uri.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
namespace Valar\Http\Config;
77

8+
use Mvc5\Http;
9+
810
use const Mvc5\{ FRAGMENT, HOST, QUERY, PATH, PASS, PORT, SCHEME, USER };
911

1012
trait Uri
1113
{
1214
/**
1315
*
1416
*/
15-
use \Mvc5\Http\Config\Uri;
17+
use Http\Config\Uri;
1618

1719
/**
1820
* @return string
@@ -86,64 +88,64 @@ function getUserInfo() : string
8688

8789
/**
8890
* @param string $fragment
89-
* @return mixed|self
91+
* @return Http\Uri|mixed
9092
*/
91-
function withFragment($fragment)
93+
function withFragment($fragment) : Http\Uri
9294
{
9395
return $this->with(FRAGMENT, $fragment);
9496
}
9597

9698
/**
9799
* @param $host
98-
* @return mixed|self
100+
* @return Http\Uri|mixed
99101
*/
100-
function withHost($host)
102+
function withHost($host) : Http\Uri
101103
{
102104
return $this->with(HOST, $host);
103105
}
104106

105107
/**
106108
* @param $path
107-
* @return mixed|self
109+
* @return Http\Uri|mixed
108110
*/
109-
function withPath($path)
111+
function withPath($path) : Http\Uri
110112
{
111113
return $this->with(PATH, $path);
112114
}
113115

114116
/**
115117
* @param $port
116-
* @return mixed|self
118+
* @return Http\Uri|mixed
117119
*/
118-
function withPort($port)
120+
function withPort($port) : Http\Uri
119121
{
120122
return $this->with(PORT, $port);
121123
}
122124

123125
/**
124126
* @param $query
125-
* @return mixed|self
127+
* @return Http\Uri|mixed
126128
*/
127-
function withQuery($query)
129+
function withQuery($query) : Http\Uri
128130
{
129131
return $this->with(QUERY, $query);
130132
}
131133

132134
/**
133135
* @param $scheme
134-
* @return mixed|self
136+
* @return Http\Uri|mixed
135137
*/
136-
function withScheme($scheme)
138+
function withScheme($scheme) : Http\Uri
137139
{
138140
return $this->with(SCHEME, $scheme);
139141
}
140142

141143
/**
142144
* @param $user
143145
* @param null $password
144-
* @return mixed|self
146+
* @return Http\Uri|mixed
145147
*/
146-
function withUserInfo($user, $password = null)
148+
function withUserInfo($user, $password = null) : Http\Uri
147149
{
148150
return $this->with([USER => $user, PASS => $password]);
149151
}

0 commit comments

Comments
 (0)