From 675601b8f73364d5451ed6a61bc8c37e6f1f764a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Fri, 26 Aug 2022 16:19:22 +0200 Subject: [PATCH] Replace get_class() calls by ::class --- .php-cs-fixer.dist.php | 1 + .../DataCollector/ObjectParameter.php | 2 +- .../Security/User/EntityUserProviderTest.php | 2 +- .../Constraints/UniqueEntityValidator.php | 10 +++++----- .../Validator/DoctrineInitializer.php | 2 +- .../Bridge/Twig/Mime/NotificationEmail.php | 2 +- .../CacheWarmer/ConfigBuilderCacheWarmer.php | 2 +- .../FrameworkBundle/Command/AboutCommand.php | 2 +- .../Command/BuildDebugContainerTrait.php | 2 +- .../Command/ContainerLintCommand.php | 2 +- .../Console/Descriptor/Descriptor.php | 4 ++-- .../Console/Descriptor/JsonDescriptor.php | 8 ++++---- .../Console/Descriptor/MarkdownDescriptor.php | 8 ++++---- .../Console/Descriptor/TextDescriptor.php | 8 ++++---- .../Console/Descriptor/XmlDescriptor.php | 6 +++--- .../CacheClearCommandTest.php | 2 +- .../Compiler/ProfilerPassTest.php | 4 ++-- .../Controller/AnnotatedController.php | 2 +- .../Command/DebugFirewallCommand.php | 4 ++-- .../DataCollector/SecurityDataCollector.php | 4 ++-- .../SecurityDataCollectorTest.php | 20 +++++++++---------- .../Security/StaticTokenProvider.php | 4 ++-- .../Security/Core/User/ArrayUserProvider.php | 2 +- .../EventListener/WebDebugToolbarListener.php | 2 +- .../Cache/Adapter/DoctrineDbalAdapter.php | 2 +- .../Cache/Adapter/MemcachedAdapter.php | 2 +- .../Component/Cache/Tests/Psr16CacheTest.php | 2 +- .../Config/Builder/ConfigBuilderGenerator.php | 2 +- .../Definition/Dumper/XmlReferenceDumper.php | 2 +- .../Definition/Dumper/YamlReferenceDumper.php | 2 +- .../Config/Exception/LoaderLoadException.php | 2 +- .../Config/Tests/Definition/ArrayNodeTest.php | 2 +- .../Definition/Builder/NodeBuilderTest.php | 4 ++-- .../Console/Logger/ConsoleLogger.php | 2 +- .../Compiler/CheckTypeDeclarationsPass.php | 2 +- .../DependencyInjection/Compiler/Compiler.php | 4 ++-- .../MergeExtensionConfigurationPass.php | 2 +- .../ResolveInstanceofConditionalsPass.php | 2 +- .../DependencyInjection/Dumper/XmlDumper.php | 2 +- .../DependencyInjection/Dumper/YamlDumper.php | 2 +- .../RegisterServiceSubscribersPassTest.php | 4 ++-- .../ResolveChildDefinitionsPassTest.php | 2 +- .../Tests/ContainerBuilderTest.php | 2 +- .../Component/DomCrawler/Tests/FormTest.php | 2 +- .../ErrorHandler/Tests/ErrorHandlerTest.php | 4 ++-- .../Component/Form/AbstractExtension.php | 2 +- .../Component/Form/Command/DebugCommand.php | 2 +- .../Form/Console/Descriptor/Descriptor.php | 2 +- .../DependencyInjectionExtension.php | 2 +- .../Validator/ValidatorTypeGuesser.php | 8 ++++---- src/Symfony/Component/Form/FormRegistry.php | 2 +- .../Component/Form/PreloadedExtension.php | 2 +- .../Form/Tests/Command/DebugCommandTest.php | 2 +- .../Core/DataMapper/DataMapperTest.php | 2 +- .../Constraints/FormValidatorTest.php | 2 +- .../Type/FormTypeValidatorExtensionTest.php | 2 +- .../HttpClient/Tests/HttplugClientTest.php | 4 ++-- .../Component/HttpFoundation/JsonResponse.php | 2 +- .../Session/Storage/NativeSessionStorage.php | 2 +- .../ControllerMetadata/ArgumentMetadata.php | 2 +- .../DataCollector/ConfigDataCollector.php | 2 +- .../Component/HttpKernel/HttpKernel.php | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- .../ArgumentResolver/UidValueResolverTest.php | 2 +- .../Tests/EventListener/ErrorListenerTest.php | 4 ++-- .../Component/HttpKernel/Tests/KernelTest.php | 2 +- .../Component/Intl/Resources/bin/common.php | 2 +- src/Symfony/Component/Mailer/Envelope.php | 2 +- .../Component/Mailer/Transport/Transports.php | 2 +- .../DataCollector/MessengerDataCollector.php | 4 ++-- src/Symfony/Component/Messenger/Envelope.php | 4 ++-- .../SendFailedMessageForRetryListener.php | 6 +++--- ...ailedMessageToFailureTransportListener.php | 2 +- .../DelayedMessageHandlingException.php | 2 +- .../Middleware/HandleMessageMiddleware.php | 2 +- .../Middleware/SendMessageMiddleware.php | 4 ++-- .../Messenger/Stamp/ErrorDetailsStamp.php | 2 +- .../HandleMessageMiddlewareTest.php | 4 ++-- .../Middleware/SendMessageMiddlewareTest.php | 10 +++++----- .../Component/Messenger/Tests/WorkerTest.php | 2 +- src/Symfony/Component/Messenger/Worker.php | 2 +- .../Test/Constraint/EmailAddressContains.php | 2 +- .../Test/Constraint/EmailAttachmentCount.php | 2 +- .../Mime/Test/Constraint/EmailHasHeader.php | 2 +- .../Mime/Test/Constraint/EmailHeaderSame.php | 2 +- .../Test/Constraint/EmailHtmlBodyContains.php | 2 +- .../Test/Constraint/EmailTextBodyContains.php | 2 +- .../Notifier/Notification/Notification.php | 4 ++-- src/Symfony/Component/Notifier/Notifier.php | 2 +- .../OptionsResolver/OptionsResolver.php | 2 +- .../Command/UserPasswordHashCommand.php | 2 +- .../PropertyAccess/PropertyAccessor.php | 8 ++++---- .../Routing/Requirement/EnumRequirement.php | 2 +- .../Authorization/AccessDecisionManager.php | 2 +- .../Core/Signature/SignatureHasher.php | 2 +- .../Authentication/AuthenticatorManager.php | 6 +++--- .../TraceableAuthenticatorManagerListener.php | 2 +- .../Http/Authenticator/Passport/Passport.php | 2 +- .../PersistentRememberMeHandler.php | 2 +- .../RememberMe/SignatureRememberMeHandler.php | 2 +- .../Semaphore/Store/StoreFactory.php | 2 +- .../Extractor/ObjectPropertyListExtractor.php | 2 +- .../ClassDiscriminatorFromClassMetadata.php | 2 +- .../Mapping/Factory/ClassResolverTrait.php | 2 +- .../Factory/CompiledClassMetadataFactory.php | 4 ++-- .../Normalizer/AbstractObjectNormalizer.php | 6 +++--- .../Normalizer/GetSetMethodNormalizer.php | 2 +- .../Normalizer/MimeMessageNormalizer.php | 2 +- .../Normalizer/ObjectNormalizer.php | 8 ++++---- .../Normalizer/PropertyNormalizer.php | 4 ++-- .../Component/Serializer/Serializer.php | 2 +- .../Tests/Debug/TraceableEncoderTest.php | 4 ++-- .../Tests/Debug/TraceableNormalizerTest.php | 4 ++-- .../ObjectPropertyListExtractorTest.php | 2 +- .../Factory/CacheMetadataFactoryTest.php | 2 +- .../Features/CallbacksTestTrait.php | 4 ++-- .../Features/CircularReferenceTestTrait.php | 8 ++++---- .../Normalizer/PropertyNormalizerTest.php | 2 +- src/Symfony/Component/String/LazyString.php | 2 +- .../String/Resources/bin/update-data.php | 2 +- .../Validator/Command/DebugCommand.php | 4 ++-- .../Validator/Constraints/Composite.php | 2 +- .../Factory/LazyLoadingMetadataFactory.php | 4 ++-- .../Validator/Mapping/MemberMetadata.php | 2 +- .../Validator/Mapping/PropertyMetadata.php | 2 +- .../Test/ConstraintValidatorTestCase.php | 4 ++-- .../AbstractComparisonValidatorTestCase.php | 4 ++-- .../Tests/Constraints/BicValidatorTest.php | 2 +- .../Validator/RecursiveValidatorTest.php | 2 +- .../RecursiveContextualValidator.php | 6 +++--- .../Component/VarDumper/Caster/CutStub.php | 2 +- .../Component/VarDumper/Caster/SplCaster.php | 2 +- .../VarDumper/Caster/SymfonyCaster.php | 2 +- .../Component/VarDumper/Cloner/VarCloner.php | 2 +- .../VarDumper/Dumper/ContextualizedDumper.php | 2 +- .../Exception/ThrowingCasterException.php | 2 +- .../Component/VarExporter/Hydrator.php | 2 +- .../VarExporter/Internal/Exporter.php | 4 ++-- .../VarExporter/Internal/GhostObjectState.php | 4 ++-- src/Symfony/Component/Yaml/Inline.php | 2 +- .../HttpClient/Test/HttpClientTestCase.php | 2 +- 141 files changed, 216 insertions(+), 215 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 96b7d3020063c..35a6317290581 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -34,6 +34,7 @@ 'no_superfluous_phpdoc_tags' => ['remove_inheritdoc' => true], 'header_comment' => ['header' => $fileHeaderComment], 'modernize_strpos' => true, + 'get_class_to_class_keyword' => true, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/ObjectParameter.php b/src/Symfony/Bridge/Doctrine/DataCollector/ObjectParameter.php index 549a6af8bb42a..384ba0efeb869 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/ObjectParameter.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/ObjectParameter.php @@ -23,7 +23,7 @@ public function __construct(object $object, ?\Throwable $error) $this->object = $object; $this->error = $error; $this->stringable = \is_callable([$object, '__toString']); - $this->class = \get_class($object); + $this->class = $object::class; } public function getObject(): object diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 20d1e487a23d2..ca4f091b75f9f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -146,7 +146,7 @@ public function testSupportProxy() $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', ['id1' => 1, 'id2' => 1]); - $this->assertTrue($provider->supportsClass(\get_class($user2))); + $this->assertTrue($provider->supportsClass($user2::class)); } public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 1274607287560..71d73d88a4a44 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -75,14 +75,14 @@ public function validate(mixed $entity, Constraint $constraint) throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em)); } } else { - $em = $this->registry->getManagerForClass(\get_class($entity)); + $em = $this->registry->getManagerForClass($entity::class); if (!$em) { throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_debug_type($entity))); } } - $class = $em->getClassMetadata(\get_class($entity)); + $class = $em->getClassMetadata($entity::class); $criteria = []; $hasNullValue = false; @@ -136,7 +136,7 @@ public function validate(mixed $entity, Constraint $constraint) throw new ConstraintDefinitionException(sprintf('The "%s" entity repository does not support the "%s" entity. The entity should be an instance of or extend "%s".', $constraint->entityClass, $class->getName(), $supportedClass)); } } else { - $repository = $em->getRepository(\get_class($entity)); + $repository = $em->getRepository($entity::class); } $arguments = [$criteria]; @@ -203,7 +203,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, return (string) $value; } - if ($class->getName() !== $idClass = \get_class($value)) { + if ($class->getName() !== $idClass = $value::class) { // non unique value might be a composite PK that consists of other entity objects if ($em->getMetadataFactory()->hasMetadataFor($idClass)) { $identifiers = $em->getClassMetadata($idClass)->getIdentifierValues($value); @@ -224,7 +224,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, if (!\is_object($id) || $id instanceof \DateTimeInterface) { $idAsString = $this->formatValue($id, self::PRETTY_DATE); } else { - $idAsString = sprintf('object("%s")', \get_class($id)); + $idAsString = sprintf('object("%s")', $id::class); } $id = sprintf('%s => %s', $field, $idAsString); diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php index 3e7922ec79276..c50c6e98120ab 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php @@ -30,6 +30,6 @@ public function __construct(ManagerRegistry $registry) public function initialize(object $object) { - $this->registry->getManagerForClass(\get_class($object))?->initializeObject($object); + $this->registry->getManagerForClass($object::class)?->initializeObject($object); } } diff --git a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php index 60a29304c9b20..3148d60a8c851 100644 --- a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php @@ -208,7 +208,7 @@ private function getExceptionAsString(\Throwable|FlattenException $exception): s return $exception->getAsString(); } - $message = \get_class($exception); + $message = $exception::class; if ('' !== $exception->getMessage()) { $message .= ': '.$exception->getMessage(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php index 7b87e487e91fc..3f4a8057ed187 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php @@ -53,7 +53,7 @@ public function warmUp(string $cacheDir): array try { $this->dumpExtension($extension, $generator); } catch (\Exception $e) { - $this->logger?->warning('Failed to generate ConfigBuilder for extension {extensionClass}.', ['exception' => $e, 'extensionClass' => \get_class($extension)]); + $this->logger?->warning('Failed to generate ConfigBuilder for extension {extensionClass}.', ['exception' => $e, 'extensionClass' => $extension::class]); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 4b2df917db7a1..e7e6331b2fc92 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int new TableSeparator(), ['Kernel'], new TableSeparator(), - ['Type', \get_class($kernel)], + ['Type', $kernel::class], ['Environment', $kernel->getEnvironment()], ['Debug', $kernel->isDebug() ? 'true' : 'false'], ['Charset', $kernel->getCharset()], diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php index 785027dbc8d4e..5ac0c8cbc2cb1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php @@ -44,7 +44,7 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde $this->initializeBundles(); return $this->buildContainer(); - }, $kernel, \get_class($kernel)); + }, $kernel, $kernel::class); $container = $buildContainer(); $container->getCompilerPassConfig()->setRemovingPasses([]); $container->getCompilerPassConfig()->setAfterRemovingPasses([]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php index 1029dbc49d3c1..8100793faf3dc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php @@ -86,7 +86,7 @@ private function getContainerBuilder(): ContainerBuilder $this->initializeBundles(); return $this->buildContainer(); - }, $kernel, \get_class($kernel)); + }, $kernel, $kernel::class); $container = $buildContainer(); $skippedIds = []; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index c110f2ea86483..28d1a7c73c8f6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -158,7 +158,7 @@ protected function formatValue(mixed $value): string } if (\is_object($value)) { - return sprintf('object(%s)', \get_class($value)); + return sprintf('object(%s)', $value::class); } if (\is_string($value)) { @@ -335,7 +335,7 @@ private function getContainerEnvVars(ContainerBuilder $container): array $getDefaultParameter = function (string $name) { return parent::get($name); }; - $getDefaultParameter = $getDefaultParameter->bindTo($bag, \get_class($bag)); + $getDefaultParameter = $getDefaultParameter->bindTo($bag, $bag::class); $getEnvReflection = new \ReflectionMethod($container, 'getEnv'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 1c0cfa5c6d936..2a7c53fe52a46 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -78,7 +78,7 @@ protected function describeContainerService(object $service, array $options = [] } elseif ($service instanceof Definition) { $this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $builder, $options['id']), $options); } else { - $this->writeData(\get_class($service), $options); + $this->writeData($service::class, $options); } } @@ -108,7 +108,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } elseif ($service instanceof Definition) { $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments, $builder, $serviceId); } else { - $data['services'][$serviceId] = \get_class($service); + $data['services'][$serviceId] = $service::class; } } @@ -204,7 +204,7 @@ protected function getRouteData(Route $route): array 'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '', 'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', 'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', - 'class' => \get_class($route), + 'class' => $route::class, 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions(), @@ -382,7 +382,7 @@ private function getCallableData(mixed $callable): array if (method_exists($callable, '__invoke')) { $data['type'] = 'object'; - $data['name'] = \get_class($callable); + $data['name'] = $callable::class; return $data; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 111578a84b1d2..2fc80103179e1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -51,7 +51,7 @@ protected function describeRoute(Route $route, array $options = []) ."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '') ."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY') ."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY') - ."\n".'- Class: '.\get_class($route) + ."\n".'- Class: '.$route::class ."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults()) ."\n".'- Requirements: '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM') ."\n".'- Options: '.$this->formatRouterConfig($route->getOptions()); @@ -101,7 +101,7 @@ protected function describeContainerService(object $service, array $options = [] } elseif ($service instanceof Definition) { $this->describeContainerDefinition($service, $childOptions, $builder); } else { - $this->write(sprintf('**`%s`:** `%s`', $options['id'], \get_class($service))); + $this->write(sprintf('**`%s`:** `%s`', $options['id'], $service::class)); } } @@ -188,7 +188,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $this->write("\n\nServices\n--------\n"); foreach ($services['services'] as $id => $service) { $this->write("\n"); - $this->write(sprintf('- `%s`: `%s`', $id, \get_class($service))); + $this->write(sprintf('- `%s`: `%s`', $id, $service::class)); } } } @@ -399,7 +399,7 @@ protected function describeCallable(mixed $callable, array $options = []) if (method_exists($callable, '__invoke')) { $string .= "\n- Type: `object`"; - $string .= "\n".sprintf('- Name: `%s`', \get_class($callable)); + $string .= "\n".sprintf('- Name: `%s`', $callable::class); return $this->write($string."\n"); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 13a8a8b955ef7..b20c95a5a6d4c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -98,7 +98,7 @@ protected function describeRoute(Route $route, array $options = []) ['Scheme', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'], ['Method', $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'], ['Requirements', $route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'], - ['Class', \get_class($route)], + ['Class', $route::class], ['Defaults', $this->formatRouterConfig($defaults)], ['Options', $this->formatRouterConfig($route->getOptions())], ]; @@ -156,7 +156,7 @@ protected function describeContainerService(object $service, array $options = [] $options['output']->table( ['Service ID', 'Class'], [ - [$options['id'] ?? '-', \get_class($service)], + [$options['id'] ?? '-', $service::class], ] ); } @@ -244,7 +244,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $alias = $definition; $tableRows[] = array_merge([$styledServiceId, sprintf('alias for "%s"', $alias)], $tagsCount ? array_fill(0, $tagsCount, '') : []); } else { - $tableRows[] = array_merge([$styledServiceId, \get_class($definition)], $tagsCount ? array_fill(0, $tagsCount, '') : []); + $tableRows[] = array_merge([$styledServiceId, $definition::class], $tagsCount ? array_fill(0, $tagsCount, '') : []); } } @@ -625,7 +625,7 @@ private function formatCallable(mixed $callable): string } if (method_exists($callable, '__invoke')) { - return sprintf('%s::__invoke()', \get_class($callable)); + return sprintf('%s::__invoke()', $callable::class); } throw new \InvalidArgumentException('Callable is not describable.'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 414c526603d6d..b95438eefba38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -164,7 +164,7 @@ private function getRouteDocument(Route $route, string $name = null): \DOMDocume $routeXML->setAttribute('name', $name); } - $routeXML->setAttribute('class', \get_class($route)); + $routeXML->setAttribute('class', $route::class); $routeXML->appendChild($pathXML = $dom->createElement('path')); $pathXML->setAttribute('regex', $route->compile()->getRegex()); @@ -269,7 +269,7 @@ private function getContainerServiceDocument(object $service, string $id, Contai } else { $dom->appendChild($serviceXML = $dom->createElement('service')); $serviceXML->setAttribute('id', $id); - $serviceXML->setAttribute('class', \get_class($service)); + $serviceXML->setAttribute('class', $service::class); } return $dom; @@ -577,7 +577,7 @@ private function getCallableDocument(mixed $callable): \DOMDocument if (method_exists($callable, '__invoke')) { $callableXML->setAttribute('type', 'object'); - $callableXML->setAttribute('name', \get_class($callable)); + $callableXML->setAttribute('name', $callable::class); return $dom; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index 8a5a023e3b7ac..d3f8e2c9be5a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -126,7 +126,7 @@ public function testCacheIsWarmedWithOldContainer() \Closure::bind(function (Container $class) { unset($class->loadedDynamicParameters['kernel.build_dir']); unset($class->parameters['kernel.build_dir']); - }, null, \get_class($container))($container); + }, null, $container::class)($container); $input = new ArrayInput(['cache:clear']); $application = new Application($kernel); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index 65f047426ae44..bb7d4f1f4ae4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -105,12 +105,12 @@ public function testValidCollectorWithTemplateUsingAutoconfigure(TemplateAwareDa $profilerDefinition = $container->register('profiler', 'ProfilerClass'); $container->registerForAutoconfiguration(DataCollectorInterface::class)->addTag('data_collector'); - $container->register('mydatacollector', \get_class($dataCollector))->setAutoconfigured(true); + $container->register('mydatacollector', $dataCollector::class)->setAutoconfigured(true); (new ResolveInstanceofConditionalsPass())->process($container); (new ProfilerPass())->process($container); - $idForTemplate = \get_class($dataCollector); + $idForTemplate = $dataCollector::class; $this->assertSame(['mydatacollector' => [$idForTemplate, 'foo']], $container->getParameter('data_collector.templates')); // grab the method calls off of the "profiler" definition diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php index f2f077786f2b7..e6b917b63cc60 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/AnnotatedController.php @@ -22,7 +22,7 @@ class AnnotatedController */ public function requestDefaultNullAction(Request $request = null) { - return new Response($request ? \get_class($request) : null); + return new Response($request ? $request::class : null); } /** diff --git a/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php index ea1e44018ea05..757f61629f6f5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php @@ -218,7 +218,7 @@ private function displayAuthenticators(string $name, SymfonyStyle $io): void array_map( static function ($authenticator) { return [ - \get_class($authenticator), + $authenticator::class, ]; }, $authenticators @@ -253,7 +253,7 @@ private function formatCallable(mixed $callable): string } if (method_exists($callable, '__invoke')) { - return sprintf('%s::__invoke()', \get_class($callable)); + return sprintf('%s::__invoke()', $callable::class); } throw new \InvalidArgumentException('Callable is not describable.'); diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index dd446208e39d2..96730d041c5fc 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -119,7 +119,7 @@ public function collect(Request $request, Response $response, \Throwable $except 'impersonator_user' => $impersonatorUser, 'impersonation_exit_path' => null, 'token' => $token, - 'token_class' => $this->hasVarDumper ? new ClassStub(\get_class($token)) : \get_class($token), + 'token_class' => $this->hasVarDumper ? new ClassStub($token::class) : $token::class, 'logout_url' => $logoutUrl, 'user' => $token->getUserIdentifier(), 'roles' => $assignedRoles, @@ -137,7 +137,7 @@ public function collect(Request $request, Response $response, \Throwable $except $voter = $voter->getDecoratedVoter(); } - $this->data['voters'][] = $this->hasVarDumper ? new ClassStub(\get_class($voter)) : \get_class($voter); + $this->data['voters'][] = $this->hasVarDumper ? new ClassStub($voter::class) : $voter::class; } // collect voter details diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index c3283dae5cdd7..b5178dcde56a1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -239,14 +239,14 @@ public function providerCollectDecisionLog(): \Generator ], ]], [$decoratedVoter1, $decoratedVoter1], - [\get_class($voter1), \get_class($voter2)], + [$voter1::class, $voter2::class], [[ 'attributes' => ['view'], 'object' => new \stdClass(), 'result' => true, 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], - ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], + ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], + ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN], ], ]], ]; @@ -276,17 +276,17 @@ public function providerCollectDecisionLog(): \Generator ], ], [$decoratedVoter1, $decoratedVoter1], - [\get_class($voter1), \get_class($voter2)], + [$voter1::class, $voter2::class], [ [ 'attributes' => ['view', 'edit'], 'object' => new \stdClass(), 'result' => false, 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => \get_class($voter1), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED], - ['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => \get_class($voter2), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter1::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED], + ['class' => $voter1::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED], + ['class' => $voter2::class, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter2::class, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED], ], ], [ @@ -294,8 +294,8 @@ public function providerCollectDecisionLog(): \Generator 'object' => new \stdClass(), 'result' => true, 'voter_details' => [ - ['class' => \get_class($voter1), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], - ['class' => \get_class($voter2), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter1::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], + ['class' => $voter2::class, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED], ], ], ], diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/StaticTokenProvider.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/StaticTokenProvider.php index 24ff10a4d0199..8a669e99bc48d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/StaticTokenProvider.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/RememberMeBundle/Security/StaticTokenProvider.php @@ -23,8 +23,8 @@ class StaticTokenProvider implements TokenProviderInterface public function __construct($kernel) { // only reset the "internal db" for new tests - if (self::$kernelClass !== \get_class($kernel)) { - self::$kernelClass = \get_class($kernel); + if (self::$kernelClass !== $kernel::class) { + self::$kernelClass = $kernel::class; self::$db = []; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php index 68f896bcc68b1..42f2df9e10043 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php @@ -64,7 +64,7 @@ public function refreshUser(UserInterface $user): UserInterface } $storedUser = $this->getUser($user->getUserIdentifier()); - $class = \get_class($storedUser); + $class = $storedUser::class; return new $class($storedUser->getUserIdentifier(), $storedUser->getPassword(), $storedUser->getRoles(), $storedUser->isEnabled()); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index 5152223669c8d..8e0366e15340c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -85,7 +85,7 @@ public function onKernelResponse(ResponseEvent $event) $this->urlGenerator->generate('_profiler', ['token' => $response->headers->get('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL) ); } catch (\Exception $e) { - $response->headers->set('X-Debug-Error', \get_class($e).': '.preg_replace('/\s+/', ' ', $e->getMessage())); + $response->headers->set('X-Debug-Error', $e::class.': '.preg_replace('/\s+/', ' ', $e->getMessage())); } } diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php index 15a711e370384..806eba40da8ca 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php @@ -326,7 +326,7 @@ private function getPlatformName(): string $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => $this->platformName = 'oci', $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform, $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => $this->platformName = 'sqlsrv', - default => $this->platformName = \get_class($platform), + default => $this->platformName = $platform::class, }; } diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 06d9e286f9934..83e21da55fc48 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -58,7 +58,7 @@ public function __construct(\Memcached $client, string $namespace = '', int $def if (!static::isSupported()) { throw new CacheException('Memcached > 3.1.5 is required.'); } - if ('Memcached' === \get_class($client)) { + if ('Memcached' === $client::class) { $opt = $client->getOption(\Memcached::OPT_SERIALIZER); if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php index 562d6e11bf50b..264679aecc1b6 100644 --- a/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheTest.php @@ -163,7 +163,7 @@ public function testPrune() protected function isPruned(CacheInterface $cache, string $name): bool { - if (Psr16Cache::class !== \get_class($cache)) { + if (Psr16Cache::class !== $cache::class) { $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); } diff --git a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php index e67e86679594a..c8ce7252e7835 100644 --- a/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php +++ b/src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php @@ -123,7 +123,7 @@ private function buildNode(NodeInterface $node, ClassBuilder $class, string $nam $this->handleArrayNode($child, $class, $namespace); break; default: - throw new \RuntimeException(sprintf('Unknown node "%s".', \get_class($child))); + throw new \RuntimeException(sprintf('Unknown node "%s".', $child::class)); } } } diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index 1ad8522e00d4d..8dee2d394aeb9 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -104,7 +104,7 @@ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = fal if ($prototype->hasDefaultValue()) { $prototypeValue = $prototype->getDefaultValue(); } else { - $prototypeValue = match (\get_class($prototype)) { + $prototypeValue = match ($prototype::class) { ScalarNode::class => 'scalar value', FloatNode::class, IntegerNode::class => 'numeric value', diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index e19e05cfdaf6a..bb629d332e507 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -100,7 +100,7 @@ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null } elseif ($node instanceof EnumNode) { $comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues())); $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~'; - } elseif (VariableNode::class === \get_class($node) && \is_array($example)) { + } elseif (VariableNode::class === $node::class && \is_array($example)) { // If there is an array example, we are sure we dont need to print a default value $default = ''; } else { diff --git a/src/Symfony/Component/Config/Exception/LoaderLoadException.php b/src/Symfony/Component/Config/Exception/LoaderLoadException.php index 7ef6be83a1dc7..9b5ffeb40c724 100644 --- a/src/Symfony/Component/Config/Exception/LoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/LoaderLoadException.php @@ -71,7 +71,7 @@ public function __construct(string $resource, string $sourceResource = null, int protected function varToString(mixed $var) { if (\is_object($var)) { - return sprintf('Object(%s)', \get_class($var)); + return sprintf('Object(%s)', $var::class); } if (\is_array($var)) { diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 354ba5a97dbc8..538ba06dbaa23 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -73,7 +73,7 @@ public function ignoreAndRemoveMatrixProvider(): array public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\Exception $expected, string $message = '') { if ($expected instanceof \Exception) { - $this->expectException(\get_class($expected)); + $this->expectException($expected::class); $this->expectExceptionMessage($expected->getMessage()); } $node = new ArrayNode('root'); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php index b272008fedf25..1338c58a68721 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php @@ -66,14 +66,14 @@ public function testNodeTypesAreNotCaseSensitive() $node1 = $builder->node('', 'VaRiAbLe'); $node2 = $builder->node('', 'variable'); - $this->assertInstanceOf(\get_class($node1), $node2); + $this->assertInstanceOf($node1::class, $node2); $builder->setNodeClass('CuStOm', SomeNodeDefinition::class); $node1 = $builder->node('', 'CUSTOM'); $node2 = $builder->node('', 'custom'); - $this->assertInstanceOf(\get_class($node1), $node2); + $this->assertInstanceOf($node1::class, $node2); } public function testNumericNodeCreation() diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index 5e2e6c14428a4..098c56185c011 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -108,7 +108,7 @@ private function interpolate(string $message, array $context): string } elseif ($val instanceof \DateTimeInterface) { $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); } elseif (\is_object($val)) { - $replacements["{{$key}}"] = '[object '.\get_class($val).']'; + $replacements["{{$key}}"] = '[object '.$val::class.']'; } else { $replacements["{{$key}}"] = '['.\gettype($val).']'; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index a8b3c7d9fac9f..26e89a9b9a26a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -258,7 +258,7 @@ private function checkType(Definition $checkedDefinition, mixed $value, \Reflect } elseif ($value instanceof ServiceLocatorArgument) { $class = ServiceLocator::class; } elseif (\is_object($value)) { - $class = \get_class($value); + $class = $value::class; } else { $class = \gettype($value); $class = ['integer' => 'int', 'double' => 'float', 'boolean' => 'bool'][$class] ?? $class; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php index 4102d8039d53d..43f6348c32e13 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php @@ -52,10 +52,10 @@ public function addPass(CompilerPassInterface $pass, string $type = PassConfig:: public function log(CompilerPassInterface $pass, string $message) { if (str_contains($message, "\n")) { - $message = str_replace("\n", "\n".\get_class($pass).': ', trim($message)); + $message = str_replace("\n", "\n".$pass::class.': ', trim($message)); } - $this->log[] = \get_class($pass).': '.$message; + $this->log[] = $pass::class.': '.$message; } public function getLog(): array diff --git a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php index 4afff8f78939c..a0a896458fc57 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php @@ -151,7 +151,7 @@ public function __construct(ExtensionInterface $extension, ParameterBagInterface { parent::__construct($parameterBag); - $this->extensionClass = \get_class($extension); + $this->extensionClass = $extension::class; } public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0): static diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php index 59acd67607e7a..c8217154741c9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php @@ -107,7 +107,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi $definition->setBindings([]); $definition = serialize($definition); - if (Definition::class === \get_class($abstract)) { + if (Definition::class === $abstract::class) { // cast Definition to ChildDefinition $definition = substr_replace($definition, '53', 2, 2); $definition = substr_replace($definition, 'Child', 44, 0); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 874f263ced4b2..d384c4c08927c 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -381,7 +381,7 @@ public static function phpToXml(mixed $value): string case $value instanceof Parameter: return '%'.$value.'%'; case $value instanceof \UnitEnum: - return sprintf('%s::%s', \get_class($value), $value->name); + return sprintf('%s::%s', $value::class, $value->name); case \is_object($value) || \is_resource($value): throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); default: diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 798043c7d5f22..dd1fa0628945e 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -297,7 +297,7 @@ private function dumpValue(mixed $value): mixed } elseif ($value instanceof Definition) { return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']); } elseif ($value instanceof \UnitEnum) { - return new TaggedValue('php/const', sprintf('%s::%s', \get_class($value), $value->name)); + return new TaggedValue('php/const', sprintf('%s::%s', $value::class, $value->name)); } elseif ($value instanceof AbstractArgument) { return new TaggedValue('abstract', $value->getText()); } elseif (\is_object($value) || \is_resource($value)) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php index c2ecdf2f9f5ec..0f8fff4eed26f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php @@ -382,7 +382,7 @@ public static function getSubscribedServices(): array $container->setAlias('stdClass $someService', 'some.service'); $container->setAlias('stdClass $some_service', 'some.service'); $container->setAlias('stdClass $anotherService', 'some.service'); - $container->register('foo', \get_class($subscriber)) + $container->register('foo', $subscriber::class) ->addMethodCall('setContainer', [new Reference(PsrContainerInterface::class)]) ->addTag('container.service_subscriber'); @@ -433,7 +433,7 @@ public static function getSubscribedServices(): array }; $container->setParameter('parameter.1', 'foobar'); - $container->register('foo', \get_class($subscriber)) + $container->register('foo', $subscriber::class) ->addMethodCall('setContainer', [new Reference(PsrContainerInterface::class)]) ->addTag('container.service_subscriber'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index d6b1013c31af3..0c137a39a03ba 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -293,7 +293,7 @@ public function testDeepDefinitionsResolving() $this->assertSame('parentClass', $factory[0]->getClass()); $argument = $container->getDefinition('sibling')->getArgument(0); - $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($argument)); + $this->assertSame('Symfony\Component\DependencyInjection\Definition', $argument::class); $this->assertSame('parentClass', $argument->getClass()); $properties = $container->getDefinition('sibling')->getProperties(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index f719442fbd9bb..5f48b68e2c046 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -381,7 +381,7 @@ public function testCreateProxyWithRealServiceInstantiator() $foo1 = $builder->get('foo1'); $this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls'); - $this->assertSame('Bar\FooClass', \get_class($foo1)); + $this->assertSame('Bar\FooClass', $foo1::class); } public function testCreateLazyProxy() diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 3b29b0f588ffe..cded9781c1f4c 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -207,7 +207,7 @@ public function testConstructor($message, $form, $values) $values, array_map( function ($field) { - $class = \get_class($field); + $class = $field::class; return [substr($class, strrpos($class, '\\') + 1), $field->getValue()]; }, diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php index 4ae6b3fcb7a7d..a45e8e1c7887e 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php @@ -327,7 +327,7 @@ public function testHandleErrorWithAnonymousClass() $handler = ErrorHandler::register(); try { - trigger_error('foo '.\get_class($anonymousObject).' bar', \E_USER_WARNING); + trigger_error('foo '.$anonymousObject::class.' bar', \E_USER_WARNING); $this->fail('Exception expected.'); } catch (\ErrorException $e) { } finally { @@ -372,7 +372,7 @@ public function testHandleException(string $expectedMessage, \Throwable $excepti $logArgCheck = function ($level, $message, $context) use ($expectedMessage, $exception) { $this->assertSame($expectedMessage, $message); $this->assertArrayHasKey('exception', $context); - $this->assertInstanceOf(\get_class($exception), $context['exception']); + $this->assertInstanceOf($exception::class, $context['exception']); }; $logger diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index 6ba5624bd9dfa..5d3c1a8480345 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -137,7 +137,7 @@ private function initTypes() throw new UnexpectedTypeException($type, FormTypeInterface::class); } - $this->types[\get_class($type)] = $type; + $this->types[$type::class] = $type; } } diff --git a/src/Symfony/Component/Form/Command/DebugCommand.php b/src/Symfony/Component/Form/Command/DebugCommand.php index 159051046f35f..afa283bbd5f15 100644 --- a/src/Symfony/Component/Form/Command/DebugCommand.php +++ b/src/Symfony/Component/Form/Command/DebugCommand.php @@ -204,7 +204,7 @@ private function getCoreTypes(): array $coreExtension = new CoreExtension(); $loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes'); $coreTypes = $loadTypesRefMethod->invoke($coreExtension); - $coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes); + $coreTypes = array_map(function (FormTypeInterface $type) { return $type::class; }, $coreTypes); sort($coreTypes); return $coreTypes; diff --git a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php index f6b09c26929a5..ad28cb67dedbe 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php @@ -198,7 +198,7 @@ private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, O foreach ($type->getTypeExtensions() as $extension) { $inheritedOptions = $optionsResolver->getDefinedOptions(); $extension->configureOptions($optionsResolver); - $this->extensions[\get_class($extension)] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions); + $this->extensions[$extension::class] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions); } } } diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 0b978d693de91..d7c93468892b3 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -65,7 +65,7 @@ public function getTypeExtensions(string $name): array // validate the result of getExtendedTypes() to ensure it is consistent with the service definition if (!\in_array($name, $extendedTypes, true)) { - 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))); + 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))); } } } diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 46738b401e544..6fb47884d2e21 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -99,7 +99,7 @@ public function guessPattern(string $class, string $property): ?ValueGuess */ public function guessTypeForConstraint(Constraint $constraint): ?TypeGuess { - switch (\get_class($constraint)) { + switch ($constraint::class) { case Type::class: switch ($constraint->type) { case 'array': @@ -190,7 +190,7 @@ public function guessTypeForConstraint(Constraint $constraint): ?TypeGuess */ public function guessRequiredForConstraint(Constraint $constraint): ?ValueGuess { - return match (\get_class($constraint)) { + return match ($constraint::class) { NotNull::class, NotBlank::class, IsTrue::class => new ValueGuess(true, Guess::HIGH_CONFIDENCE), @@ -203,7 +203,7 @@ public function guessRequiredForConstraint(Constraint $constraint): ?ValueGuess */ public function guessMaxLengthForConstraint(Constraint $constraint): ?ValueGuess { - switch (\get_class($constraint)) { + switch ($constraint::class) { case Length::class: if (is_numeric($constraint->max)) { return new ValueGuess($constraint->max, Guess::HIGH_CONFIDENCE); @@ -231,7 +231,7 @@ public function guessMaxLengthForConstraint(Constraint $constraint): ?ValueGuess */ public function guessPatternForConstraint(Constraint $constraint): ?ValueGuess { - switch (\get_class($constraint)) { + switch ($constraint::class) { case Length::class: if (is_numeric($constraint->min)) { return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE); diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index a22624f3675ca..ab3f55f9fb908 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -90,7 +90,7 @@ public function getType(string $name): ResolvedFormTypeInterface private function resolveType(FormTypeInterface $type): ResolvedFormTypeInterface { $parentType = $type->getParent(); - $fqcn = \get_class($type); + $fqcn = $type::class; if (isset($this->checkedTypes[$fqcn])) { $types = implode(' > ', array_merge(array_keys($this->checkedTypes), [$fqcn])); diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index 5590eda3706f7..c8e628d2d20e9 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -36,7 +36,7 @@ public function __construct(array $types, array $typeExtensions, FormTypeGuesser $this->typeGuesser = $typeGuesser; foreach ($types as $type) { - $this->types[\get_class($type)] = $type; + $this->types[$type::class] = $type; } } diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 6a4c8552befed..d0037bbfbda37 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -263,7 +263,7 @@ private function getCoreTypes(): array $coreExtension = new CoreExtension(); $loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes'); $coreTypes = $loadTypesRefMethod->invoke($coreExtension); - $coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes); + $coreTypes = array_map(function (FormTypeInterface $type) { return $type::class; }, $coreTypes); sort($coreTypes); return $coreTypes; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php index 1b625dc139adc..b39572ed808a5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php @@ -334,7 +334,7 @@ public function testMapFormsToDataDoesNotChangeEqualDateTimeInstance($date) $article['publishedAt'] = $publishedAtValue; $propertyPath = new PropertyPath('[publishedAt]'); - $config = new FormConfigBuilder('publishedAt', \get_class($publishedAt), $this->dispatcher); + $config = new FormConfigBuilder('publishedAt', $publishedAt::class, $this->dispatcher); $config->setByReference(false); $config->setPropertyPath($propertyPath); $config->setData($publishedAt); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index af8f048e5404c..e5b0d736b0672 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -736,7 +736,7 @@ private function getForm($name = 'name', $dataClass = null, array $options = []) private function getCompoundForm($data, array $options = []) { - return $this->getBuilder('name', \is_object($data) ? \get_class($data) : null, $options) + return $this->getBuilder('name', \is_object($data) ? $data::class : null, $options) ->setData($data) ->setCompound(true) ->setDataMapper(new DataMapper()) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 9b0c9d1481437..30db508520260 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -113,7 +113,7 @@ public function testManyFieldsGroupSequenceWithConstraintsOption() return $formMetadata; } - return new ClassMetadata(\is_string($classOrObject) ? $classOrObject : \get_class($classOrObject)); + return new ClassMetadata(\is_string($classOrObject) ? $classOrObject : $classOrObject::class); }) ; diff --git a/src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php b/src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php index 1f48be5c574c2..23dc7b6d9f0b0 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php @@ -203,7 +203,7 @@ public function testRetryNetworkError() return $response; }, function (\Exception $exception) use (&$failureCallableCalled, $client) { - $this->assertSame(NetworkException::class, \get_class($exception)); + $this->assertSame(NetworkException::class, $exception::class); $this->assertSame(TransportException::class, \get_class($exception->getPrevious())); $failureCallableCalled = true; @@ -246,7 +246,7 @@ function (ResponseInterface $response) use (&$successCallableCalled) { return $response; }, function (\Exception $exception) use ($errorMessage, &$failureCallableCalled, $client, $request) { - $this->assertSame(NetworkException::class, \get_class($exception)); + $this->assertSame(NetworkException::class, $exception::class); $this->assertSame($errorMessage, $exception->getMessage()); $failureCallableCalled = true; diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index cec01e71dee75..81278931545a8 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -127,7 +127,7 @@ public function setData(mixed $data = []): static try { $data = json_encode($data, $this->encodingOptions); } catch (\Exception $e) { - if ('Exception' === \get_class($e) && str_starts_with($e->getMessage(), 'Failed calling ')) { + if ('Exception' === $e::class && str_starts_with($e->getMessage(), 'Failed calling ')) { throw $e->getPrevious() ?: $e; } throw $e; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index d80e7436191d8..6deee421687f7 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -240,7 +240,7 @@ public function save() $previousHandler = set_error_handler(function ($type, $msg, $file, $line) use (&$previousHandler) { if (\E_WARNING === $type && str_starts_with($msg, 'session_write_close():')) { $handler = $this->saveHandler instanceof SessionHandlerProxy ? $this->saveHandler->getHandler() : $this->saveHandler; - $msg = sprintf('session_write_close(): Failed to write session data with "%s" handler', \get_class($handler)); + $msg = sprintf('session_write_close(): Failed to write session data with "%s" handler', $handler::class); } return $previousHandler ? $previousHandler($type, $msg, $file, $line) : false; diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index df791db3d7e55..a352090eac842 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -134,7 +134,7 @@ public function getAttributesOfType(string $name, int $flags = 0): array } } else { foreach ($this->attributes as $attribute) { - if (\get_class($attribute) === $name) { + if ($attribute::class === $name) { $attributes[] = $attribute; } } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 3b7ff410f6a31..fcc9ccd9e8393 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -62,7 +62,7 @@ public function collect(Request $request, Response $response, \Throwable $except if (isset($this->kernel)) { foreach ($this->kernel->getBundles() as $name => $bundle) { - $this->data['bundles'][$name] = new ClassStub(\get_class($bundle)); + $this->data['bundles'][$name] = new ClassStub($bundle::class); } } diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 9713ff3508b46..d87fbea29b94a 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -256,7 +256,7 @@ private function handleThrowable(\Throwable $e, Request $request, int $type): Re private function varToString(mixed $var): string { if (\is_object($var)) { - return sprintf('an object of type %s', \get_class($var)); + return sprintf('an object of type %s', $var::class); } if (\is_array($var)) { diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8210e0e308577..3661c216a2c4b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -540,7 +540,7 @@ protected function getKernelParameters(): array $bundlesMetadata = []; foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = \get_class($bundle); + $bundles[$name] = $bundle::class; $bundlesMetadata[$name] = [ 'path' => $bundle->getPath(), 'namespace' => $bundle->getNamespace(), diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/UidValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/UidValueResolverTest.php index 766c028873fd1..72e4921e7d219 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/UidValueResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/UidValueResolverTest.php @@ -63,7 +63,7 @@ public function testResolveOK(AbstractUid $expected, string $requestUid) { $this->assertEquals([$expected], (new UidValueResolver())->resolve( new Request([], [], ['id' => $requestUid]), - new ArgumentMetadata('id', \get_class($expected), false, false, null) + new ArgumentMetadata('id', $expected::class, false, false, null) )); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php index dc2ef3055eb39..e988fe6914956 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php @@ -40,8 +40,8 @@ public function testConstruct() $logger = new TestLogger(); $l = new ErrorListener('foo', $logger); - $_logger = new \ReflectionProperty(\get_class($l), 'logger'); - $_controller = new \ReflectionProperty(\get_class($l), 'controller'); + $_logger = new \ReflectionProperty($l::class, 'logger'); + $_controller = new \ReflectionProperty($l::class, 'controller'); $this->assertSame($logger, $_logger->getValue($l)); $this->assertSame('foo', $_controller->getValue($l)); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 1810d61ccbda0..fa127326ee839 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -640,7 +640,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->willReturn($bundleName ?? \get_class($bundle)) + ->willReturn($bundleName ?? $bundle::class) ; $bundle diff --git a/src/Symfony/Component/Intl/Resources/bin/common.php b/src/Symfony/Component/Intl/Resources/bin/common.php index cf47fa448b034..02aaf06300376 100644 --- a/src/Symfony/Component/Intl/Resources/bin/common.php +++ b/src/Symfony/Component/Intl/Resources/bin/common.php @@ -85,7 +85,7 @@ function get_icu_version_from_genrb(string $genrb) echo "Caused by\n"; } - echo get_class($cause).': '.$cause->getMessage()."\n"; + echo $cause::class.': '.$cause->getMessage()."\n"; echo "\n"; echo $cause->getFile().':'.$cause->getLine()."\n"; echo $cause->getTraceAsString()."\n"; diff --git a/src/Symfony/Component/Mailer/Envelope.php b/src/Symfony/Component/Mailer/Envelope.php index f35f25f3652eb..0a4af2eda9dad 100644 --- a/src/Symfony/Component/Mailer/Envelope.php +++ b/src/Symfony/Component/Mailer/Envelope.php @@ -35,7 +35,7 @@ public function __construct(Address $sender, array $recipients) public static function create(RawMessage $message): self { - if (RawMessage::class === \get_class($message)) { + if (RawMessage::class === $message::class) { throw new LogicException('Cannot send a RawMessage instance without an explicit Envelope.'); } diff --git a/src/Symfony/Component/Mailer/Transport/Transports.php b/src/Symfony/Component/Mailer/Transport/Transports.php index 71182a8350936..1beaa883e49ec 100644 --- a/src/Symfony/Component/Mailer/Transport/Transports.php +++ b/src/Symfony/Component/Mailer/Transport/Transports.php @@ -47,7 +47,7 @@ public function __construct(iterable $transports) public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage { /** @var Message $message */ - if (RawMessage::class === \get_class($message) || !$message->getHeaders()->has('X-Transport')) { + if (RawMessage::class === $message::class || !$message->getHeaders()->has('X-Transport')) { return $this->default->send($message, $envelope); } diff --git a/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php b/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php index f73d681a3ebfd..be10f5e7bc97a 100644 --- a/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php +++ b/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php @@ -88,7 +88,7 @@ private function collectMessage(string $busName, array $tracedMessage) 'stamps' => $tracedMessage['stamps'] ?? null, 'stamps_after_dispatch' => $tracedMessage['stamps_after_dispatch'] ?? null, 'message' => [ - 'type' => new ClassStub(\get_class($message)), + 'type' => new ClassStub($message::class), 'value' => $message, ], 'caller' => $tracedMessage['caller'], @@ -98,7 +98,7 @@ private function collectMessage(string $busName, array $tracedMessage) $exception = $tracedMessage['exception']; $debugRepresentation['exception'] = [ - 'type' => \get_class($exception), + 'type' => $exception::class, 'value' => $exception, ]; } diff --git a/src/Symfony/Component/Messenger/Envelope.php b/src/Symfony/Component/Messenger/Envelope.php index 72e830c174ede..a9ea4e0b48f5f 100644 --- a/src/Symfony/Component/Messenger/Envelope.php +++ b/src/Symfony/Component/Messenger/Envelope.php @@ -35,7 +35,7 @@ public function __construct(object $message, array $stamps = []) $this->message = $message; foreach ($stamps as $stamp) { - $this->stamps[\get_class($stamp)][] = $stamp; + $this->stamps[$stamp::class][] = $stamp; } } @@ -59,7 +59,7 @@ public function with(StampInterface ...$stamps): static $cloned = clone $this; foreach ($stamps as $stamp) { - $cloned->stamps[\get_class($stamp)][] = $stamp; + $cloned->stamps[$stamp::class][] = $stamp; } return $cloned; diff --git a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php index 31b418a2ecce4..0f071e82e702d 100644 --- a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php +++ b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php @@ -56,7 +56,7 @@ public function onMessageFailed(WorkerMessageFailedEvent $event) $message = $envelope->getMessage(); $context = [ - 'class' => \get_class($message), + 'class' => $message::class, ]; $shouldRetry = $retryStrategy && $this->shouldRetry($throwable, $envelope, $retryStrategy); @@ -89,7 +89,7 @@ public function onMessageFailed(WorkerMessageFailedEvent $event) private function withLimitedHistory(Envelope $envelope, StampInterface ...$stamps): Envelope { foreach ($stamps as $stamp) { - $history = $envelope->all(\get_class($stamp)); + $history = $envelope->all($stamp::class); if (\count($history) < $this->historySize) { $envelope = $envelope->with($stamp); continue; @@ -101,7 +101,7 @@ private function withLimitedHistory(Envelope $envelope, StampInterface ...$stamp [$stamp] ); - $envelope = $envelope->withoutAll(\get_class($stamp))->with(...$history); + $envelope = $envelope->withoutAll($stamp::class)->with(...$history); } return $envelope; diff --git a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php index 21cad3ac627c7..4b6c6a2860a48 100644 --- a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php +++ b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php @@ -62,7 +62,7 @@ public function onMessageFailed(WorkerMessageFailedEvent $event) $this->logger?->info('Rejected message {class} will be sent to the failure transport {transport}.', [ 'class' => \get_class($envelope->getMessage()), - 'transport' => \get_class($failureSender), + 'transport' => $failureSender::class, ]); $failureSender->send($envelope); diff --git a/src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php b/src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php index 7dd6a9b0b1116..a5065131c40ff 100644 --- a/src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php +++ b/src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php @@ -25,7 +25,7 @@ public function __construct(array $exceptions) { $exceptionMessages = implode(", \n", array_map( function (\Throwable $e) { - return \get_class($e).': '.$e->getMessage(); + return $e::class.': '.$e->getMessage(); }, $exceptions )); diff --git a/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php b/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php index e090b037e4b23..ec5b1016364f8 100644 --- a/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php @@ -52,7 +52,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope $message = $envelope->getMessage(); $context = [ - 'class' => \get_class($message), + 'class' => $message::class, ]; $exceptions = []; diff --git a/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php b/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php index 9a9f362876215..c52119c7f0097 100644 --- a/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php @@ -61,8 +61,8 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope $shouldDispatchEvent = false; } - $this->logger->info('Sending message {class} with {alias} sender using {sender}', $context + ['alias' => $alias, 'sender' => \get_class($sender)]); - $envelope = $sender->send($envelope->with(new SentStamp(\get_class($sender), \is_string($alias) ? $alias : null))); + $this->logger->info('Sending message {class} with {alias} sender using {sender}', $context + ['alias' => $alias, 'sender' => $sender::class]); + $envelope = $sender->send($envelope->with(new SentStamp($sender::class, \is_string($alias) ? $alias : null))); } } diff --git a/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php b/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php index 41b2190560d6f..0331ff24dbf73 100644 --- a/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php +++ b/src/Symfony/Component/Messenger/Stamp/ErrorDetailsStamp.php @@ -44,7 +44,7 @@ public static function create(Throwable $throwable): self $flattenException = FlattenException::createFromThrowable($throwable); } - return new self(\get_class($throwable), $throwable->getCode(), $throwable->getMessage(), $flattenException); + return new self($throwable::class, $throwable->getCode(), $throwable->getMessage(), $flattenException); } public function getExceptionClass(): string diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php index c36274b12fe0a..4d7dd32b03547 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php @@ -72,11 +72,11 @@ public function itAddsHandledStampsProvider(): iterable { $first = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']); $first->method('__invoke')->willReturn('first result'); - $firstClass = \get_class($first); + $firstClass = $first::class; $second = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']); $second->method('__invoke')->willReturn(null); - $secondClass = \get_class($second); + $secondClass = $second::class; $failing = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']); $failing->method('__invoke')->will($this->throwException(new \Exception('handler failed.'))); diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/SendMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/SendMessageMiddlewareTest.php index b9992fc90fd0c..a0ff3667c9e5e 100644 --- a/src/Symfony/Component/Messenger/Tests/Middleware/SendMessageMiddlewareTest.php +++ b/src/Symfony/Component/Messenger/Tests/Middleware/SendMessageMiddlewareTest.php @@ -36,7 +36,7 @@ public function testItSendsTheMessageToAssignedSender() $sendersLocator = $this->createSendersLocator([DummyMessage::class => ['my_sender']], ['my_sender' => $sender]); $middleware = new SendMessageMiddleware($sendersLocator); - $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp(\get_class($sender), 'my_sender')))->willReturnArgument(0); + $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp($sender::class, 'my_sender')))->willReturnArgument(0); $envelope = $middleware->handle($envelope, $this->getStackMock(false)); @@ -91,7 +91,7 @@ public function testItSendsTheMessageToAssignedSenderWithPreWrappedMessage() $sendersLocator = $this->createSendersLocator([DummyMessage::class => ['foo_sender']], ['foo_sender' => $sender]); $middleware = new SendMessageMiddleware($sendersLocator); - $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp(\get_class($sender), 'foo_sender')))->willReturn($envelope); + $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp($sender::class, 'foo_sender')))->willReturn($envelope); $middleware->handle($envelope, $this->getStackMock(false)); } @@ -105,7 +105,7 @@ public function testItSendsTheMessageBasedOnTheMessageParentClass() $sendersLocator = $this->createSendersLocator([DummyMessage::class => ['foo_sender']], ['foo_sender' => $sender]); $middleware = new SendMessageMiddleware($sendersLocator); - $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp(\get_class($sender), 'foo_sender')))->willReturn($envelope); + $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp($sender::class, 'foo_sender')))->willReturn($envelope); $middleware->handle($envelope, $this->getStackMock(false)); } @@ -119,7 +119,7 @@ public function testItSendsTheMessageBasedOnTheMessageInterface() $sendersLocator = $this->createSendersLocator([DummyMessageInterface::class => ['foo_sender']], ['foo_sender' => $sender]); $middleware = new SendMessageMiddleware($sendersLocator); - $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp(\get_class($sender), 'foo_sender')))->willReturn($envelope); + $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp($sender::class, 'foo_sender')))->willReturn($envelope); $middleware->handle($envelope, $this->getStackMock(false)); } @@ -133,7 +133,7 @@ public function testItSendsTheMessageBasedOnWildcard() $sendersLocator = $this->createSendersLocator(['*' => ['foo_sender']], ['foo_sender' => $sender]); $middleware = new SendMessageMiddleware($sendersLocator); - $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp(\get_class($sender), 'foo_sender')))->willReturn($envelope); + $sender->expects($this->once())->method('send')->with($envelope->with(new SentStamp($sender::class, 'foo_sender')))->willReturn($envelope); $middleware->handle($envelope, $this->getStackMock(false)); } diff --git a/src/Symfony/Component/Messenger/Tests/WorkerTest.php b/src/Symfony/Component/Messenger/Tests/WorkerTest.php index 85419c78e45fa..5103d4ad84568 100644 --- a/src/Symfony/Component/Messenger/Tests/WorkerTest.php +++ b/src/Symfony/Component/Messenger/Tests/WorkerTest.php @@ -425,7 +425,7 @@ public function testWorkerMessageReceivedEventMutability() $worker->run(); $envelope = current($receiver->getAcknowledgedEnvelopes()); - $this->assertCount(1, $envelope->all(\get_class($stamp))); + $this->assertCount(1, $envelope->all($stamp::class)); } public function testWorkerRateLimitMessages() diff --git a/src/Symfony/Component/Messenger/Worker.php b/src/Symfony/Component/Messenger/Worker.php index fee30a460f831..1608644f9d6bd 100644 --- a/src/Symfony/Component/Messenger/Worker.php +++ b/src/Symfony/Component/Messenger/Worker.php @@ -211,7 +211,7 @@ private function ack(): bool if (null !== $this->logger) { $message = $envelope->getMessage(); $context = [ - 'class' => \get_class($message), + 'class' => $message::class, ]; $this->logger->info('{class} was handled successfully (acknowledging to transport).', $context); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php b/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php index d7d5b928dc367..6ca9cc0587d7b 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php @@ -37,7 +37,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message)) { + if (RawMessage::class === $message::class) { throw new \LogicException('Unable to test a message address on a RawMessage instance.'); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailAttachmentCount.php b/src/Symfony/Component/Mime/Test/Constraint/EmailAttachmentCount.php index 3ba5c724bae7c..d5c8ae981189c 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailAttachmentCount.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailAttachmentCount.php @@ -36,7 +36,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { + if (RawMessage::class === $message::class || Message::class === $message::class) { throw new \LogicException('Unable to test a message attachment on a RawMessage or Message instance.'); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailHasHeader.php b/src/Symfony/Component/Mime/Test/Constraint/EmailHasHeader.php index d2cd36b805a14..b7c5625b266bc 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailHasHeader.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailHasHeader.php @@ -33,7 +33,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message)) { + if (RawMessage::class === $message::class) { throw new \LogicException('Unable to test a message header on a RawMessage instance.'); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php b/src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php index 752d370719555..edb6ab4257d74 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php @@ -36,7 +36,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message)) { + if (RawMessage::class === $message::class) { throw new \LogicException('Unable to test a message header on a RawMessage instance.'); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailHtmlBodyContains.php b/src/Symfony/Component/Mime/Test/Constraint/EmailHtmlBodyContains.php index 00a4b9dea2cb1..cbf303d1be6e5 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailHtmlBodyContains.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailHtmlBodyContains.php @@ -34,7 +34,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { + if (RawMessage::class === $message::class || Message::class === $message::class) { throw new \LogicException('Unable to test a message HTML body on a RawMessage or Message instance.'); } diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailTextBodyContains.php b/src/Symfony/Component/Mime/Test/Constraint/EmailTextBodyContains.php index 00bfd5b415dd0..592595cf44919 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailTextBodyContains.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailTextBodyContains.php @@ -34,7 +34,7 @@ public function toString(): string */ protected function matches($message): bool { - if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) { + if (RawMessage::class === $message::class || Message::class === $message::class) { throw new \LogicException('Unable to test a message text body on a RawMessage or Message instance.'); } diff --git a/src/Symfony/Component/Notifier/Notification/Notification.php b/src/Symfony/Component/Notifier/Notification/Notification.php index 673fa8bc7abd3..f423804717f5e 100644 --- a/src/Symfony/Component/Notifier/Notification/Notification.php +++ b/src/Symfony/Component/Notifier/Notification/Notification.php @@ -139,7 +139,7 @@ public function getEmoji(): string */ public function exception(\Throwable $exception): static { - $parts = explode('\\', \get_class($exception)); + $parts = explode('\\', $exception::class); $this->subject = sprintf('%s: %s', array_pop($parts), $exception->getMessage()); if (class_exists(FlattenException::class)) { @@ -202,7 +202,7 @@ private function computeExceptionAsString(\Throwable $exception): string return $exception->getAsString(); } - $message = \get_class($exception); + $message = $exception::class; if ('' !== $exception->getMessage()) { $message .= ': '.$exception->getMessage(); } diff --git a/src/Symfony/Component/Notifier/Notifier.php b/src/Symfony/Component/Notifier/Notifier.php index edc6928b10c51..2e0665cef7c28 100644 --- a/src/Symfony/Component/Notifier/Notifier.php +++ b/src/Symfony/Component/Notifier/Notifier.php @@ -72,7 +72,7 @@ private function getChannels(Notification $notification, RecipientInterface $rec { $channels = $notification->getChannels($recipient); if (!$channels) { - $errorPrefix = sprintf('Unable to determine which channels to use to send the "%s" notification', \get_class($notification)); + $errorPrefix = sprintf('Unable to determine which channels to use to send the "%s" notification', $notification::class); $error = 'you should either pass channels in the constructor, override its "getChannels()" method'; if (null === $this->policy) { throw new LogicException(sprintf('%s; %s, or configure a "%s".', $errorPrefix, $error, ChannelPolicy::class)); diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 205c15b4cd8ca..6e78815e87f51 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -1222,7 +1222,7 @@ public function count(): int private function formatValue(mixed $value): string { if (\is_object($value)) { - return \get_class($value); + return $value::class; } if (\is_array($value)) { diff --git a/src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php b/src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php index 81122d1cd3424..5fdc89cab91f5 100644 --- a/src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php +++ b/src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php @@ -143,7 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $hashedPassword = $hasher->hash($password, $salt); $rows = [ - ['Hasher used', \get_class($hasher)], + ['Hasher used', $hasher::class], ['Password hash', $hashedPassword], ]; if (!$emptySalt) { diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index c076f572df616..20256928c2506 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -381,7 +381,7 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid $result = self::RESULT_PROTO; $object = $zval[self::VALUE]; - $class = \get_class($object); + $class = $object::class; $access = $this->getReadInfo($class, $property); if (null !== $access) { @@ -502,7 +502,7 @@ private function writeProperty(array $zval, string $property, mixed $value) } $object = $zval[self::VALUE]; - $class = \get_class($object); + $class = $object::class; $mutator = $this->getWriteInfo($class, $property, $value); if (PropertyWriteInfo::TYPE_NONE !== $mutator->getType()) { @@ -597,13 +597,13 @@ private function getWriteInfo(string $class, string $property, mixed $value): Pr */ private function isPropertyWritable(object $object, string $property): bool { - $mutatorForArray = $this->getWriteInfo(\get_class($object), $property, []); + $mutatorForArray = $this->getWriteInfo($object::class, $property, []); if (PropertyWriteInfo::TYPE_NONE !== $mutatorForArray->getType() || ($object instanceof \stdClass && property_exists($object, $property))) { return true; } - $mutator = $this->getWriteInfo(\get_class($object), $property, ''); + $mutator = $this->getWriteInfo($object::class, $property, ''); return PropertyWriteInfo::TYPE_NONE !== $mutator->getType() || ($object instanceof \stdClass && property_exists($object, $property)); } diff --git a/src/Symfony/Component/Routing/Requirement/EnumRequirement.php b/src/Symfony/Component/Routing/Requirement/EnumRequirement.php index 2a369845c4eb4..3ab2ed3321028 100644 --- a/src/Symfony/Component/Routing/Requirement/EnumRequirement.php +++ b/src/Symfony/Component/Routing/Requirement/EnumRequirement.php @@ -38,7 +38,7 @@ public function __construct(string|array $cases = []) throw new InvalidArgumentException(sprintf('Case must be a "BackedEnum" instance, "%s" given.', get_debug_type($case))); } - $class ??= \get_class($case); + $class ??= $case::class; if (!$case instanceof $class) { throw new InvalidArgumentException(sprintf('"%s::%s" is not a case of "%s".', get_debug_type($case), $case->name, $class)); diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index ed5857577c86b..025f6827bdfd1 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -86,7 +86,7 @@ private function getVoters(array $attributes, $object = null): iterable $keyAttributes[] = \is_string($attribute) ? $attribute : null; } // use `get_class` to handle anonymous classes - $keyObject = \is_object($object) ? \get_class($object) : get_debug_type($object); + $keyObject = \is_object($object) ? $object::class : get_debug_type($object); foreach ($this->voters as $key => $voter) { if (!$voter instanceof CacheableVoterInterface) { yield $voter; diff --git a/src/Symfony/Component/Security/Core/Signature/SignatureHasher.php b/src/Symfony/Component/Security/Core/Signature/SignatureHasher.php index 29d508cecd90e..39c02d56c5208 100644 --- a/src/Symfony/Component/Security/Core/Signature/SignatureHasher.php +++ b/src/Symfony/Component/Security/Core/Signature/SignatureHasher.php @@ -88,7 +88,7 @@ public function computeSignatureHash(UserInterface $user, int $expires): string } if (!\is_scalar($value) && !$value instanceof \Stringable) { - throw new \InvalidArgumentException(sprintf('The property path "%s" on the user object "%s" must return a value that can be cast to a string, but "%s" was returned.', $property, \get_class($user), get_debug_type($value))); + throw new \InvalidArgumentException(sprintf('The property path "%s" on the user object "%s" must return a value that can be cast to a string, but "%s" was returned.', $property, $user::class, get_debug_type($value))); } $signatureFields[] = base64_encode($value); } diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php index e174dfbfcbc5f..4ab19b1da8bd1 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php @@ -102,13 +102,13 @@ public function supports(Request $request): ?bool $skippedAuthenticators = []; $lazy = true; foreach ($this->authenticators as $authenticator) { - $this->logger?->debug('Checking support on authenticator.', ['firewall_name' => $this->firewallName, 'authenticator' => \get_class($authenticator)]); + $this->logger?->debug('Checking support on authenticator.', ['firewall_name' => $this->firewallName, 'authenticator' => $authenticator::class]); if (false !== $supports = $authenticator->supports($request)) { $authenticators[] = $authenticator; $lazy = $lazy && null === $supports; } else { - $this->logger?->debug('Authenticator does not support the request.', ['firewall_name' => $this->firewallName, 'authenticator' => \get_class($authenticator)]); + $this->logger?->debug('Authenticator does not support the request.', ['firewall_name' => $this->firewallName, 'authenticator' => $authenticator::class]); $skippedAuthenticators[] = $authenticator; } } @@ -181,7 +181,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req throw new BadCredentialsException(sprintf('Authentication failed: Security badge "%s" is not resolved, did you forget to register the correct listeners?', get_debug_type($badge))); } - $resolvedBadges[] = \get_class($badge); + $resolvedBadges[] = $badge::class; } $missingRequiredBadges = array_diff($this->requiredBadges, $resolvedBadges); diff --git a/src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticatorManagerListener.php b/src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticatorManagerListener.php index a5bc1c57799fb..2e933a32e8c49 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticatorManagerListener.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticatorManagerListener.php @@ -50,7 +50,7 @@ public function authenticate(RequestEvent $event): void foreach ($request->attributes->get('_security_skipped_authenticators') as $skippedAuthenticator) { $this->authenticatorsInfo[] = [ 'supports' => false, - 'stub' => $this->hasVardumper ? new ClassStub(\get_class($skippedAuthenticator)) : \get_class($skippedAuthenticator), + 'stub' => $this->hasVardumper ? new ClassStub($skippedAuthenticator::class) : $skippedAuthenticator::class, 'passport' => null, 'duration' => 0, ]; diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php index ea05acec27d7f..f6b5afa58f321 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php +++ b/src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php @@ -70,7 +70,7 @@ public function getUser(): UserInterface */ public function addBadge(BadgeInterface $badge): static { - $this->badges[\get_class($badge)] = $badge; + $this->badges[$badge::class] = $badge; return $this; } diff --git a/src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php b/src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php index 9f439561e703b..bbe9813f2a5d6 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php +++ b/src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php @@ -52,7 +52,7 @@ public function createRememberMeCookie(UserInterface $user): void { $series = base64_encode(random_bytes(64)); $tokenValue = $this->generateHash(base64_encode(random_bytes(64))); - $token = new PersistentToken(\get_class($user), $user->getUserIdentifier(), $series, $tokenValue, new \DateTime()); + $token = new PersistentToken($user::class, $user->getUserIdentifier(), $series, $tokenValue, new \DateTime()); $this->tokenProvider->createNewToken($token); $this->createCookie(RememberMeDetails::fromPersistentToken($token, time() + $this->options['lifetime'])); diff --git a/src/Symfony/Component/Security/Http/RememberMe/SignatureRememberMeHandler.php b/src/Symfony/Component/Security/Http/RememberMe/SignatureRememberMeHandler.php index 5f6edcb28c604..8a12dbea9ab57 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/SignatureRememberMeHandler.php +++ b/src/Symfony/Component/Security/Http/RememberMe/SignatureRememberMeHandler.php @@ -46,7 +46,7 @@ public function createRememberMeCookie(UserInterface $user): void $expires = time() + $this->options['lifetime']; $value = $this->signatureHasher->computeSignatureHash($user, $expires); - $details = new RememberMeDetails(\get_class($user), $user->getUserIdentifier(), $expires, $value); + $details = new RememberMeDetails($user::class, $user->getUserIdentifier(), $expires, $value); $this->createCookie($details); } diff --git a/src/Symfony/Component/Semaphore/Store/StoreFactory.php b/src/Symfony/Component/Semaphore/Store/StoreFactory.php index 6e03d619feff5..1d4ec3a72505c 100644 --- a/src/Symfony/Component/Semaphore/Store/StoreFactory.php +++ b/src/Symfony/Component/Semaphore/Store/StoreFactory.php @@ -36,7 +36,7 @@ public static function createStore(object|string $connection): PersistingStoreIn return new RedisStore($connection); case !\is_string($connection): - throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection))); + throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection::class)); case str_starts_with($connection, 'redis://'): case str_starts_with($connection, 'rediss://'): if (!class_exists(AbstractAdapter::class)) { diff --git a/src/Symfony/Component/Serializer/Extractor/ObjectPropertyListExtractor.php b/src/Symfony/Component/Serializer/Extractor/ObjectPropertyListExtractor.php index 0524b03806272..9b73446273726 100644 --- a/src/Symfony/Component/Serializer/Extractor/ObjectPropertyListExtractor.php +++ b/src/Symfony/Component/Serializer/Extractor/ObjectPropertyListExtractor.php @@ -29,7 +29,7 @@ public function __construct(PropertyListExtractorInterface $propertyListExtracto public function getProperties(object $object, array $context = []): ?array { - $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object); + $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : $object::class; return $this->propertyListExtractor->getProperties($class, $context); } diff --git a/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php b/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php index 8b9b02896c338..5359408dd80b5 100644 --- a/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php +++ b/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php @@ -48,7 +48,7 @@ public function getMappingForMappedObject(object|string $object): ?ClassDiscrimi } } - $cacheKey = \is_object($object) ? \get_class($object) : $object; + $cacheKey = \is_object($object) ? $object::class : $object; if (!\array_key_exists($cacheKey, $this->mappingForMappedObjectCache)) { $this->mappingForMappedObjectCache[$cacheKey] = $this->resolveMappingForMappedObject($object); } diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php index 05ce80922c859..7af722d55ee7f 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php @@ -37,6 +37,6 @@ private function getClass(object|string $value): string return ltrim($value, '\\'); } - return \get_class($value); + return $value::class; } } diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/CompiledClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/CompiledClassMetadataFactory.php index 5bac97581caa2..670a935875d94 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/CompiledClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/CompiledClassMetadataFactory.php @@ -44,7 +44,7 @@ public function __construct(string $compiledClassMetadataFile, ClassMetadataFact public function getMetadataFor(string|object $value): ClassMetadataInterface { - $className = \is_object($value) ? \get_class($value) : $value; + $className = \is_object($value) ? $value::class : $value; if (!isset($this->compiledClassMetadata[$className])) { return $this->classMetadataFactory->getMetadataFor($value); @@ -69,7 +69,7 @@ public function getMetadataFor(string|object $value): ClassMetadataInterface public function hasMetadataFor(mixed $value): bool { - $className = \is_object($value) ? \get_class($value) : $value; + $className = \is_object($value) ? $value::class : $value; return isset($this->compiledClassMetadata[$className]) || $this->classMetadataFactory->hasMetadataFor($value); } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 1a499a04908dc..59704c6d6c076 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -156,7 +156,7 @@ public function normalize(mixed $object, string $format = null, array $context = $data = []; $stack = []; $attributes = $this->getAttributes($object, $format, $context); - $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object); + $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : $object::class; $attributesMetadata = $this->classMetadataFactory?->getMetadataFor($class)->getAttributesMetadata(); if (isset($context[self::MAX_DEPTH_HANDLER])) { $maxDepthHandler = $context[self::MAX_DEPTH_HANDLER]; @@ -248,7 +248,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex */ protected function getAttributes(object $object, ?string $format, array $context): array { - $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object); + $class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : $object::class; $key = $class.'-'.$context['cache_key']; if (isset($this->attributesCache[$key])) { @@ -318,7 +318,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar $reflectionClass = new \ReflectionClass($type); $object = $this->instantiateObject($normalizedData, $type, $context, $reflectionClass, $allowedAttributes, $format); - $resolvedClass = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object); + $resolvedClass = $this->objectClassResolver ? ($this->objectClassResolver)($object) : $object::class; foreach ($normalizedData as $attribute => $value) { if ($this->nameConverter) { diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index a0b6ee78037f3..08ccfd1bd5de4 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -137,7 +137,7 @@ protected function getAttributeValue(object $object, string $attribute, string $ protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []) { $setter = 'set'.ucfirst($attribute); - $key = \get_class($object).':'.$setter; + $key = $object::class.':'.$setter; if (!isset(self::$setterAccessibleCache[$key])) { self::$setterAccessibleCache[$key] = \is_callable([$object, $setter]) && !(new \ReflectionMethod($object, $setter))->isStatic(); diff --git a/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php index 1a31558186b1a..f112b3e2cbbb4 100644 --- a/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php @@ -61,7 +61,7 @@ public function normalize(mixed $object, string $format = null, array $context = if ($object instanceof AbstractPart) { $ret = $this->normalizer->normalize($object, $format, $context); - $ret['class'] = \get_class($object); + $ret['class'] = $object::class; return $ret; } diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index 5851bfe9a89a5..b949193e4312b 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -45,7 +45,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); $this->objectClassResolver = $objectClassResolver ?? function ($class) { - return \is_object($class) ? \get_class($class) : $class; + return \is_object($class) ? $class::class : $class; }; } @@ -56,7 +56,7 @@ public function hasCacheableSupportsMethod(): bool protected function extractAttributes(object $object, string $format = null, array $context = []): array { - if (\stdClass::class === \get_class($object)) { + if (\stdClass::class === $object::class) { return array_keys((array) $object); } @@ -119,7 +119,7 @@ protected function extractAttributes(object $object, string $format = null, arra protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed { - $cacheKey = \get_class($object); + $cacheKey = $object::class; if (!\array_key_exists($cacheKey, $this->discriminatorCache)) { $this->discriminatorCache[$cacheKey] = null; if (null !== $this->classDiscriminatorResolver) { @@ -147,7 +147,7 @@ protected function getAllowedAttributes(string|object $classOrObject, array $con } if (null !== $this->classDiscriminatorResolver) { - $class = \is_object($classOrObject) ? \get_class($classOrObject) : $classOrObject; + $class = \is_object($classOrObject) ? $classOrObject::class : $classOrObject; if (null !== $discriminatorMapping = $this->classDiscriminatorResolver->getMappingForMappedObject($classOrObject)) { $allowedAttributes[] = $attributesAsString ? $discriminatorMapping->getTypeProperty() : new AttributeMetadata($discriminatorMapping->getTypeProperty()); } diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php index 365b9f56c36fd..144f1c448dc97 100644 --- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php @@ -59,7 +59,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory */ public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool { - return parent::supportsNormalization($data, $format) && $this->supports(\get_class($data)); + return parent::supportsNormalization($data, $format) && $this->supports($data::class); } /** @@ -164,7 +164,7 @@ protected function getAttributeValue(object $object, string $attribute, string $ || ($reflectionProperty->isProtected() && !\array_key_exists("\0*\0{$reflectionProperty->name}", $propertyValues)) || ($reflectionProperty->isPrivate() && !\array_key_exists("\0{$reflectionProperty->class}\0{$reflectionProperty->name}", $propertyValues)) ) { - throw new UninitializedPropertyException(sprintf('The property "%s::$%s" is not initialized.', \get_class($object), $reflectionProperty->name)); + throw new UninitializedPropertyException(sprintf('The property "%s::$%s" is not initialized.', $object::class, $reflectionProperty->name)); } } diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 7896129b24323..85a3ac5b558d4 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -246,7 +246,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma */ private function getNormalizer(mixed $data, ?string $format, array $context): ?NormalizerInterface { - $type = \is_object($data) ? \get_class($data) : 'native-'.\gettype($data); + $type = \is_object($data) ? $data::class : 'native-'.\gettype($data); if (!isset($this->normalizerCache[$format][$type])) { $this->normalizerCache[$format][$type] = []; diff --git a/src/Symfony/Component/Serializer/Tests/Debug/TraceableEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Debug/TraceableEncoderTest.php index aa2393bbe7f69..9c1fddc7dffd7 100644 --- a/src/Symfony/Component/Serializer/Tests/Debug/TraceableEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Debug/TraceableEncoderTest.php @@ -50,11 +50,11 @@ public function testCollectEncodingData() $dataCollector ->expects($this->once()) ->method('collectEncoding') - ->with($this->isType('string'), \get_class($encoder), $this->isType('float')); + ->with($this->isType('string'), $encoder::class, $this->isType('float')); $dataCollector ->expects($this->once()) ->method('collectDecoding') - ->with($this->isType('string'), \get_class($decoder), $this->isType('float')); + ->with($this->isType('string'), $decoder::class, $this->isType('float')); (new TraceableEncoder($encoder, $dataCollector))->encode('data', 'format', [TraceableSerializer::DEBUG_TRACE_ID => 'debug']); (new TraceableEncoder($decoder, $dataCollector))->decode('data', 'format', [TraceableSerializer::DEBUG_TRACE_ID => 'debug']); diff --git a/src/Symfony/Component/Serializer/Tests/Debug/TraceableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Debug/TraceableNormalizerTest.php index dc99a03c03b22..481639fb95054 100644 --- a/src/Symfony/Component/Serializer/Tests/Debug/TraceableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Debug/TraceableNormalizerTest.php @@ -50,11 +50,11 @@ public function testCollectNormalizationData() $dataCollector ->expects($this->once()) ->method('collectNormalization') - ->with($this->isType('string'), \get_class($normalizer), $this->isType('float')); + ->with($this->isType('string'), $normalizer::class, $this->isType('float')); $dataCollector ->expects($this->once()) ->method('collectDenormalization') - ->with($this->isType('string'), \get_class($denormalizer), $this->isType('float')); + ->with($this->isType('string'), $denormalizer::class, $this->isType('float')); (new TraceableNormalizer($normalizer, $dataCollector))->normalize('data', 'format', [TraceableSerializer::DEBUG_TRACE_ID => 'debug']); (new TraceableNormalizer($denormalizer, $dataCollector))->denormalize('data', 'type', 'format', [TraceableSerializer::DEBUG_TRACE_ID => 'debug']); diff --git a/src/Symfony/Component/Serializer/Tests/Extractor/ObjectPropertyListExtractorTest.php b/src/Symfony/Component/Serializer/Tests/Extractor/ObjectPropertyListExtractorTest.php index 65e776684f2b1..d639bf7336d36 100644 --- a/src/Symfony/Component/Serializer/Tests/Extractor/ObjectPropertyListExtractorTest.php +++ b/src/Symfony/Component/Serializer/Tests/Extractor/ObjectPropertyListExtractorTest.php @@ -26,7 +26,7 @@ public function testGetPropertiesWithoutObjectClassResolver() $propertyListExtractor = $this->createMock(PropertyListExtractorInterface::class); $propertyListExtractor->expects($this->once()) ->method('getProperties') - ->with(\get_class($object), $context) + ->with($object::class, $context) ->willReturn($properties); $this->assertSame( diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php index 74fc1006991d1..9525ca6059fb3 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php @@ -70,7 +70,7 @@ public function testAnonymousClass() $anonymousObject = new class() { }; - $metadata = new ClassMetadata(\get_class($anonymousObject)); + $metadata = new ClassMetadata($anonymousObject::class); $decorated = $this->createMock(ClassMetadataFactoryInterface::class); $decorated ->expects($this->once()) diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php index db7b226c3e14b..a8ef81bb660a9 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CallbacksTestTrait.php @@ -107,8 +107,8 @@ public function __construct() } }; - $obj = $normalizer->denormalize(['foo' => $valueBar], \get_class($objWithNoConstructorArgument), 'any', ['callbacks' => $callbacks]); - $this->assertInstanceof(\get_class($objWithNoConstructorArgument), $obj); + $obj = $normalizer->denormalize(['foo' => $valueBar], $objWithNoConstructorArgument::class, 'any', ['callbacks' => $callbacks]); + $this->assertInstanceof($objWithNoConstructorArgument::class, $obj); $this->assertEquals($result->getBar(), $obj->getBar()); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php index 1996e80e98a38..1407c824280ce 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/CircularReferenceTestTrait.php @@ -42,7 +42,7 @@ public function testUnableToNormalizeCircularReference(array $defaultContext, ar $obj = $this->getSelfReferencingModel(); $this->expectException(CircularReferenceException::class); - $this->expectExceptionMessage(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d).', \get_class($obj), $expectedLimit)); + $this->expectExceptionMessage(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d).', $obj::class, $expectedLimit)); $normalizer->normalize($obj, null, $context); } @@ -51,15 +51,15 @@ public function testCircularReferenceHandler() $normalizer = $this->getNormalizerForCircularReference([]); $obj = $this->getSelfReferencingModel(); - $expected = ['me' => \get_class($obj)]; + $expected = ['me' => $obj::class]; $context = [ 'circular_reference_handler' => function ($actualObj, string $format, array $context) use ($obj) { - $this->assertInstanceOf(\get_class($obj), $actualObj); + $this->assertInstanceOf($obj::class, $actualObj); $this->assertSame('test', $format); $this->assertArrayHasKey('foo', $context); - return \get_class($actualObj); + return $actualObj::class; }, 'foo' => 'bar', ]; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index 2b9a111ed1e27..f1401158fb140 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -453,7 +453,7 @@ public function testMultiDimensionObject() RootDummy::class, 'any' ); - $this->assertEquals(\get_class($root), RootDummy::class); + $this->assertEquals($root::class, RootDummy::class); // children (two dimension array) $this->assertCount(1, $root->children); diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index 84fa7bf0b5a27..3b91c4f712c67 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -86,7 +86,7 @@ public function __toString(): string try { return $this->value = ($this->value)(); } catch (\Throwable $e) { - if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) { + if (\TypeError::class === $e::class && __FILE__ === $e->getFile()) { $type = explode(', ', $e->getMessage()); $type = substr(array_pop($type), 0, -\strlen(' returned')); $r = new \ReflectionFunction($this->value); diff --git a/src/Symfony/Component/String/Resources/bin/update-data.php b/src/Symfony/Component/String/Resources/bin/update-data.php index 3f66be2b7656d..edbe8a4c5a383 100644 --- a/src/Symfony/Component/String/Resources/bin/update-data.php +++ b/src/Symfony/Component/String/Resources/bin/update-data.php @@ -28,7 +28,7 @@ echo "Caused by\n"; } - echo get_class($cause).': '.$cause->getMessage()."\n"; + echo $cause::class.': '.$cause->getMessage()."\n"; echo "\n"; echo $cause->getFile().':'.$cause->getLine()."\n"; echo $cause->getTraceAsString()."\n"; diff --git a/src/Symfony/Component/Validator/Command/DebugCommand.php b/src/Symfony/Component/Validator/Command/DebugCommand.php index 06b8d0b8047dd..ed41eb8c7c9be 100644 --- a/src/Symfony/Component/Validator/Command/DebugCommand.php +++ b/src/Symfony/Component/Validator/Command/DebugCommand.php @@ -135,7 +135,7 @@ private function getClassConstraintsData(ClassMetadataInterface $classMetadata): { foreach ($classMetadata->getConstraints() as $constraint) { yield [ - 'class' => \get_class($constraint), + 'class' => $constraint::class, 'groups' => $constraint->groups, 'options' => $this->getConstraintOptions($constraint), ]; @@ -161,7 +161,7 @@ private function getPropertyData(ClassMetadataInterface $classMetadata, string $ foreach ($propertyMetadata as $metadata) { foreach ($metadata->getConstraints() as $constraint) { $data[] = [ - 'class' => \get_class($constraint), + 'class' => $constraint::class, 'groups' => $constraint->groups, 'options' => $this->getConstraintOptions($constraint), ]; diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index 53d69968af28e..a545779f0f31b 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -66,7 +66,7 @@ public function __construct(mixed $options = null, array $groups = null, mixed $ foreach ($nestedConstraints as $constraint) { if (!$constraint instanceof Constraint) { if (\is_object($constraint)) { - $constraint = \get_class($constraint); + $constraint = $constraint::class; } throw new ConstraintDefinitionException(sprintf('The value "%s" is not an instance of Constraint in constraint "%s".', $constraint, static::class)); diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 732befd000363..6c191298c0c87 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -74,7 +74,7 @@ public function getMetadataFor(mixed $value): MetadataInterface throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: "%s".', get_debug_type($value))); } - $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\'); + $class = ltrim(\is_object($value) ? $value::class : $value, '\\'); if (isset($this->loadedClasses[$class])) { return $this->loadedClasses[$class]; @@ -139,7 +139,7 @@ public function hasMetadataFor(mixed $value): bool return false; } - $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\'); + $class = ltrim(\is_object($value) ? $value::class : $value, '\\'); return class_exists($class) || interface_exists($class, false); } diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index cf2a0f8f8d212..a32cd19966f03 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -132,7 +132,7 @@ public function isPrivate(object|string $objectOrClassName): bool */ public function getReflectionMember(object|string $objectOrClassName): \ReflectionMethod|\ReflectionProperty { - $className = \is_string($objectOrClassName) ? $objectOrClassName : \get_class($objectOrClassName); + $className = \is_string($objectOrClassName) ? $objectOrClassName : $objectOrClassName::class; if (!isset($this->reflMember[$className])) { $this->reflMember[$className] = $this->newReflectionMember($objectOrClassName); } diff --git a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php index 292b6fe586ef7..49620bfdfe309 100644 --- a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php @@ -69,7 +69,7 @@ public function getPropertyValue(mixed $object): mixed protected function newReflectionMember(object|string $objectOrClassName): \ReflectionMethod|\ReflectionProperty { - $originalClass = \is_string($objectOrClassName) ? $objectOrClassName : \get_class($objectOrClassName); + $originalClass = \is_string($objectOrClassName) ? $objectOrClassName : $objectOrClassName::class; while (!property_exists($objectOrClassName, $this->getName())) { $objectOrClassName = get_parent_class($objectOrClassName); diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index 808d2550b568a..998cb4aea9816 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -186,7 +186,7 @@ protected function setObject(mixed $object) { $this->object = $object; $this->metadata = \is_object($object) - ? new ClassMetadata(\get_class($object)) + ? new ClassMetadata($object::class) : null; $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); @@ -196,7 +196,7 @@ protected function setProperty(mixed $object, string $property) { $this->object = $object; $this->metadata = \is_object($object) - ? new PropertyMetadata(\get_class($object), $property) + ? new PropertyMetadata($object::class, $property) : null; $this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 4544e46687e48..4b29c6a6074ac 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -157,7 +157,7 @@ public function testInvalidValuePath() $constraint = $this->createConstraint(['propertyPath' => 'foo']); $this->expectException(ConstraintDefinitionException::class); - $this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint))); + $this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', $constraint::class)); $object = new ComparisonTest_Class(5); @@ -239,7 +239,7 @@ public function throwsOnInvalidStringDatesProvider(): array 'value' => 'foo', ]); - $constraintClass = \get_class($constraint); + $constraintClass = $constraint::class; return [ [$constraint, sprintf('The compared value "foo" could not be converted to a "DateTimeImmutable" instance in the "%s" constraint.', $constraintClass), new \DateTimeImmutable()], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php index 4219295c147d2..b29e0096bb27f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -163,7 +163,7 @@ public function testInvalidValuePath() $constraint = new Bic(['ibanPropertyPath' => 'foo']); $this->expectException(ConstraintDefinitionException::class); - $this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint))); + $this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', $constraint::class)); $object = new BicComparisonTestClass(5); diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index cd0d2fdc5aa33..0c14d7104a430 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -1258,7 +1258,7 @@ public function testReplaceDefaultGroup($sequence, array $assertViolations) $context->addViolation('Violation in Group 3'); }; - $metadata = new ClassMetadata(\get_class($entity)); + $metadata = new ClassMetadata($entity::class); $metadata->addConstraint(new Callback([ 'callback' => function () {}, 'groups' => 'Group 1', diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index 4fc8ca2f00286..5ab26d48d7eef 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -183,7 +183,7 @@ public function validateProperty(object $object, string $propertyName, string|Gr $this->validateGenericNode( $propertyValue, $object, - $cacheKey.':'.\get_class($object).':'.$propertyName, + $cacheKey.':'.$object::class.':'.$propertyName, $propertyMetadata, $propertyPath, $groups, @@ -212,7 +212,7 @@ public function validatePropertyValue(object|string $objectOrClass, string $prop if (\is_object($objectOrClass)) { $object = $objectOrClass; - $class = \get_class($object); + $class = $object::class; $cacheKey = $this->generateCacheKey($objectOrClass); $propertyPath = PropertyPath::append($this->defaultPropertyPath, $propertyName); } else { @@ -501,7 +501,7 @@ private function validateClassNode(object $object, ?string $cacheKey, ClassMetad $this->validateGenericNode( $propertyValue, $object, - $cacheKey.':'.\get_class($object).':'.$propertyName, + $cacheKey.':'.$object::class.':'.$propertyName, $propertyMetadata, PropertyPath::append($propertyPath, $propertyName), $groups, diff --git a/src/Symfony/Component/VarDumper/Caster/CutStub.php b/src/Symfony/Component/VarDumper/Caster/CutStub.php index b5a96a02cfcdc..772399ef69f03 100644 --- a/src/Symfony/Component/VarDumper/Caster/CutStub.php +++ b/src/Symfony/Component/VarDumper/Caster/CutStub.php @@ -27,7 +27,7 @@ public function __construct(mixed $value) switch (\gettype($value)) { case 'object': $this->type = self::TYPE_OBJECT; - $this->class = \get_class($value); + $this->class = $value::class; if ($value instanceof \Closure) { ReflectionCaster::castClosure($value, [], $this, true, Caster::EXCLUDE_VERBOSE); diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index de040231dba09..448afbad90a47 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -218,7 +218,7 @@ private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, S if (!($flags & \ArrayObject::STD_PROP_LIST)) { $c->setFlags(\ArrayObject::STD_PROP_LIST); - $a = Caster::castObject($c, \get_class($c), method_exists($c, '__debugInfo'), $stub->class); + $a = Caster::castObject($c, $c::class, method_exists($c, '__debugInfo'), $stub->class); $c->setFlags($flags); } $a += [ diff --git a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php index 08428b9274100..c8f856d16fc1a 100644 --- a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php @@ -49,7 +49,7 @@ public static function castRequest(Request $request, array $a, Stub $stub, bool public static function castHttpClient($client, array $a, Stub $stub, bool $isNested) { - $multiKey = sprintf("\0%s\0multi", \get_class($client)); + $multiKey = sprintf("\0%s\0multi", $client::class); if (isset($a[$multiKey])) { $a[$multiKey] = new CutStub($a[$multiKey]); } diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index ec5f989062559..4068c7c386305 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -126,7 +126,7 @@ protected function doClone(mixed $var): array if (empty($objRefs[$h = spl_object_id($v)])) { $stub = new Stub(); $stub->type = Stub::TYPE_OBJECT; - $stub->class = \get_class($v); + $stub->class = $v::class; $stub->value = $v; $stub->handle = $h; $a = $this->castObject($stub, 0 < $i); diff --git a/src/Symfony/Component/VarDumper/Dumper/ContextualizedDumper.php b/src/Symfony/Component/VarDumper/Dumper/ContextualizedDumper.php index cd2b28f0c40d7..1ba803d813894 100644 --- a/src/Symfony/Component/VarDumper/Dumper/ContextualizedDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/ContextualizedDumper.php @@ -35,7 +35,7 @@ public function dump(Data $data) { $context = []; foreach ($this->contextProviders as $contextProvider) { - $context[\get_class($contextProvider)] = $contextProvider->getContext(); + $context[$contextProvider::class] = $contextProvider->getContext(); } $this->wrappedDumper->dump($data->withContext($context)); diff --git a/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php b/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php index 122f0d358a129..fd8eca9f138ab 100644 --- a/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php +++ b/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php @@ -21,6 +21,6 @@ class ThrowingCasterException extends \Exception */ public function __construct(\Throwable $prev) { - parent::__construct('Unexpected '.\get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev); + parent::__construct('Unexpected '.$prev::class.' thrown from a caster: '.$prev->getMessage(), 0, $prev); } } diff --git a/src/Symfony/Component/VarExporter/Hydrator.php b/src/Symfony/Component/VarExporter/Hydrator.php index b568e43502844..5f456fb3cf7e7 100644 --- a/src/Symfony/Component/VarExporter/Hydrator.php +++ b/src/Symfony/Component/VarExporter/Hydrator.php @@ -57,7 +57,7 @@ final class Hydrator public static function hydrate(object $instance, array $properties = [], array $scopedProperties = []): object { if ($properties) { - $class = \get_class($instance); + $class = $instance::class; $propertyScopes = InternalHydrator::$propertyScopes[$class] ??= InternalHydrator::getPropertyScopes($class); foreach ($properties as $name => &$value) { diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index b22d6ae609468..57c229eb14d2b 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -73,7 +73,7 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount goto handle_value; } - $class = \get_class($value); + $class = $value::class; $reflector = Registry::$reflectors[$class] ??= Registry::getClassReflector($class); if ($reflector->hasMethod('__serialize')) { @@ -364,7 +364,7 @@ private static function exportHydrator(Hydrator $value, string $indent, string $ self::export($value->wakeups, $subIndent), ]; - return '\\'.\get_class($value)."::hydrate(\n".$subIndent.implode(",\n".$subIndent, $code)."\n".$indent.')'; + return '\\'.$value::class."::hydrate(\n".$subIndent.implode(",\n".$subIndent, $code)."\n".$indent.')'; } /** diff --git a/src/Symfony/Component/VarExporter/Internal/GhostObjectState.php b/src/Symfony/Component/VarExporter/Internal/GhostObjectState.php index 471c1a6b91381..509cac3d50275 100644 --- a/src/Symfony/Component/VarExporter/Internal/GhostObjectState.php +++ b/src/Symfony/Component/VarExporter/Internal/GhostObjectState.php @@ -65,7 +65,7 @@ public function initialize($instance, $propertyName, $propertyScope) } if (self::STATUS_UNINITIALIZED_FULL === $this->status) { - if ($defaultProperties = array_diff_key(GhostObjectRegistry::$defaultProperties[\get_class($instance)], (array) $instance)) { + if ($defaultProperties = array_diff_key(GhostObjectRegistry::$defaultProperties[$instance::class], (array) $instance)) { Hydrator::hydrate($instance, $defaultProperties); } @@ -77,7 +77,7 @@ public function initialize($instance, $propertyName, $propertyScope) $value = ($this->initializer)(...[$instance, $propertyName, $propertyScope]); - $propertyScope ??= \get_class($instance); + $propertyScope ??= $instance::class; $accessor = GhostObjectRegistry::$classAccessors[$propertyScope] ??= GhostObjectRegistry::getClassAccessors($propertyScope); $accessor['set']($instance, $propertyName, $value); diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 7c2e19cd78b62..952a3a61c18da 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -112,7 +112,7 @@ public static function dump(mixed $value, int $flags = 0): string case $value instanceof \DateTimeInterface: return $value->format('c'); case $value instanceof \UnitEnum: - return sprintf('!php/const %s::%s', \get_class($value), $value->name); + return sprintf('!php/const %s::%s', $value::class, $value->name); case \is_object($value): if ($value instanceof TaggedValue) { return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); diff --git a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php index 84df70654f2ce..9489300760bfc 100644 --- a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php +++ b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php @@ -1125,7 +1125,7 @@ public function testWithOptions() $client2 = $client->withOptions(['base_uri' => 'http://localhost:8057/']); $this->assertNotSame($client, $client2); - $this->assertSame(\get_class($client), \get_class($client2)); + $this->assertSame($client::class, $client2::class); $response = $client2->request('GET', '/'); $this->assertSame(200, $response->getStatusCode());