Skip to content

Commit c439350

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Use ::class keyword when possible
2 parents 6a90e0e + fdf759d commit c439350

File tree

10 files changed

+91
-91
lines changed

10 files changed

+91
-91
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function load(array $configs, ContainerBuilder $container)
232232
// default in the Form and Validator component). If disabled, an identity
233233
// translator will be used and everything will still work as expected.
234234
if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) {
235-
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) {
235+
if (!class_exists(Translator::class) && $this->isConfigEnabled($container, $config['translator'])) {
236236
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
237237
}
238238

@@ -320,14 +320,14 @@ public function load(array $configs, ContainerBuilder $container)
320320
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
321321

322322
if ($this->isConfigEnabled($container, $config['form'])) {
323-
if (!class_exists('Symfony\Component\Form\Form')) {
323+
if (!class_exists(\Symfony\Component\Form\Form::class)) {
324324
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
325325
}
326326

327327
$this->formConfigEnabled = true;
328328
$this->registerFormConfiguration($config, $container, $loader);
329329

330-
if (class_exists('Symfony\Component\Validator\Validation')) {
330+
if (class_exists(\Symfony\Component\Validator\Validation::class)) {
331331
$config['validation']['enabled'] = true;
332332
} else {
333333
$container->setParameter('validator.translation_domain', 'validators');
@@ -340,7 +340,7 @@ public function load(array $configs, ContainerBuilder $container)
340340
}
341341

342342
if ($this->isConfigEnabled($container, $config['assets'])) {
343-
if (!class_exists('Symfony\Component\Asset\Package')) {
343+
if (!class_exists(\Symfony\Component\Asset\Package::class)) {
344344
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
345345
}
346346

@@ -408,7 +408,7 @@ public function load(array $configs, ContainerBuilder $container)
408408
$this->registerSecretsConfiguration($config['secrets'], $container, $loader);
409409

410410
if ($this->isConfigEnabled($container, $config['serializer'])) {
411-
if (!class_exists('Symfony\Component\Serializer\Serializer')) {
411+
if (!class_exists(\Symfony\Component\Serializer\Serializer::class)) {
412412
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
413413
}
414414

@@ -1170,18 +1170,18 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11701170
$dirs = [];
11711171
$transPaths = [];
11721172
$nonExistingDirs = [];
1173-
if (class_exists('Symfony\Component\Validator\Validation')) {
1174-
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
1173+
if (class_exists(\Symfony\Component\Validator\Validation::class)) {
1174+
$r = new \ReflectionClass(\Symfony\Component\Validator\Validation::class);
11751175

11761176
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
11771177
}
1178-
if (class_exists('Symfony\Component\Form\Form')) {
1179-
$r = new \ReflectionClass('Symfony\Component\Form\Form');
1178+
if (class_exists(\Symfony\Component\Form\Form::class)) {
1179+
$r = new \ReflectionClass(\Symfony\Component\Form\Form::class);
11801180

11811181
$dirs[] = $transPaths[] = \dirname($r->getFileName()).'/Resources/translations';
11821182
}
1183-
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
1184-
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
1183+
if (class_exists(\Symfony\Component\Security\Core\Exception\AuthenticationException::class)) {
1184+
$r = new \ReflectionClass(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
11851185

11861186
$dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
11871187
}
@@ -1279,7 +1279,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
12791279
return;
12801280
}
12811281

1282-
if (!class_exists('Symfony\Component\Validator\Validation')) {
1282+
if (!class_exists(\Symfony\Component\Validator\Validation::class)) {
12831283
throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
12841284
}
12851285

@@ -1346,8 +1346,8 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
13461346
$files['yaml' === $extension ? 'yml' : $extension][] = $path;
13471347
};
13481348

1349-
if (interface_exists('Symfony\Component\Form\FormInterface')) {
1350-
$reflClass = new \ReflectionClass('Symfony\Component\Form\FormInterface');
1349+
if (interface_exists(\Symfony\Component\Form\FormInterface::class)) {
1350+
$reflClass = new \ReflectionClass(\Symfony\Component\Form\FormInterface::class);
13511351
$fileRecorder('xml', \dirname($reflClass->getFileName()).'/Resources/config/validation.xml');
13521352
}
13531353

@@ -1408,7 +1408,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14081408
return;
14091409
}
14101410

1411-
if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
1411+
if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
14121412
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
14131413
}
14141414

@@ -1420,7 +1420,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14201420
}
14211421

14221422
if ('none' !== $config['cache']) {
1423-
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
1423+
if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
14241424
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
14251425
}
14261426

@@ -1531,7 +1531,7 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
15311531
return;
15321532
}
15331533

1534-
if (!class_exists('Symfony\Component\Security\Csrf\CsrfToken')) {
1534+
if (!class_exists(\Symfony\Component\Security\Csrf\CsrfToken::class)) {
15351535
throw new LogicException('CSRF support cannot be enabled as the Security CSRF component is not installed. Try running "composer require symfony/security-csrf".');
15361536
}
15371537

@@ -1646,7 +1646,7 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container,
16461646

16471647
$loader->load('property_info.php');
16481648

1649-
if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) {
1649+
if (interface_exists(\phpDocumentor\Reflection\DocBlockFactoryInterface::class)) {
16501650
$definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
16511651
$definition->addTag('property_info.description_extractor', ['priority' => -1000]);
16521652
$definition->addTag('property_info.type_extractor', ['priority' => -1001]);

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testDebugCustomDirectory()
9292
{
9393
$this->fs->mkdir($this->translationDir.'/customDir/translations');
9494
$this->fs->mkdir($this->translationDir.'/customDir/templates');
95-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
95+
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
9696
$kernel->expects($this->once())
9797
->method('getBundle')
9898
->with($this->equalTo($this->translationDir.'/customDir'))
@@ -110,8 +110,8 @@ public function testDebugCustomDirectory()
110110

111111
public function testDebugInvalidDirectory()
112112
{
113-
$this->expectException('InvalidArgumentException');
114-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
113+
$this->expectException(\InvalidArgumentException::class);
114+
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
115115
$kernel->expects($this->once())
116116
->method('getBundle')
117117
->with($this->equalTo('dir'))
@@ -136,7 +136,7 @@ protected function tearDown(): void
136136

137137
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester
138138
{
139-
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
139+
$translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
140140
->disableOriginalConstructor()
141141
->getMock();
142142

@@ -145,7 +145,7 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
145145
->method('getFallbackLocales')
146146
->willReturn(['en']);
147147

148-
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
148+
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
149149
$extractor
150150
->expects($this->any())
151151
->method('extract')
@@ -155,7 +155,7 @@ function ($path, $catalogue) use ($extractedMessages) {
155155
}
156156
);
157157

158-
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
158+
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
159159
$loader
160160
->expects($this->any())
161161
->method('read')
@@ -170,7 +170,7 @@ function ($path, $catalogue) use ($loadedMessages) {
170170
['foo', $this->getBundle($this->translationDir)],
171171
['test', $this->getBundle('test')],
172172
];
173-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
173+
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
174174
$kernel
175175
->expects($this->any())
176176
->method('getBundle')
@@ -198,7 +198,7 @@ function ($path, $catalogue) use ($loadedMessages) {
198198

199199
private function getBundle($path)
200200
{
201-
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
201+
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
202202
$bundle
203203
->expects($this->any())
204204
->method('getPath')

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ protected function tearDown(): void
145145
*/
146146
private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = [])
147147
{
148-
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
148+
$translator = $this->getMockBuilder(\Symfony\Component\Translation\Translator::class)
149149
->disableOriginalConstructor()
150150
->getMock();
151151

@@ -154,7 +154,7 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
154154
->method('getFallbackLocales')
155155
->willReturn(['en']);
156156

157-
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
157+
$extractor = $this->getMockBuilder(\Symfony\Component\Translation\Extractor\ExtractorInterface::class)->getMock();
158158
$extractor
159159
->expects($this->any())
160160
->method('extract')
@@ -166,7 +166,7 @@ function ($path, $catalogue) use ($extractedMessages) {
166166
}
167167
);
168168

169-
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
169+
$loader = $this->getMockBuilder(\Symfony\Component\Translation\Reader\TranslationReader::class)->getMock();
170170
$loader
171171
->expects($this->any())
172172
->method('read')
@@ -176,7 +176,7 @@ function ($path, $catalogue) use ($loadedMessages) {
176176
}
177177
);
178178

179-
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
179+
$writer = $this->getMockBuilder(\Symfony\Component\Translation\Writer\TranslationWriter::class)->getMock();
180180
$writer
181181
->expects($this->any())
182182
->method('getFormats')
@@ -189,7 +189,7 @@ function ($path, $catalogue) use ($loadedMessages) {
189189
['foo', $this->getBundle($this->translationDir)],
190190
['test', $this->getBundle('test')],
191191
];
192-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
192+
$kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
193193
$kernel
194194
->expects($this->any())
195195
->method('getBundle')
@@ -217,7 +217,7 @@ function ($path, $catalogue) use ($loadedMessages) {
217217

218218
private function getBundle($path)
219219
{
220-
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
220+
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
221221
$bundle
222222
->expects($this->any())
223223
->method('getPath')

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
3030
{
3131
public function testBundleInterfaceImplementation()
3232
{
33-
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
33+
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\BundleInterface::class)->getMock();
3434

3535
$kernel = $this->getKernel([$bundle], true);
3636

@@ -236,10 +236,10 @@ private function createEventForSuggestingPackages(string $command, array $altern
236236

237237
private function getKernel(array $bundles, $useDispatcher = false)
238238
{
239-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
239+
$container = $this->getMockBuilder(\Symfony\Component\DependencyInjection\ContainerInterface::class)->getMock();
240240

241241
if ($useDispatcher) {
242-
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
242+
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
243243
$dispatcher
244244
->expects($this->atLeastOnce())
245245
->method('dispatch')
@@ -264,7 +264,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
264264
->willReturnOnConsecutiveCalls([], [])
265265
;
266266

267-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
267+
$kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
268268
$kernel->expects($this->once())->method('boot');
269269
$kernel
270270
->expects($this->any())
@@ -282,7 +282,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
282282

283283
private function createBundleMock(array $commands)
284284
{
285-
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
285+
$bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock();
286286
$bundle
287287
->expects($this->once())
288288
->method('registerCommands')

0 commit comments

Comments
 (0)