Skip to content

Commit 0bb2b26

Browse files
Add return types - batch 2/n
1 parent de2dd61 commit 0bb2b26

Some content is hidden

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

52 files changed

+228
-304
lines changed

src/Symfony/Component/Asset/Context/ContextInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ interface ContextInterface
2323
*
2424
* @return string The base path
2525
*/
26-
public function getBasePath();
26+
public function getBasePath(): string;
2727

2828
/**
2929
* Checks whether the request is secure or not.
3030
*
3131
* @return bool true if the request is secure, false otherwise
3232
*/
33-
public function isSecure();
33+
public function isSecure(): bool;
3434
}

src/Symfony/Component/Asset/Context/NullContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class NullContext implements ContextInterface
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function getBasePath()
24+
public function getBasePath(): string
2525
{
2626
return '';
2727
}
2828

2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function isSecure()
32+
public function isSecure(): bool
3333
{
3434
return false;
3535
}

src/Symfony/Component/Asset/Context/RequestStackContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(RequestStack $requestStack, string $basePath = '', b
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function getBasePath()
37+
public function getBasePath(): string
3838
{
3939
if (!$request = $this->requestStack->getMainRequest()) {
4040
return $this->basePath;
@@ -46,7 +46,7 @@ public function getBasePath()
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function isSecure()
49+
public function isSecure(): bool
5050
{
5151
if (!$request = $this->requestStack->getMainRequest()) {
5252
return $this->secure;

src/Symfony/Component/Asset/Package.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function __construct(VersionStrategyInterface $versionStrategy, ContextIn
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function getVersion(string $path)
38+
public function getVersion(string $path): string
3939
{
4040
return $this->versionStrategy->getVersion($path);
4141
}
4242

4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function getUrl(string $path)
46+
public function getUrl(string $path): string
4747
{
4848
if ($this->isAbsoluteUrl($path)) {
4949
return $path;
@@ -52,26 +52,17 @@ public function getUrl(string $path)
5252
return $this->versionStrategy->applyVersion($path);
5353
}
5454

55-
/**
56-
* @return ContextInterface
57-
*/
58-
protected function getContext()
55+
protected function getContext(): ContextInterface
5956
{
6057
return $this->context;
6158
}
6259

63-
/**
64-
* @return VersionStrategyInterface
65-
*/
66-
protected function getVersionStrategy()
60+
protected function getVersionStrategy(): VersionStrategyInterface
6761
{
6862
return $this->versionStrategy;
6963
}
7064

71-
/**
72-
* @return bool
73-
*/
74-
protected function isAbsoluteUrl(string $url)
65+
protected function isAbsoluteUrl(string $url): bool
7566
{
7667
return str_contains($url, '://') || '//' === substr($url, 0, 2);
7768
}

src/Symfony/Component/Asset/PackageInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ interface PackageInterface
2323
*
2424
* @return string The version string
2525
*/
26-
public function getVersion(string $path);
26+
public function getVersion(string $path): string;
2727

2828
/**
2929
* Returns an absolute or root-relative public path.
3030
*
3131
* @return string The public path
3232
*/
33-
public function getUrl(string $path);
33+
public function getUrl(string $path): string;
3434
}

src/Symfony/Component/Asset/Packages.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function addPackage(string $name, PackageInterface $package)
5757
* @throws InvalidArgumentException If there is no package by that name
5858
* @throws LogicException If no default package is defined
5959
*/
60-
public function getPackage(string $name = null)
60+
public function getPackage(string $name = null): PackageInterface
6161
{
6262
if (null === $name) {
6363
if (null === $this->defaultPackage) {
@@ -82,7 +82,7 @@ public function getPackage(string $name = null)
8282
*
8383
* @return string The current version
8484
*/
85-
public function getVersion(string $path, string $packageName = null)
85+
public function getVersion(string $path, string $packageName = null): string
8686
{
8787
return $this->getPackage($packageName)->getVersion($path);
8888
}
@@ -97,7 +97,7 @@ public function getVersion(string $path, string $packageName = null)
9797
*
9898
* @return string A public path which takes into account the base path and URL path
9999
*/
100-
public function getUrl(string $path, string $packageName = null)
100+
public function getUrl(string $path, string $packageName = null): string
101101
{
102102
return $this->getPackage($packageName)->getUrl($path);
103103
}

src/Symfony/Component/Asset/PathPackage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(string $basePath, VersionStrategyInterface $versionS
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function getUrl(string $path)
52+
public function getUrl(string $path): string
5353
{
5454
$versionedPath = parent::getUrl($path);
5555

@@ -66,7 +66,7 @@ public function getUrl(string $path)
6666
*
6767
* @return string The base path
6868
*/
69-
public function getBasePath()
69+
public function getBasePath(): string
7070
{
7171
return $this->getContext()->getBasePath().$this->basePath;
7272
}

src/Symfony/Component/Asset/UrlPackage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(string|array $baseUrls, VersionStrategyInterface $ve
6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function getUrl(string $path)
70+
public function getUrl(string $path): string
7171
{
7272
if ($this->isAbsoluteUrl($path)) {
7373
return $path;
@@ -95,7 +95,7 @@ public function getUrl(string $path)
9595
*
9696
* @return string The base URL
9797
*/
98-
public function getBaseUrl(string $path)
98+
public function getBaseUrl(string $path): string
9999
{
100100
if (1 === \count($this->baseUrls)) {
101101
return $this->baseUrls[0];
@@ -112,7 +112,7 @@ public function getBaseUrl(string $path)
112112
*
113113
* @return int The base URL index for the given path
114114
*/
115-
protected function chooseBaseUrl(string $path)
115+
protected function chooseBaseUrl(string $path): int
116116
{
117117
return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), \count($this->baseUrls));
118118
}

src/Symfony/Component/Asset/VersionStrategy/EmptyVersionStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class EmptyVersionStrategy implements VersionStrategyInterface
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function getVersion(string $path)
24+
public function getVersion(string $path): string
2525
{
2626
return '';
2727
}
2828

2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function applyVersion(string $path)
32+
public function applyVersion(string $path): string
3333
{
3434
return $path;
3535
}

src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public function __construct(string $manifestPath, HttpClientInterface $httpClien
5656
* the version is. Instead, this returns the path to the
5757
* versioned file.
5858
*/
59-
public function getVersion(string $path)
59+
public function getVersion(string $path): string
6060
{
6161
return $this->applyVersion($path);
6262
}
6363

64-
public function applyVersion(string $path)
64+
public function applyVersion(string $path): string
6565
{
6666
return $this->getManifestPath($path) ?: $path;
6767
}

0 commit comments

Comments
 (0)