8000 minor #33770 Add types to constructors and private/final/internal met… · dontub/symfony@62216ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 62216ea

Browse files
minor symfony#33770 Add types to constructors and private/final/internal methods (Batch III) (derrabus)
This PR was squashed before being merged into the 4.4 branch (closes symfony#33770). Discussion ---------- Add types to constructors and private/final/internal methods (Batch III) | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | symfony#32179, symfony#33228 | License | MIT | Doc PR | N/A Followup to symfony#33709, this time with: * Validator * VarDumper * Workflow * Yaml * all bridges * all bundles That should be the final batch. 😃 Commits ------- 6493902 Add types to constructors and private/final/internal methods (Batch III)
2 parents 1998814 + 6493902 commit 62216ea

File tree

50 files changed

+122
-120
lines changed

Some content is hidden

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

50 files changed

+122
-120
lines changed

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function log($message, array $params)
7171
$this->logger->debug($message, $params);
7272
}
7373

74-
private function normalizeParams(array $params)
74+
private function normalizeParams(array $params): array
7575
{
7676
foreach ($params as $index => $param) {
7777
// normalize recursively

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
namespace Symfony\Bridge\Doctrine\Security\User;
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
15+
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
16+
use Doctrine\Common\Persistence\ObjectManager;
17+
use Doctrine\Common\Persistence\ObjectRepository;
1518
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
1619
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
1720
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
@@ -124,17 +127,17 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
124127
}
125128
}
126129

127-
private function getObjectManager()
130+
private function getObjectManager(): ObjectManager
128131
{
129132
return $this->registry->getManager($this->managerName);
130133
}
131134

132-
private function getRepository()
135+
private function getRepository(): ObjectRepository
133136
{
134137
return $this->getObjectManager()->getRepository($this->classOrAlias);
135138
}
136139

137-
private function getClass()
140+
private function getClass(): string
138141
{
139142
if (null === $this->class) {
140143
$class = $this->classOrAlias;
@@ -149,7 +152,7 @@ priva F438 te function getClass()
149152
return $this->class;
150153
}
151154

152-
private function getClassMetadata()
155+
private function getClassMetadata(): ClassMetadata
153156
{
154157
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
155158
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName
4040
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
4141
}
4242

43-
public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository)
43+
public function setRepository(EntityManagerInterface $entityManager, string $entityName, ObjectRepository $repository)
4444
{
4545
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
4646

@@ -56,7 +56,7 @@ private function createRepository(EntityManagerInterface $entityManager, string
5656
return new $repositoryClassName($entityManager, $metadata);
5757
}
5858

59-
private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName)
59+
private function getRepositoryHash(EntityManagerInterface $entityManager, string $entityName): string
6060
{
6161
return $entityManager->getClassMetadata($entityName)->getName().spl_object_hash($entityManager);
6262
}

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
1313

14+
use Doctrine\Common\Persistence\ObjectRepository;
1415
use Doctrine\ORM\Tools\SchemaTool;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
18+
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
1719
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
1820
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
1921
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
@@ -59,9 +61,7 @@ public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty
5961
{
6062
$user = new User(1, 1, 'user1');
6163

62-
$repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')
63-
->disableOriginalConstructor()
64-
->getMock();
64+
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
6565
$repository
6666
->expects($this->once())
6767
->method('loadUserByUsername')
@@ -147,7 +147,7 @@ public function testSupportProxy()
147147

148148
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
149149
{
150-
$repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock();
150+
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
151151
$repository->expects($this->once())
152152
->method('loadUserByUsername')
153153
->with('name')
@@ -166,7 +166,7 @@ public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided(
166166
public function testLoadUserByUserNameShouldDeclineInvalidInterface()
167167
{
168168
$this->expectException('InvalidArgumentException');
169-
$repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
169+
$repository = $this->createMock(ObjectRepository::class);
170170

171171
$provider = new EntityUserProvider(
172172
$this->getManager($this->getObjectManager($repository)),
@@ -180,7 +180,7 @@ public function testPasswordUpgrades()
180180
{
181181
$user = new User(1, 1, 'user1');
182182

183-
$repository = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock();
183+
$repository = $this->createMock([ObjectRepository::class, PasswordUpgraderInterface::class]);
184184
$repository->expects($this->once())
185185
->method('upgradePassword')
186186
->with($user, 'foobar');

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function format(array $record)
133133
/**
134134
* @internal
135135
*/
136-
public function echoLine($line, $depth, $indentPad)
136+
public function echoLine(string $line, int $depth, string $indentPad)
137137
{
138138
if (-1 !== $depth) {
139139
fwrite($this->outputBuffer, $line);
@@ -143,7 +143,7 @@ public function echoLine($line, $depth, $indentPad)
143143
/**
144144
* @internal
145145
*/
146-
public function castObject($v, array $a, Stub $s, $isNested)
146+
public function castObject($v, array $a, Stub $s, bool $isNested): array
147147
{
148148
if ($this->options['multiline']) {
149149
return $a;
@@ -157,7 +157,7 @@ public function castObject($v, array $a, Stub $s, $isNested)
157157
return $a;
158158
}
159159

160-
private function replacePlaceHolder(array $record)
160+
private function replacePlaceHolder(array $record): array
161161
{
162162
$message = $record['message'];
163163

src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function createSocket()
103103
return $socket;
104104
}
105105

106-
private function formatRecord(array $record)
106+
private function formatRecord(array $record): string
107107
{
108108
if ($this->processors) {
109109
foreach ($this->processors as $processor) {

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ private function getMetadata(string $type, $entity)
364364
return null;
365365
}
366366

367-
private function getPrettyMetadata(string $type, $entity, bool $decorated)
367+
private function getPrettyMetadata(string $type, $entity, bool $decorated): ?string
368368
{
369369
if ('tests' === $type) {
370370
return '';

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function getStdin(): string
119119
return $template;
120120
}
121121

122-
private function getFilesInfo(array $filenames)
122+
private function getFilesInfo(array $filenames): array
123123
{
124124
$filesInfo = [];
125125
foreach ($filenames as $filename) {

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function formatFileFromText($text)
236236
/**
237237
* @internal
238238
*/
239-
public function formatLogMessage($message, array $context)
239+
public function formatLogMessage(string $message, array $context): string
240240
{
241241
if ($context && false !== strpos($message, '{')) {
242242
$replacements = [];

src/Symfony/Bridge/Twig/Extension/FormExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getName()
111111
*
112112
* @see ChoiceView::isSelected()
113113
*/
114-
function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
114+
function twig_is_selected_choice(ChoiceView $choice, $selectedValue): bool
115115
{
116116
if (\is_array($selectedValue)) {
117117
return \in_array($choice->value, $selectedValue, true);
@@ -123,7 +123,7 @@ function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
123123
/**
124124
* @internal
125125
*/
126-
function twig_is_root_form(FormView $formView)
126+
function twig_is_root_form(FormView $formView): bool
127127
{
128128
return null === $formView->parent;
129129
}

0 commit comments

Comments
 (0)
0