10BC0 Add types to constructors and private/final/internal methods (Batch I) · symfony/symfony@4039b95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4039b95

Browse files
derrabusfabpot
authored andcommitted
Add types to constructors and private/final/internal methods (Batch I)
1 parent 373469b commit 4039b95

34 files changed

+69
-66
lines changed

src/Symfony/Component/Asset/Package.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ protected function getVersionStrategy()
6868
return $this->versionStrategy;
6969
}
7070

71+
/**
72+
* @return bool
73+
*/
7174
protected function isAbsoluteUrl($url)
7275
{
7376
return false !== strpos($url, '://') || '//' === substr($url, 0, 2);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function applyVersion($path)
5050
return $this->getManifestPath($path) ?: $path;
5151
}
5252

53-
private function getManifestPath(string $path)
53+
private function getManifestPath(string $path): ?string
5454
{
5555
if (null === $this->manifestData) {
5656
if (!file_exists($this->manifestPath)) {

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ protected function requestFromRequest(Request $request, $changeHistory = true)
710710
return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory);
711711
}
712712

713-
private function updateServerFromUri(array $server, string $uri)
713+
private function updateServerFromUri(array $server, string $uri): array
714714
{
715715
$server['HTTP_HOST'] = $this->extractHost($uri);
716716
$scheme = parse_url($uri, PHP_URL_SCHEME);
@@ -720,7 +720,7 @@ private function updateServerFromUri(array $server, string $uri)
720720
return $server;
721721
}
722722

723-
private function extractHost(string $uri)
723+
private function extractHost(string $uri): ?string
724724
{
725725
$host = parse_url($uri, PHP_URL_HOST);
726726

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function (\SplFileInfo $file, $path) {
174174
}
175175
}
176176

177-
private function computeHash()
177+
private function computeHash(): string
178178
{
179179
$hash = hash_init('md5');
180180

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function loadFiles(\ReflectionClass $class)
9898
} while ($class = $class->getParentClass());
9999
}
100100

101-
private function computeHash()
101+
private function computeHash(): string
102102
{
103103
if (null === $this->classReflector) {
104104
try {
@@ -117,7 +117,7 @@ private function computeHash()
117117
return hash_final($hash);
118118
}
119119

120-
private function generateSignature(\ReflectionClass $class)
120+
private function generateSignature(\ReflectionClass $class): iterable
121121
{
122122
yield $class->getDocComment();
123123
yield (int) $class->isFinal();

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,12 +1125,12 @@ public function setDefaultCommand($commandName, $isSingleCommand = false)
11251125
/**
11261126
* @internal
11271127
*/
1128-
public function isSingleCommand()
1128+
public function isSingleCommand(): bool
11291129
{
11301130
return $this->singleCommand;
11311131
}
11321132

1133-
private function splitStringByWidth(string $string, int $width)
1133+
private function splitStringByWidth(string $string, int $width): array
11341134
{
11351135
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
11361136
// additionally, array_slice() is not enough as some character has doubled width.

src/Symfony/Component/Console/Command/ListCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7676
]);
7777
}
7878

79-
/**
80-
* {@inheritdoc}
81-
*/
82-
private function createDefinition()
79+
private function createDefinition(): InputDefinition
8380
{
8481
return new InputDefinition([
8582
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),

src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function describeApplication(Application $application, array $options
167167
}
168168
}
169169

170-
private function getApplicationTitle(Application $application)
170+
private function getApplicationTitle(Application $application): string
171171
{
172172
if ('UNKNOWN' !== $application->getName()) {
173173
if ('UNKNOWN' !== $application->getVersion()) {

src/Symfony/Component/Console/EventListener/ErrorListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function getSubscribedEvents()
7777
];
7878
}
7979

80-
private static function getInputString(ConsoleEvent $event)
80+
private static function getInputString(ConsoleEvent $event): ?string
8181
{
8282
$commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
8383
$input = $event->getInput();

src/Symfony/Component/Console/Helper/ProcessHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function wrapCallback(OutputInterface $output, Process $process, callable
135135
};
136136
}
137137

138-
private function escapeString(string $str)
138+
private function escapeString(string $str): string
139139
{
140140
return str_replace('<', '\\<', $str);
141141
}

0 commit comments

Comments
 (0)
0