Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c2229b

Browse filesBrowse files
minor #42507 Add return types - batch 3/n (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 3/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 for components that shouldn't be extended very often. Commits ------- aef9069 Add return types - batch 3/n
2 parents 5a3938a + aef9069 commit 2c2229b
Copy full SHA for 2c2229b

File tree

Expand file treeCollapse file tree

103 files changed

+439
-624
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

103 files changed

+439
-624
lines changed

‎src/Symfony/Component/HttpFoundation/AcceptHeader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/AcceptHeader.php
+7-17Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function __construct(array $items)
4646

4747
/**
4848
* Builds an AcceptHeader instance from a string.
49-
*
50-
* @return self
5149
*/
52-
public static function fromString(?string $headerValue)
50+
public static function fromString(?string $headerValue): self
5351
{
5452
$index = 0;
5553

@@ -76,20 +74,16 @@ public function __toString(): string
7674

7775
/**
7876
* Tests if header has given value.
79-
*
80-
* @return bool
8177
*/
82-
public function has(string $value)
78+
public function has(string $value): bool
8379
{
8480
return isset($this->items[$value]);
8581
}
8682

8783
/**
8884
* Returns given value's item, if exists.
89-
*
90-
* @return AcceptHeaderItem|null
9185
*/
92-
public function get(string $value)
86+
public function get(string $value): ?AcceptHeaderItem
9387
{
9488
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
9589
}
@@ -99,7 +93,7 @@ public function get(string $value)
9993
*
10094
* @return $this
10195
*/
102-
public function add(AcceptHeaderItem $item)
96+
public function add(AcceptHeaderItem $item): static
10397
{
10498
$this->items[$item->getValue()] = $item;
10599
$this->sorted = false;
@@ -112,7 +106,7 @@ public function add(AcceptHeaderItem $item)
112106
*
113107
* @return AcceptHeaderItem[]
114108
*/
115-
public function all()
109+
public function all(): array
116110
{
117111
$this->sort();
118112

@@ -121,10 +115,8 @@ public function all()
121115

122116
/**
123117
* Filters items on their value using given regex.
124-
*
125-
* @return self
126118
*/
127-
public function filter(string $pattern)
119+
public function filter(string $pattern): self
128120
{
129121
return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
130122
return preg_match($pattern, $item->getValue());
@@ -133,10 +125,8 @@ public function filter(string $pattern)
133125

134126
/**
135127
* Returns first item.
136-
*
137-
* @return AcceptHeaderItem|null
138128
*/
139-
public function first()
129+
public function first(): ?AcceptHeaderItem
140130
{
141131
$this->sort();
142132

‎src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php
+11-25Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public function __construct(string $value, array $attributes = [])
3333

3434
/**
3535
* Builds an AcceptHeaderInstance instance from a string.
36-
*
37-
* @return self
3836
*/
39-
public static function fromString(?string $itemValue)
37+
public static function fromString(?string $itemValue): self
4038
{
4139
$parts = HeaderUtils::split($itemValue ?? '', ';=');
4240

@@ -64,7 +62,7 @@ public function __toString(): string
6462
*
6563
* @return $this
6664
*/
67-
public function setValue(string $value)
65+
public function setValue(string $value): static
6866
{
6967
$this->value = $value;
7068

@@ -73,10 +71,8 @@ public function setValue(string $value)
7371

7472
/**
7573
* Returns the item value.
76-
*
77-
* @return string
7874
*/
79-
public function getValue()
75+
public function getValue(): string
8076
{
8177
return $this->value;
8278
}
@@ -86,7 +82,7 @@ public function getValue()
8682
*
8783
* @return $this
8884
*/
89-
public function setQuality(float $quality)
85+
public function setQuality(float $quality): static
9086
{
9187
$this->quality = $quality;
9288

@@ -95,10 +91,8 @@ public function setQuality(float $quality)
9591

9692
/**
9793
* Returns the item quality.
98-
*
99-
* @return float
10094
*/
101-
public function getQuality()
95+
public function getQuality(): float
10296
{
10397
return $this->quality;
10498
}
@@ -108,7 +102,7 @@ public function getQuality()
108102
*
109103
* @return $this
110104
*/
111-
public function setIndex(int $index)
105+
public function setIndex(int $index): static
112106
{
113107
$this->index = $index;
114108

@@ -117,40 +111,32 @@ public function setIndex(int $index)
117111

118112
/**
119113
* Returns the item index.
120-
*
121-
* @return int
122114
*/
123-
public function getIndex()
115+
public function getIndex(): int
124116
{
125117
return $this->index;
126118
}
127119

128120
/**
129121
* Tests if an attribute exists.
130-
*
131-
* @return bool
132122
*/
133-
public function hasAttribute(string $name)
123+
public function hasAttribute(string $name): bool
134124
{
135125
return isset($this->attributes[$name]);
136126
}
137127

138128
/**
139129
* Returns an attribute by its name.
140-
*
141-
* @return mixed
142130
*/
143-
public function getAttribute(string $name, mixed $default = null)
131+
public function getAttribute(string $name, mixed $default = null): mixed
144132
{
145133
return $this->attributes[$name] ?? $default;
146134
}
147135

148136
/**
149137
* Returns all attributes.
150-
*
151-
* @return array
152138
*/
153-
public function getAttributes()
139+
public function getAttributes(): array
154140
{
155141
return $this->attributes;
156142
}
@@ -160,7 +146,7 @@ public function getAttributes()
160146
*
161147
* @return $this
162148
*/
163-
public function setAttribute(string $name, string $value)
149+
public function setAttribute(string $name, string $value): static
164150
{
165151
if ('q' === $name) {
166152
$this->quality = (float) $value;

‎src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(\SplFileInfo|string $file, int $status = 200, array
6262
*
6363
* @throws FileException
6464
*/
65-
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
65+
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
6666
{
6767
if (!$file instanceof File) {
6868
if ($file instanceof \SplFileInfo) {
@@ -98,7 +98,7 @@ public function setFile(\SplFileInfo|string $file, string $contentDisposition =
9898
*
9999
* @return File The file to stream
100100
*/
101-
public function getFile()
101+
public function getFile(): File
102102
{
103103
return $this->file;
104104
}
@@ -132,7 +132,7 @@ public function setAutoEtag()
132132
*
133133
* @return $this
134134
*/
135-
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')
135+
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = ''): static
136136
{
137137
if ('' === $filename) {
138138
$filename = $this->file->getFilename();
@@ -161,7 +161,7 @@ public function setContentDisposition(string $disposition, string $filename = ''
161161
/**
162162
* {@inheritdoc}
163163
*/
164-
public function prepare(Request $request)
164+
public function prepare(Request $request): static
165165
{
166166
if (!$this->headers->has('Content-Type')) {
167167
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
@@ -269,7 +269,7 @@ private function hasValidIfRangeHeader(?string $header): bool
269269
*
270270
* {@inheritdoc}
271271
*/
272-
public function sendContent()
272+
public function sendContent(): static
273273
{
274274
if (!$this->isSuccessful()) {
275275
return parent::sendContent();
@@ -299,7 +299,7 @@ public function sendContent()
299299
*
300300
* @throws \LogicException when the content is not null
301301
*/
302-
public function setContent(?string $content)
302+
public function setContent(?string $content): static
303303
{
304304
if (null !== $content) {
305305
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
@@ -311,7 +311,7 @@ public function setContent(?string $content)
311311
/**
312312
* {@inheritdoc}
313313
*/
314-
public function getContent()
314+
public function getContent(): string|false
315315
{
316316
return false;
317317
}
@@ -330,7 +330,7 @@ public static function trustXSendfileTypeHeader()
330330
*
331331
* @return $this
332332
*/
333-
public function deleteFileAfterSend(bool $shouldDelete = true)
333+
public function deleteFileAfterSend(bool $shouldDelete = true): static
334334
{
335335
$this->deleteFileAfterSend = $shouldDelete;
336336

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.