Skip to content

Commit 55cd8d6

Browse files
minor #33279 Add return types to tests and final|internal|private methods (nicolas-grekas, derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- Add return types to tests and final|internal|private methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33228 #33236 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> #33266 made me spot an issue with my logic to add return types with help from `DebugClassLoader`. Here is a completing PR, with the logic expanded to test classes. I need help to fix tests, /cc @derrabus :) Commits ------- c39fd9c Fixed tests on the Security and Form components fc186bb Add return types to tests and final|internal|private methods
2 parents 8d8d3d4 + c39fd9c commit 55cd8d6

File tree

309 files changed

+718
-858
lines changed

Some content is hidden

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

309 files changed

+718
-858
lines changed

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ final class TestRepositoryFactory implements RepositoryFactory
2828

2929
/**
3030
* {@inheritdoc}
31-
*
32-
* @return ObjectRepository
3331
*/
34-
public function getRepository(EntityManagerInterface $entityManager, $entityName)
32+
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
3533
{
3634
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
3735

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder
257257
$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
258258
}
259259

260-
/**
261-
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
262-
*/
263-
protected function createContainer(array $data = [])
260+
protected function createContainer(array $data = []): ContainerBuilder
264261
{
265262
return new ContainerBuilder(new ParameterBag(array_merge([
266263
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class BaseUser
2424

2525
/**
2626
* BaseUser constructor.
27-
*
28-
* @param int $id
29-
* @param string $username
3027
*/
3128
public function __construct(int $id, string $username)
3229
{
@@ -42,10 +39,7 @@ public function getId()
4239
return $this->id;
4340
}
4441

45-
/**
46-
* @return string
47-
*/
48-
public function getUsername()
42+
public function getUsername(): string
4943
{
5044
return $this->username;
5145
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@ public function __construct(SingleIntIdNoToStringEntity $objectOne, SingleIntIdN
3535
$this->objectTwo = $objectTwo;
3636
}
3737

38-
/**
39-
* @return SingleIntIdNoToStringEntity
40-
*/
41-
public function getObjectOne()
38+
public function getObjectOne(): SingleIntIdNoToStringEntity
4239
{
4340
return $this->objectOne;
4441
}
4542

46-
/**
47-
* @return SingleIntIdNoToStringEntity
48-
*/
49-
public function getObjectTwo()
43+
public function getObjectTwo(): SingleIntIdNoToStringEntity
5044
{
5145
return $this->objectTwo;
5246
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public function __construct(string $string = null)
2020
$this->string = $string;
2121
}
2222

23-
/**
24-
* @return string
25-
*/
26-
public function getString()
23+
public function getString(): string
2724
{
2825
return $this->string;
2926
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
3434

3535
/**
3636
* {@inheritdoc}
37-
*
38-
* @return string
3937
*/
40-
public function getName()
38+
public function getName(): string
4139
{
4240
return 'string_wrapper';
4341
}

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

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

38-
public function getRoles()
38+
public function getRoles(): array
3939
{
4040
}
4141

42-
public function getPassword()
42+
public function getPassword(): ?string
4343
{
4444
}
4545

46-
public function getSalt()
46+
public function getSalt(): ?string
4747
{
4848
}
4949

50-
public function getUsername()
50+
public function getUsername(): string
5151
{
5252
return $this->name;
5353
}

src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function setTestContainer($container)
5151
$this->container = $container;
5252
}
5353

54-
public function getAliasNamespace($alias)
54+
public function getAliasNamespace($alias): string
5555
{
5656
return 'Foo';
5757
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,16 @@ class DoctrineFooType extends Type
2727

2828
/**
2929
* {@inheritdoc}
30-
*
31-
* @return string
3230
*/
33-
public function getName()
31+
public function getName(): string
3432
{
3533
return self::NAME;
3634
}
3735

3836
/**
3937
* {@inheritdoc}
40-
*
41-
* @return string
4238
*/
43-
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
39+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
4440
{
4541
return $platform->getClobTypeDeclarationSQL([]);
4642
}
@@ -80,10 +76,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
8076

8177
/**
8278
* {@inheritdoc}
83-
*
84-
* @return bool
8579
*/
86-
public function requiresSQLCommentHint(AbstractPlatform $platform)
80+
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
8781
{
8882
return true;
8983
}

src/Symfony/Bridge/Monolog/Tests/Formatter/ConsoleFormatterTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ public function testFormat(array $record, $expectedMessage)
2626
self::assertSame($expectedMessage, $formatter->format($record));
2727
}
2828

29-
/**
30-
* @return array
31-
*/
32-
public function providerFormatTests()
29+
public function providerFormatTests(): array
3330
{
3431
$currentDateTime = new \DateTime();
3532

0 commit comments

Comments
 (0)