Skip to content

Commit 470996f

Browse files
Matthew Smeetsfabpot
authored andcommitted
[5.0] [Translator] Add parameter type-hints where possible
1 parent c10ad18 commit 470996f

Some content is hidden

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

44 files changed

+82
-106
lines changed

src/Symfony/Component/Translation/Catalogue/AbstractOperation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getDomains()
8888
/**
8989
* {@inheritdoc}
9090
*/
91-
public function getMessages($domain)
91+
public function getMessages(string $domain)
9292
{
9393
if (!\in_array($domain, $this->getDomains())) {
9494
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
@@ -104,7 +104,7 @@ public function getMessages($domain)
104104
/**
105105
* {@inheritdoc}
106106
*/
107-
public function getNewMessages($domain)
107+
public function getNewMessages(string $domain)
108108
{
109109
if (!\in_array($domain, $this->getDomains())) {
110110
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
@@ -120,7 +120,7 @@ public function getNewMessages($domain)
120120
/**
121121
* {@inheritdoc}
122122
*/
123-
public function getObsoleteMessages($domain)
123+
public function getObsoleteMessages(string $domain)
124124
{
125125
if (!\in_array($domain, $this->getDomains())) {
126126
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
@@ -153,5 +153,5 @@ public function getResult()
153153
*
154154
* @param string $domain The domain which the operation will be performed for
155155
*/
156-
abstract protected function processDomain($domain);
156+
abstract protected function processDomain(string $domain);
157157
}

src/Symfony/Component/Translation/Catalogue/MergeOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MergeOperation extends AbstractOperation
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
protected function processDomain($domain)
30+
protected function processDomain(string $domain)
3131
{
3232
$this->messages[$domain] = [
3333
'all' => [],

src/Symfony/Component/Translation/Catalogue/OperationInterface.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,23 @@ public function getDomains();
4444
/**
4545
* Returns all valid messages ('all') after operation.
4646
*
47-
* @param string $domain
48-
*
4947
* @return array
5048
*/
51-
public function getMessages($domain);
49+
public function getMessages(string $domain);
5250

5351
/**
5452
* Returns new messages ('new') after operation.
5553
*
56-
* @param string $domain
57-
*
5854
* @return array
5955
*/
60-
public function getNewMessages($domain);
56+
public function getNewMessages(string $domain);
6157

6258
/**
6359
* Returns obsolete messages ('obsolete') after operation.
6460
*
65-
* @param string $domain
66-
*
6761
* @return array
6862
*/
69-
public function getObsoleteMessages($domain);
63+
public function getObsoleteMessages(string $domain);
7064

7165
/**
7266
* Returns resulting catalogue ('result').

src/Symfony/Component/Translation/Catalogue/TargetOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TargetOperation extends AbstractOperation
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
protected function processDomain($domain)
31+
protected function processDomain(string $domain)
3232
{
3333
$this->messages[$domain] = [
3434
'all' => [],

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getLocale()
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
public function getCatalogue($locale = null)
77+
public function getCatalogue(string $locale = null)
7878
{
7979
return $this->translator->getCatalogue($locale);
8080
}

src/Symfony/Component/Translation/Dumper/CsvFileDumper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CsvFileDumper extends FileDumper
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
29+
public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = [])
3030
{
3131
$handle = fopen('php://memory', 'r+b');
3232

@@ -43,11 +43,8 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
4343

4444
/**
4545
* Sets the delimiter and escape character for CSV.
46-
*
47-
* @param string $delimiter Delimiter character
48-
* @param string $enclosure Enclosure character
4946
*/
50-
public function setCsvControl($delimiter = ';', $enclosure = '"')
47+
public function setCsvControl(string $delimiter = ';', string $enclosure = '"')
5148
{
5249
$this->delimiter = $delimiter;
5350
$this->enclosure = $enclosure;

src/Symfony/Component/Translation/Dumper/DumperInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ interface DumperInterface
2727
* @param MessageCatalogue $messages The message catalogue
2828
* @param array $options Options that are used by the dumper
2929
*/
30-
public function dump(MessageCatalogue $messages, $options = []);
30+
public function dump(MessageCatalogue $messages, array $options = []);
3131
}

src/Symfony/Component/Translation/Dumper/FileDumper.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ abstract class FileDumper implements DumperInterface
3737
*
3838
* @param string $relativePathTemplate A template for the relative paths to files
3939
*/
40-
public function setRelativePathTemplate($relativePathTemplate)
40+
public function setRelativePathTemplate(string $relativePathTemplate)
4141
{
4242
$this->relativePathTemplate = $relativePathTemplate;
4343
}
4444

4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function dump(MessageCatalogue $messages, $options = [])
48+
public function dump(MessageCatalogue $messages, array $options = [])
4949
{
5050
if (!\array_key_exists('path', $options)) {
5151
throw new InvalidArgumentException('The file dumper needs a path option.');
@@ -87,13 +87,9 @@ public function dump(MessageCatalogue $messages, $options = [])
8787
/**
8888
* Transforms a domain of a message catalogue to its string representation.
8989
*
90-
* @param MessageCatalogue $messages
91-
* @param string $domain
92-
* @param array $options
93-
*
9490
* @return string representation
9591
*/
96-
abstract public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []);
92+
abstract public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []);
9793

9894
/**
9995
* Gets the file extension of the dumper.

src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class IcuResFileDumper extends FileDumper
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
31+
public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = [])
3232
{
3333
$data = $indexes = $resources = '';
3434

@@ -82,7 +82,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
8282
return $header.$root.$data;
8383
}
8484

85-
private function writePadding($data)
85+
private function writePadding(string $data)
8686
{
8787
$padding = \strlen($data) % 4;
8888

@@ -91,7 +91,7 @@ private function writePadding($data)
9191
}
9292
}
9393

94-
private function getPosition($data)
94+
private function getPosition(string $data)
9595
{
9696
return (\strlen($data) + 28) / 4;
9797
}

src/Symfony/Component/Translation/Dumper/IniFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class IniFileDumper extends FileDumper
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
26+
public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = [])
2727
{
2828
$output = '';
2929

0 commit comments

Comments
 (0)