Skip to content

Commit 6c27f0a

Browse files
deguiffabpot
authored andcommitted
Replace get_class() calls by ::class
1 parent 1809b7a commit 6c27f0a

File tree

11 files changed

+14
-14
lines changed

11 files changed

+14
-14
lines changed

AbstractExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function initTypes()
137137
throw new UnexpectedTypeException($type, FormTypeInterface::class);
138138
}
139139

140-
$this->types[\get_class($type)] = $type;
140+
$this->types[$type::class] = $type;
141141
}
142142
}
143143

Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function getCoreTypes(): array
204204
$coreExtension = new CoreExtension();
205205
$loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
206206
$coreTypes = $loadTypesRefMethod->invoke($coreExtension);
207-
$coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes);
207+
$coreTypes = array_map(function (FormTypeInterface $type) { return $type::class; }, $coreTypes);
208208
sort($coreTypes);
209209

210210
return $coreTypes;

Console/Descriptor/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, O
198198
foreach ($type->getTypeExtensions() as $extension) {
199199
$inheritedOptions = $optionsResolver->getDefinedOptions();
200200
$extension->configureOptions($optionsResolver);
201-
$this->extensions[\get_class($extension)] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
201+
$this->extensions[$extension::class] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
202202
}
203203
}
204204
}

Extension/DependencyInjection/DependencyInjectionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function getTypeExtensions(string $name): array
6565

6666
// validate the result of getExtendedTypes() to ensure it is consistent with the service definition
6767
if (!\in_array($name, $extendedTypes, true)) {
68-
throw new InvalidArgumentException(sprintf('The extended type "%s" specified for the type extension class "%s" does not match any of the actual extended types (["%s"]).', $name, \get_class($extension), implode('", "', $extendedTypes)));
68+
throw new InvalidArgumentException(sprintf('The extended type "%s" specified for the type extension class "%s" does not match any of the actual extended types (["%s"]).', $name, $extension::class, implode('", "', $extendedTypes)));
6969
}
7070
}
7171
}

Extension/Validator/ValidatorTypeGuesser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function guessPattern(string $class, string $property): ?ValueGuess
9999
*/
100100
public function guessTypeForConstraint(Constraint $constraint): ?TypeGuess
101101
{
102-
switch (\get_class($constraint)) {
102+
switch ($constraint::class) {
103103
case Type::class:
104104
switch ($constraint->type) {
105105
case 'array':
@@ -190,7 +190,7 @@ public function guessTypeForConstraint(Constraint $constraint): ?TypeGuess
190190
*/
191191
public function guessRequiredForConstraint(Constraint $constraint): ?ValueGuess
192192
{
193-
return match (\get_class($constraint)) {
193+
return match ($constraint::class) {
194194
NotNull::class,
195195
NotBlank::class,
196196
IsTrue::class => new ValueGuess(true, Guess::HIGH_CONFIDENCE),
@@ -203,7 +203,7 @@ public function guessRequiredForConstraint(Constraint $constraint): ?ValueGuess
203203
*/
204204
public function guessMaxLengthForConstraint(Constraint $constraint): ?ValueGuess
205205
{
206-
switch (\get_class($constraint)) {
206+
switch ($constraint::class) {
207207
case Length::class:
208208
if (is_numeric($constraint->max)) {
209209
return new ValueGuess($constraint->max, Guess::HIGH_CONFIDENCE);
@@ -231,7 +231,7 @@ public function guessMaxLengthForConstraint(Constraint $constraint): ?ValueGuess
231231
*/
232232
public function guessPatternForConstraint(Constraint $constraint): ?ValueGuess
233233
{
234-
switch (\get_class($constraint)) {
234+
switch ($constraint::class) {
235235
case Length::class:
236236
if (is_numeric($constraint->min)) {
237237
return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE);

FormRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function getType(string $name): ResolvedFormTypeInterface
9090
private function resolveType(FormTypeInterface $type): ResolvedFormTypeInterface
9191
{
9292
$parentType = $type->getParent();
93-
$fqcn = \get_class($type);
93+
$fqcn = $type::class;
9494

9595
if (isset($this->checkedTypes[$fqcn])) {
9696
$types = implode(' > ', array_merge(array_keys($this->checkedTypes), [$fqcn]));

PreloadedExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $types, array $typeExtensions, FormTypeGuesser
3636
$this->typeGuesser = $typeGuesser;
3737

3838
foreach ($types as $type) {
39-
$this->types[\get_class($type)] = $type;
39+
$this->types[$type::class] = $type;
4040
}
4141
}
4242

Tests/Command/DebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private function getCoreTypes(): array
263263
$coreExtension = new CoreExtension();
264264
$loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
265265
$coreTypes = $loadTypesRefMethod->invoke($coreExtension);
266-
$coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes);
266+
$coreTypes = array_map(function (FormTypeInterface $type) { return $type::class; }, $coreTypes);
267267
sort($coreTypes);
268268

269269
return $coreTypes;

Tests/Extension/Core/DataMapper/DataMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public function testMapFormsToDataDoesNotChangeEqualDateTimeInstance($date)
334334
$article['publishedAt'] = $publishedAtValue;
335335
$propertyPath = new PropertyPath('[publishedAt]');
336336

337-
$config = new FormConfigBuilder('publishedAt', \get_class($publishedAt), $this->dispatcher);
337+
$config = new FormConfigBuilder('publishedAt', $publishedAt::class, $this->dispatcher);
338338
$config->setByReference(false);
339339
$config->setPropertyPath($propertyPath);
340340
$config->setData($publishedAt);

Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ private function getForm($name = 'name', $dataClass = null, array $options = [])
736736

737737
private function getCompoundForm($data, array $options = [])
738738
{
739-
return $this->getBuilder('name', \is_object($data) ? \get_class($data) : null, $options)
739+
return $this->getBuilder('name', \is_object($data) ? $data::class : null, $options)
740740
->setData($data)
741741
->setCompound(true)
742742
->setDataMapper(new DataMapper())

0 commit comments

Comments
 (0)