Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47322db

Browse files
minor #33294 Add return types to internal & magic methods when possible (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- Add return types to internal & magic methods when possible | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33236 #33228 | License | MIT | Doc PR | - Commits ------- 962dcfe Add return types to internal & magic methods when possible
2 parents 3051c59 + 962dcfe commit 47322db

File tree

80 files changed

+171
-138
lines changed

Some content is hidden

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

80 files changed

+171
-138
lines changed

src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private function createCollector($queries)
205205

206206
class StringRepresentableClass
207207
{
208-
public function __toString()
208+
public function __toString(): string
209209
{
210210
return 'string representation';
211211
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($id1, $id2, $name)
3434
$this->name = $name;
3535
}
3636

37-
public function __toString()
37+
public function __toString(): string
3838
{
3939
return $this->name;
4040
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($id1, $id2, $name)
3434
$this->name = $name;
3535
}
3636

37-
public function __toString()
37+
public function __toString(): string
3838
{
3939
return $this->name;
4040
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($id, $name)
3838
$this->name = $name;
3939
}
4040

41-
public function __toString()
41+
public function __toString(): string
4242
{
4343
return (string) $this->name;
4444
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(SingleIntIdNoToStringEntity $entity, $name)
3131
$this->name = $name;
3232
}
3333

34-
public function __toString()
34+
public function __toString(): string
3535
{
3636
return (string) $this->name;
3737
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($id, $name)
3333
$this->name = $name;
3434
}
3535

36-
public function __toString()
36+
public function __toString(): string
3737
{
3838
return (string) $this->name;
3939
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringCastableIdEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct($id, $name)
3535
$this->name = $name;
3636
}
3737

38-
public function __toString()
38+
public function __toString(): string
3939
{
4040
return (string) $this->name;
4141
}
@@ -50,7 +50,7 @@ public function __construct($id)
5050
$this->id = $id;
5151
}
5252

53-
public function __toString()
53+
public function __toString(): string
5454
{
5555
return (string) $this->id;
5656
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct($id, $name)
3030
$this->name = $name;
3131
}
3232

33-
public function __toString()
33+
public function __toString(): string
3434
{
3535
return $this->name;
3636
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function build(ContainerBuilder $container)
7979
$container->register('logger', NullLogger::class);
8080
}
8181

82-
public function __sleep()
82+
public function __sleep(): array
8383
{
8484
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
8585
}

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getLogDir(): string
6464
return $this->cacheDir;
6565
}
6666

67-
public function __sleep()
67+
public function __sleep(): array
6868
{
6969
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
7070
}

src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(KernelInterface $kernel, string $rootDir, array $pat
4343
}
4444

4545
/**
46-
* {@inheritdoc}
46+
* @return \Traversable
4747
*/
4848
public function getIterator()
4949
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public function __sleep(): array
9191
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
9292
}
9393

94+
/**
95+
* @return \Traversable
96+
*/
9497
public function getIterator()
9598
{
9699
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(callable $generator)
2323
$this->generator = $generator;
2424
}
2525

26-
public function getIterator()
26+
public function getIterator(): \Traversable
2727
{
2828
$g = $this->generator;
2929

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function testFormatAndWrap()
339339

340340
class TableCell
341341
{
342-
public function __toString()
342+
public function __toString(): string
343343
{
344344
return '<info>some info</info>';
345345
}

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ public function __construct(array $values)
835835
$this->values = $values;
836836
}
837837

838-
public function getIterator()
838+
public function getIterator(): \Traversable
839839
{
840840
return new \ArrayIterator($this->values);
841841
}

src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function testContextExceptionKeyCanBeExceptionOrOtherValues()
204204

205205
class DummyTest
206206
{
207-
public function __toString()
207+
public function __toString(): string
208208
{
209209
}
210210
}

src/Symfony/Component/DependencyInjection/Argument/RewindableGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public function __construct(callable $generator, $count)
2828
$this->count = $count;
2929
}
3030

31-
public function getIterator()
31+
public function getIterator(): \Traversable
3232
{
3333
$g = $this->generator;
3434

3535
return $g();
3636
}
3737

38-
public function count()
38+
public function count(): int
3939
{
4040
if (\is_callable($count = $this->count)) {
4141
$this->count = $count();

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ public function load(array $configs, ContainerBuilder $configuration)
2525
return $configuration;
2626
}
2727

28-
public function getXsdValidationBasePath()
28+
public function getXsdValidationBasePath(): string
2929
{
3030
return false;
3131
}
3232

33-
public function getNamespace()
33+
public function getNamespace(): string
3434
{
3535
return 'http://www.example.com/schema/project';
3636
}
3737

38-
public function getAlias()
38+
public function getAlias(): string
3939
{
4040
return 'project';
4141
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
class ProjectWithXsdExtension extends ProjectExtension
44
{
5-
public function getXsdValidationBasePath()
5+
public function getXsdValidationBasePath(): string
66
{
77
return __DIR__.'/schema';
88
}
99

10-
public function getNamespace()
10+
public function getNamespace(): string
1111
{
1212
return 'http://www.example.com/schema/projectwithxsd';
1313
}
1414

15-
public function getAlias()
15+
public function getAlias(): string
1616
{
1717
return 'projectwithxsd';
1818
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ public function callPassed()
8383

8484
class DummyProxyDumper implements ProxyDumper
8585
{
86-
public function isProxyCandidate(Definition $definition)
86+
public function isProxyCandidate(Definition $definition): bool
8787
{
8888
return $definition->isLazy();
8989
}
9090

91-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null)
91+
public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null): string
9292
{
9393
return " // lazy factory for {$definition->getClass()}\n\n";
9494
}
9595

96-
public function getProxyCode(Definition $definition)
96+
public function getProxyCode(Definition $definition): string
9797
{
9898
return "// proxy code for {$definition->getClass()}\n";
9999
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
1212
class ProjectWithXsdExtensionInPhar extends ProjectExtension
1313
{
14-
public function getXsdValidationBasePath()
14+
public function getXsdValidationBasePath(): string
1515
{
1616
return __DIR__.'/schema';
1717
}
1818
19-
public function getNamespace()
19+
public function getNamespace(): string
2020
{
2121
return 'http://www.example.com/schema/projectwithxsdinphar';
2222
}
2323
24-
public function getAlias()
24+
public function getAlias(): string
2525
{
2626
return 'projectwithxsdinphar';
2727
}

src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public function accept()
6868
return true;
6969
}
7070

71+
/**
72+
* @return bool
73+
*/
7174
public function hasChildren()
7275
{
7376
return $this->isRecursive && $this->iterator->hasChildren();

src/Symfony/Component/Finder/Iterator/SortableIterator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
8080
}
8181
}
8282

83+
/**
84+
* @return \Traversable
85+
*/
8386
public function getIterator()
8487
{
8588
if (1 === $this->sort) {

src/Symfony/Component/Finder/Tests/Iterator/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function rewind()
3333
reset($this->values);
3434
}
3535

36-
public function valid()
36+
public function valid(): bool
3737
{
3838
return false !== $this->current();
3939
}

src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function getData()
234234
/**
235235
* @internal
236236
*/
237-
public function __sleep()
237+
public function __sleep(): array
238238
{
239239
foreach ($this->data['forms_by_hash'] as &$form) {
240240
if (isset($form['type_class']) && !$form['type_class'] instanceof ClassStub) {

src/Symfony/Component/Form/FormBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function all()
158158
}
159159

160160
/**
161-
* {@inheritdoc}
161+
* @return int
162162
*/
163163
public function count()
164164
{

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ public function __construct($property)
860860
$this->property = $property;
861861
}
862862

863-
public function __toString()
863+
public function __toString(): string
864864
{
865865
return $this->property;
866866
}

src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(array $array = null)
2424
$this->array = $array ?: [];
2525
}
2626

27-
public function offsetExists($offset)
27+
public function offsetExists($offset): bool
2828
{
2929
return \array_key_exists($offset, $this->array);
3030
}
@@ -48,12 +48,12 @@ public function offsetUnset($offset)
4848
unset($this->array[$offset]);
4949
}
5050

51-
public function getIterator()
51+
public function getIterator(): \Traversable
5252
{
5353
return new \ArrayIterator($this->array);
5454
}
5555

56-
public function count()
56+
public function count(): int
5757
{
5858
return \count($this->array);
5959
}
@@ -63,7 +63,7 @@ public function __serialize(): array
6363
return $this->array;
6464
}
6565

66-
public function serialize()
66+
public function serialize(): string
6767
{
6868
return serialize($this->__serialize());
6969
}

src/Symfony/Component/Form/Tests/SimpleFormTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct($count)
3232
$this->count = $count;
3333
}
3434

35-
public function count()
35+
public function count(): int
3636
{
3737
return $this->count;
3838
}
@@ -47,7 +47,7 @@ public function __construct($count)
4747
$this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : []);
4848
}
4949

50-
public function getIterator()
50+
public function getIterator(): \Traversable
5151
{
5252
return $this->iterator;
5353
}

src/Symfony/Component/Form/Util/InheritDataAwareIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getChildren()
3434
}
3535

3636
/**
37-
* {@inheritdoc}
37+
* @return bool
3838
*/
3939
public function hasChildren()
4040
{

src/Symfony/Component/Form/Util/OrderedHashMap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(array $elements = [])
9999
}
100100

101101
/**
102-
* {@inheritdoc}
102+
* @return bool
103103
*/
104104
public function offsetExists($key)
105105
{
@@ -157,15 +157,15 @@ public function offsetUnset($key)
157157
}
158158

159159
/**
160-
* {@inheritdoc}
160+
* @return \Traversable
161161
*/
162162
public function getIterator()
163163
{
164164
return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors);
165165
}
166166

167167
/**
168-
* {@inheritdoc}
168+
* @return int
169169
*/
170170
public function count()
171171
{

0 commit comments

Comments
 (0)