From daf1c6605eb3571e2176c46281acba36b37cf536 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Mar 2020 20:07:47 +0100 Subject: [PATCH] Leverage PHP8's get_debug_type() --- .../Doctrine/Form/ChoiceList/IdReader.php | 2 +- .../Bridge/Doctrine/Form/Type/EntityType.php | 4 +- .../Security/User/EntityUserProvider.php | 6 +-- .../PropertyInfo/Fixtures/DoctrineFooType.php | 2 +- .../Constraints/UniqueEntityValidator.php | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 1 + .../Twig/ErrorRenderer/TwigErrorRenderer.php | 2 +- src/Symfony/Bridge/Twig/Mime/BodyRenderer.php | 2 +- src/Symfony/Bridge/Twig/composer.json | 1 + .../CacheWarmer/RouterCacheWarmer.php | 2 +- .../Command/AbstractConfigCommand.php | 2 +- .../Command/ContainerLintCommand.php | 4 +- .../Console/Descriptor/Descriptor.php | 2 +- .../Resources/config/session.xml | 4 +- .../Bundle/FrameworkBundle/Routing/Router.php | 2 +- .../FrameworkBundle/Secrets/SodiumVault.php | 2 +- .../TestBundle/Resources/config/routing.yml | 2 +- .../Tests/Routing/RouterTest.php | 4 +- .../Bundle/FrameworkBundle/composer.json | 1 + .../Security/Core/User/ArrayUserProvider.php | 2 +- .../Bundle/SecurityBundle/composer.json | 1 + .../Cache/Adapter/AbstractAdapter.php | 4 +- .../Cache/Adapter/AbstractTagAwareAdapter.php | 4 +- .../Component/Cache/Adapter/ArrayAdapter.php | 2 +- .../Component/Cache/Adapter/ChainAdapter.php | 2 +- .../Cache/Adapter/CouchbaseBucketAdapter.php | 2 +- .../Cache/Adapter/MemcachedAdapter.php | 4 +- .../Component/Cache/Adapter/PdoAdapter.php | 2 +- .../Cache/Adapter/PhpArrayAdapter.php | 14 +++---- .../Cache/Adapter/PhpFilesAdapter.php | 4 +- .../Cache/Adapter/RedisTagAwareAdapter.php | 2 +- .../Cache/Adapter/TraceableAdapter.php | 4 +- src/Symfony/Component/Cache/CacheItem.php | 8 ++-- src/Symfony/Component/Cache/Psr16Cache.php | 6 +-- .../Component/Cache/Traits/RedisTrait.php | 2 +- src/Symfony/Component/Cache/composer.json | 1 + .../Component/Config/Definition/ArrayNode.php | 4 +- .../Config/Definition/BooleanNode.php | 2 +- .../Component/Config/Definition/FloatNode.php | 2 +- .../Config/Definition/IntegerNode.php | 2 +- .../Config/Definition/PrototypedArrayNode.php | 2 +- .../Config/Definition/ScalarNode.php | 2 +- .../Tests/Definition/ScalarNodeTest.php | 4 +- src/Symfony/Component/Config/composer.json | 3 +- src/Symfony/Component/Console/Application.php | 11 +++-- .../Component/Console/Command/Command.php | 2 +- .../Console/Descriptor/Descriptor.php | 2 +- .../Console/Helper/ProcessHelper.php | 2 +- .../Component/Console/Helper/Table.php | 4 +- .../Console/Tests/ApplicationTest.php | 8 ++-- src/Symfony/Component/Console/composer.json | 1 + .../Argument/ReferenceSetArgumentTrait.php | 2 +- .../Compiler/AbstractRecursivePass.php | 2 +- .../Compiler/CheckTypeDeclarationsPass.php | 2 +- .../MergeExtensionConfigurationPass.php | 4 +- .../Compiler/PriorityTaggedServiceTrait.php | 4 +- .../RegisterServiceSubscribersPass.php | 2 +- .../Compiler/ResolveBindingsPass.php | 2 +- .../Compiler/ResolveNamedArgumentsPass.php | 2 +- .../Compiler/ServiceLocatorTagPass.php | 4 +- .../Compiler/ValidateEnvPlaceholdersPass.php | 16 +------- .../DependencyInjection/ContainerBuilder.php | 4 +- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../DependencyInjection/Dumper/YamlDumper.php | 2 +- .../DependencyInjection/EnvVarProcessor.php | 6 +-- .../Configurator/AbstractConfigurator.php | 2 +- .../DependencyInjection/Loader/FileLoader.php | 4 +- .../Loader/XmlFileLoader.php | 2 +- .../Loader/YamlFileLoader.php | 8 ++-- .../EnvPlaceholderParameterBag.php | 4 +- .../ParameterBag/ParameterBag.php | 2 +- .../CheckTypeDeclarationsPassTest.php | 10 ++--- .../Tests/Compiler/IntegrationTest.php | 10 ++--- .../ValidateEnvPlaceholdersPassTest.php | 2 +- .../Tests/Loader/YamlFileLoaderTest.php | 4 +- .../EnvPlaceholderParameterBagTest.php | 4 +- .../DependencyInjection/composer.json | 5 ++- src/Symfony/Component/DomCrawler/Crawler.php | 12 +++--- .../Component/DomCrawler/composer.json | 3 +- .../ErrorHandler/DebugClassLoader.php | 2 +- .../Component/ErrorHandler/ErrorHandler.php | 8 ++-- .../ErrorRenderer/HtmlErrorRenderer.php | 4 +- .../ErrorRenderer/SerializerErrorRenderer.php | 4 +- .../Exception/FlattenException.php | 8 ++-- .../Component/ErrorHandler/composer.json | 1 + .../EventDispatcher/Debug/WrappedListener.php | 4 +- .../Component/EventDispatcher/composer.json | 3 +- .../ExpressionLanguage/Node/GetAttrNode.php | 2 +- .../ExpressionLanguage/composer.json | 1 + .../Factory/Cache/AbstractStaticOption.php | 2 +- .../Form/Console/Descriptor/Descriptor.php | 2 +- .../Exception/UnexpectedTypeException.php | 2 +- .../WeekToArrayTransformer.php | 8 ++-- .../TransformationFailureListener.php | 2 +- .../Form/Extension/Core/Type/FormType.php | 2 +- .../Validator/Constraints/FormValidator.php | 2 +- src/Symfony/Component/Form/Form.php | 6 +-- .../Component/Form/FormErrorIterator.php | 2 +- .../Component/Form/ResolvedFormType.php | 2 +- .../WeekToArrayTransformerTest.php | 6 +-- src/Symfony/Component/Form/composer.json | 1 + .../Component/HttpClient/AmpHttpClient.php | 2 +- .../HttpClient/CachingHttpClient.php | 2 +- .../Component/HttpClient/CurlHttpClient.php | 6 +-- .../Component/HttpClient/HttpClientTrait.php | 18 ++++----- .../Component/HttpClient/HttplugClient.php | 2 +- .../Component/HttpClient/Internal/AmpBody.php | 2 +- .../Component/HttpClient/MockHttpClient.php | 2 +- .../Component/HttpClient/NativeHttpClient.php | 4 +- .../HttpClient/NoPrivateNetworkHttpClient.php | 4 +- .../HttpClient/Response/MockResponse.php | 2 +- .../HttpClient/Response/ResponseTrait.php | 2 +- .../HttpClient/Tests/HttpClientTraitTest.php | 4 +- .../Tests/NoPrivateNetworkHttpClientTest.php | 2 +- .../Tests/Response/MockResponseTest.php | 2 +- .../HttpClient/TraceableHttpClient.php | 4 +- .../Component/HttpClient/composer.json | 1 + .../Exception/UnexpectedTypeException.php | 2 +- .../Storage/Handler/RedisSessionHandler.php | 2 +- .../Storage/Handler/SessionHandlerFactory.php | 4 +- .../Storage/Handler/StrictSessionHandler.php | 2 +- .../Component/HttpFoundation/composer.json | 3 +- .../Component/HttpKernel/Bundle/Bundle.php | 2 +- .../Controller/ArgumentResolver.php | 2 +- .../VariadicValueResolver.php | 2 +- .../Controller/ControllerResolver.php | 6 +-- .../DataCollector/RequestDataCollector.php | 4 +- src/Symfony/Component/HttpKernel/Kernel.php | 5 +-- .../Component/HttpKernel/composer.json | 1 + .../Exception/UnexpectedTypeException.php | 2 +- src/Symfony/Component/Intl/composer.json | 3 +- .../Ldap/Adapter/ExtLdap/UpdateOperation.php | 2 +- .../Ldap/Security/LdapUserProvider.php | 4 +- src/Symfony/Component/Ldap/composer.json | 1 + src/Symfony/Component/Lock/Lock.php | 2 +- .../Component/Lock/Store/CombinedStore.php | 2 +- .../Component/Lock/Store/MongoDbStore.php | 2 +- src/Symfony/Component/Lock/Store/PdoStore.php | 2 +- .../Component/Lock/Store/RedisStore.php | 4 +- .../Component/Lock/Store/StoreFactory.php | 4 +- src/Symfony/Component/Lock/composer.json | 3 +- src/Symfony/Component/Mailer/Envelope.php | 2 +- src/Symfony/Component/Mailer/composer.json | 1 + .../Bridge/Amqp/Transport/Connection.php | 2 +- .../Transport/DoctrineTransportFactory.php | 2 +- .../DependencyInjection/MessengerPass.php | 2 +- src/Symfony/Component/Messenger/Envelope.php | 2 +- .../Component/Messenger/HandleTrait.php | 6 +-- .../Component/Messenger/MessageBus.php | 2 +- .../Messenger/Middleware/StackMiddleware.php | 2 +- .../Middleware/TraceableMiddleware.php | 3 +- .../Messenger/Tests/HandleTraitTest.php | 2 +- src/Symfony/Component/Messenger/composer.json | 1 + src/Symfony/Component/Mime/Address.php | 2 +- src/Symfony/Component/Mime/Header/Headers.php | 2 +- .../Component/Mime/MessageConverter.php | 12 +++--- .../Mime/Part/Multipart/FormDataPart.php | 2 +- src/Symfony/Component/Mime/Part/SMimePart.php | 2 +- src/Symfony/Component/Mime/Part/TextPart.php | 2 +- src/Symfony/Component/Mime/composer.json | 3 +- .../Bridge/Firebase/FirebaseTransport.php | 2 +- .../Bridge/Mattermost/MattermostTransport.php | 2 +- .../Notifier/Bridge/Nexmo/NexmoTransport.php | 2 +- .../Bridge/OvhCloud/OvhCloudTransport.php | 2 +- .../Bridge/RocketChat/RocketChatTransport.php | 2 +- .../Notifier/Bridge/Sinch/SinchTransport.php | 2 +- .../Notifier/Bridge/Slack/SlackTransport.php | 2 +- .../Bridge/Telegram/TelegramTransport.php | 2 +- .../Notifier/Bridge/Telegram/composer.json | 2 +- .../Bridge/Twilio/TwilioTransport.php | 2 +- .../Notifier/Channel/EmailChannel.php | 2 +- .../Component/Notifier/Message/SmsMessage.php | 2 +- src/Symfony/Component/Notifier/composer.json | 3 +- .../OptionsResolver/OptionsResolver.php | 20 ++-------- .../Tests/OptionsResolverTest.php | 40 +++++++++---------- .../Component/OptionsResolver/composer.json | 3 +- .../Component/Process/Pipes/AbstractPipes.php | 2 +- src/Symfony/Component/Process/composer.json | 3 +- .../PropertyAccess/PropertyAccessor.php | 6 +-- .../Component/PropertyAccess/PropertyPath.php | 2 +- .../Component/PropertyAccess/composer.json | 1 + .../Tests/Fixtures/NullExtractor.php | 2 +- .../Component/PropertyInfo/composer.json | 3 +- .../Component/Routing/Loader/ObjectLoader.php | 8 ++-- src/Symfony/Component/Routing/composer.json | 3 +- .../AuthenticationProviderManager.php | 2 +- .../RememberMeAuthenticationProvider.php | 2 +- .../Security/Core/Encoder/EncoderFactory.php | 2 +- .../Security/Core/User/ChainUserProvider.php | 2 +- .../Core/User/InMemoryUserProvider.php | 2 +- .../Component/Security/Core/composer.json | 1 + .../Security/Csrf/CsrfTokenManager.php | 2 +- .../Firewall/GuardAuthenticationListener.php | 4 +- .../Guard/GuardAuthenticatorHandler.php | 4 +- .../Provider/GuardAuthenticationProvider.php | 10 ++--- .../Component/Security/Guard/composer.json | 3 +- .../Http/Firewall/ContextListener.php | 2 +- .../Http/Firewall/ExceptionListener.php | 4 +- ...namePasswordFormAuthenticationListener.php | 2 +- .../TokenBasedRememberMeServices.php | 2 +- ...PasswordFormAuthenticationListenerTest.php | 4 +- .../Component/Security/Http/composer.json | 1 + .../Serializer/Encoder/CsvEncoder.php | 2 +- .../Mapping/Factory/ClassResolverTrait.php | 2 +- .../Serializer/Mapping/Loader/LoaderChain.php | 2 +- .../Normalizer/AbstractNormalizer.php | 2 +- .../Normalizer/AbstractObjectNormalizer.php | 2 +- .../Normalizer/ArrayDenormalizer.php | 4 +- .../Normalizer/DateIntervalNormalizer.php | 2 +- .../Component/Serializer/Serializer.php | 8 ++-- .../Component/Serializer/composer.json | 3 +- src/Symfony/Component/String/LazyString.php | 12 ++---- .../Translation/DataCollectorTranslator.php | 2 +- .../Translation/LoggingTranslator.php | 2 +- .../Component/Translation/composer.json | 1 + .../Validator/ConstraintValidator.php | 2 +- .../AbstractComparisonValidator.php | 4 +- .../Validator/Constraints/BicValidator.php | 2 +- .../Constraints/CallbackValidator.php | 2 +- .../Validator/Constraints/Composite.php | 2 +- .../Component/Validator/Constraints/Email.php | 2 +- .../Validator/Constraints/EmailValidator.php | 2 +- .../Component/Validator/Constraints/Ip.php | 2 +- .../Validator/Constraints/Length.php | 2 +- .../Validator/Constraints/NotBlank.php | 2 +- .../Validator/Constraints/RangeValidator.php | 6 +-- .../Component/Validator/Constraints/Regex.php | 2 +- .../Component/Validator/Constraints/Url.php | 2 +- .../Component/Validator/Constraints/Uuid.php | 2 +- .../ContainerConstraintValidatorFactory.php | 2 +- .../Exception/UnexpectedTypeException.php | 2 +- .../Validator/Mapping/ClassMetadata.php | 2 +- .../Factory/LazyLoadingMetadataFactory.php | 2 +- .../Validator/Mapping/GenericMetadata.php | 2 +- .../Validator/Mapping/Loader/LoaderChain.php | 2 +- .../Validator/Mapping/MemberMetadata.php | 2 +- .../AbstractComparisonValidatorTestCase.php | 2 +- .../Constraints/DivisibleByValidatorTest.php | 10 ++--- .../Constraints/EqualToValidatorTest.php | 2 +- .../GreaterThanOrEqualValidatorTest.php | 2 +- ...idatorWithPositiveOrZeroConstraintTest.php | 6 +-- .../Constraints/GreaterThanValidatorTest.php | 4 +- ...hanValidatorWithPositiveConstraintTest.php | 8 ++-- .../Constraints/IdenticalToValidatorTest.php | 2 +- .../LessThanOrEqualValidatorTest.php | 2 +- ...idatorWithNegativeOrZeroConstraintTest.php | 6 +-- .../Constraints/LessThanValidatorTest.php | 4 +- ...hanValidatorWithNegativeConstraintTest.php | 8 ++-- .../Constraints/NotEqualToValidatorTest.php | 4 +- .../NotIdenticalToValidatorTest.php | 2 +- .../Tests/Fixtures/FakeMetadataFactory.php | 2 +- .../RecursiveContextualValidator.php | 12 +++--- src/Symfony/Component/Validator/composer.json | 1 + .../Component/VarDumper/Caster/Caster.php | 7 ++-- .../Component/VarDumper/Caster/ClassStub.php | 6 +-- .../VarDumper/Caster/ExceptionCaster.php | 9 ++--- .../VarDumper/Cloner/AbstractCloner.php | 6 +-- .../Component/VarDumper/Cloner/Data.php | 2 +- src/Symfony/Component/VarDumper/composer.json | 3 +- .../VarExporter/Internal/Exporter.php | 2 +- .../Component/VarExporter/composer.json | 3 +- .../MarkingStore/MethodMarkingStore.php | 4 +- .../Workflow/Metadata/GetMetadataTrait.php | 2 +- src/Symfony/Component/Workflow/Registry.php | 4 +- .../Metadata/InMemoryMetadataStoreTest.php | 2 +- src/Symfony/Component/Workflow/composer.json | 3 +- 266 files changed, 466 insertions(+), 464 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php index 980c0ce89f..0625e5175c 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php @@ -93,7 +93,7 @@ class IdReader } if (!$this->om->contains($object)) { - throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object))); + throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_debug_type($object))); } $this->om->initializeObject($object); diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index 8f04409ef5..7cbe648f9b 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -53,7 +53,7 @@ class EntityType extends DoctrineType public function getLoader(ObjectManager $manager, $queryBuilder, string $class) { if (!$queryBuilder instanceof QueryBuilder) { - throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); + throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder))); } return new ORMQueryBuilderLoader($queryBuilder); @@ -79,7 +79,7 @@ class EntityType extends DoctrineType public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array { if (!$queryBuilder instanceof QueryBuilder) { - throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); + throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder))); } return [ diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 5dc99cc85a..565637c999 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -55,7 +55,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter $user = $repository->findOneBy([$this->property => $username]); } else { if (!$repository instanceof UserLoaderInterface) { - throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository))); + throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_debug_type($repository))); } $user = $repository->loadUserByUsername($username); @@ -75,7 +75,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter { $class = $this->getClass(); if (!$user instanceof $class) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } $repository = $this->getRepository(); @@ -114,7 +114,7 @@ class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInter { $class = $this->getClass(); if (!$user instanceof $class) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } $repository = $this->getRepository(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 6e4807c58f..e8f2b454cf 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -50,7 +50,7 @@ class DoctrineFooType extends Type return null; } if (!$value instanceof Foo) { - throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value))); + throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', get_debug_type($value))); } return $foo->bar; diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 35f723aa88..cbf40af2b5 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -71,7 +71,7 @@ class UniqueEntityValidator extends ConstraintValidator $em = $this->registry->getManagerForClass(\get_class($entity)); if (!$em) { - throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', \get_class($entity))); + throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_debug_type($entity))); } } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 26eeb9eb49..bb588a08b2 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -21,6 +21,7 @@ "doctrine/persistence": "^1.3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2" }, "require-dev": { diff --git a/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php b/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php index 5a79062d36..b0ccd684e8 100644 --- a/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php +++ b/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php @@ -35,7 +35,7 @@ class TwigErrorRenderer implements ErrorRendererInterface public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorRenderer = null, $debug = false) { if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 3 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 3 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, get_debug_type($debug))); } $this->twig = $twig; diff --git a/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php b/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php index e1031b3d56..14535f232a 100644 --- a/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php +++ b/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php @@ -47,7 +47,7 @@ final class BodyRenderer implements BodyRendererInterface $messageContext = $message->getContext(); if (isset($messageContext['email'])) { - throw new InvalidArgumentException(sprintf('A "%s" context cannot have an "email" entry as this is a reserved variable.', \get_class($message))); + throw new InvalidArgumentException(sprintf('A "%s" context cannot have an "email" entry as this is a reserved variable.', get_debug_type($message))); } $vars = array_merge($this->context, $messageContext, [ diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index a730cb3ca9..5980fad648 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": "^7.2.5", + "symfony/polyfill-php80": "^1.15", "symfony/translation-contracts": "^1.1|^2", "twig/twig": "^2.10|^3.0" }, diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php index 5b4b6e5097..6f90bba8b0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php @@ -47,7 +47,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf return; } - throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', \get_class($router), WarmableInterface::class)); + throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class)); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 22fdfe7b60..175e0fae30 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -116,7 +116,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand } if (!$configuration instanceof ConfigurationInterface) { - throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', \get_class($configuration))); + throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration))); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php index a407927bda..f059df1ee6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php @@ -89,7 +89,7 @@ final class ContainerLintCommand extends Command if (!$kernel->isDebug() || !(new ConfigCache($kernelContainer->getParameter('debug.container.dump'), true))->isFresh()) { if (!$kernel instanceof Kernel) { - throw new RuntimeException(sprintf('This command does not support the application kernel: "%s" does not extend "%s".', \get_class($kernel), Kernel::class)); + throw new RuntimeException(sprintf('This command does not support the application kernel: "%s" does not extend "%s".', get_debug_type($kernel), Kernel::class)); } $buildContainer = \Closure::bind(function (): ContainerBuilder { @@ -102,7 +102,7 @@ final class ContainerLintCommand extends Command $skippedIds = []; } else { if (!$kernelContainer instanceof Container) { - throw new RuntimeException(sprintf('This command does not support the application container: "%s" does not extend "%s".', \get_class($kernelContainer), Container::class)); + throw new RuntimeException(sprintf('This command does not support the application container: "%s" does not extend "%s".', get_debug_type($kernelContainer), Container::class)); } (new XmlFileLoader($container = new ContainerBuilder($parameterBag = new EnvPlaceholderParameterBag()), new FileLocator()))->load($kernelContainer->getParameter('debug.container.dump')); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index 17d13fdffd..72116ef402 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -83,7 +83,7 @@ abstract class Descriptor implements DescriptorInterface $this->describeCallable($object, $options); break; default: - throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object))); + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml index afa319aa66..e63967ea35 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml @@ -36,12 +36,12 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index e934e1bc21..69f8eb4ceb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -171,7 +171,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI return (string) $this->resolve($resolved); } - throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type "%s".', $match[1], $value, \gettype($resolved))); + throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type "%s".', $match[1], $value, get_debug_type($resolved))); }, $value); return str_replace('%%', '%', $escapedValue); diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index 0bbfa08080..69c42a3e50 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -34,7 +34,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface public function __construct(string $secretsDir, $decryptionKey = null) { if (null !== $decryptionKey && !\is_string($decryptionKey) && !(\is_object($decryptionKey) && method_exists($decryptionKey, '__toString'))) { - throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, "%s" given.', \gettype($decryptionKey))); + throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, "%s" given.', get_debug_type($decryptionKey))); } $this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml index d9c7986f42..155871fc27 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml @@ -20,7 +20,7 @@ session_setflash: injected_flashbag_session_setflash: path: injected_flashbag/session_setflash/{message} - defaults: { _controller: TestBundle:InjectedFlashbagSession:setFlash} + defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\InjectedFlashbagSessionController::setFlashAction} session_showflash: path: /session_showflash diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index f7971cb733..397b860ba8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -390,7 +390,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameter() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); + $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "stdClass".'); $routes = new RouteCollection(); $routes->add('foo', new Route('/%object%')); @@ -405,7 +405,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameterWithSfContainer() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); + $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "stdClass".'); $routes = new RouteCollection(); $routes->add('foo', new Route('/%object%')); diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index ea7b119c12..60b337aa77 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -25,6 +25,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/http-kernel": "^5.0", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/filesystem": "^4.4|^5.0", "symfony/finder": "^4.4|^5.0", "symfony/routing": "^5.1" 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 5b50def554..d4e80836f8 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 @@ -43,7 +43,7 @@ class ArrayUserProvider implements UserProviderInterface public function refreshUser(UserInterface $user) { if (!$user instanceof UserInterface) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } $storedUser = $this->getUser($user->getUsername()); diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 4888fc17ff..0843a4659a 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -21,6 +21,7 @@ "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/http-kernel": "^5.0", + "symfony/polyfill-php80": "^1.15", "symfony/security-core": "^4.4|^5.0", "symfony/security-csrf": "^4.4|^5.0", "symfony/security-guard": "^4.4|^5.0", diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 7a4cf7f8ee..e28a7c4cc5 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -164,7 +164,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg foreach (\is_array($e) ? $e : array_keys($values) as $id) { $ok = false; $v = $values[$id]; - $type = \is_object($v) ? \get_class($v) : \gettype($v); + $type = get_debug_type($v); $message = sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null]); } @@ -187,7 +187,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg continue; } $ok = false; - $type = \is_object($v) ? \get_class($v) : \gettype($v); + $type = get_debug_type($v); $message = sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null]); } diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 1a73d974c9..977d6e9fae 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -194,7 +194,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA foreach (\is_array($e) ? $e : array_keys($values) as $id) { $ok = false; $v = $values[$id]; - $type = \is_object($v) ? \get_class($v) : \gettype($v); + $type = get_debug_type($v); $message = sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null]); } @@ -218,7 +218,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA continue; } $ok = false; - $type = \is_object($v) ? \get_class($v) : \gettype($v); + $type = get_debug_type($v); $message = sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.'); CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null]); } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index ffec7d3d2c..d51c240021 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -351,7 +351,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter try { $serialized = serialize($value); } catch (\Exception $e) { - $type = \is_object($value) ? \get_class($value) : \gettype($value); + $type = get_debug_type($value); $message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage()); CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]); diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index a2fc8e7a34..e54f204c59 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -49,7 +49,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa foreach ($adapters as $adapter) { if (!$adapter instanceof CacheItemPoolInterface) { - throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($adapter), CacheItemPoolInterface::class)); + throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class)); } if ($adapter instanceof AdapterInterface) { diff --git a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php index 55390b5343..0fd2727001 100644 --- a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php @@ -62,7 +62,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter if (\is_string($servers)) { $servers = [$servers]; } elseif (!\is_array($servers)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be array or string, "%s" given.', __METHOD__, \gettype($servers))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be array or string, "%s" given.', __METHOD__, get_debug_type($servers))); } if (!static::isSupported()) { diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 1233fc7afc..369842a318 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -92,7 +92,7 @@ class MemcachedAdapter extends AbstractAdapter if (\is_string($servers)) { $servers = [$servers]; } elseif (!\is_array($servers)) { - throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, "%s" given.', \gettype($servers))); + throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, "%s" given.', get_debug_type($servers))); } if (!static::isSupported()) { throw new CacheException('Memcached >= 2.2.0 is required.'); @@ -313,7 +313,7 @@ class MemcachedAdapter extends AbstractAdapter return $result; } - throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage()))); + throw new CacheException(sprintf('MemcachedAdapter client error: "%s".', strtolower($this->client->getResultMessage()))); } private function getClient(): \Memcached diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index 73e4695ba8..1bc2f1515b 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -82,7 +82,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface } elseif (\is_string($connOrDsn)) { $this->dsn = $connOrDsn; } else { - throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, \is_object($connOrDsn) ? \get_class($connOrDsn) : \gettype($connOrDsn))); + throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, get_debug_type($connOrDsn))); } $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 2c337b6259..cccc608042 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -119,7 +119,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte public function getItem($key) { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } if (null === $this->values) { $this->initialize(); @@ -154,7 +154,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte { foreach ($keys as $key) { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } } if (null === $this->values) { @@ -172,7 +172,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte public function hasItem($key) { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } if (null === $this->values) { $this->initialize(); @@ -189,7 +189,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte public function deleteItem($key) { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } if (null === $this->values) { $this->initialize(); @@ -210,7 +210,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte foreach ($keys as $key) { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } if (isset($this->keys[$key])) { @@ -336,7 +336,7 @@ EOF; try { $value = VarExporter::export($value, $isStaticValue); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)), 0, $e); } } elseif (\is_string($value)) { // Wrap "N;" in a closure to not confuse it with an encoded `null` @@ -345,7 +345,7 @@ EOF; } $value = var_export($value, true); } elseif (!is_scalar($value)) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value))); + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value))); } else { $value = var_export($value, true); } diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index 013df35ba6..ebdb840978 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -226,7 +226,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface try { $value = VarExporter::export($value, $isStaticValue); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)), 0, $e); } } elseif (\is_string($value)) { // Wrap "N;" in a closure to not confuse it with an encoded `null` @@ -235,7 +235,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface } $value = var_export($value, true); } elseif (!is_scalar($value)) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value))); + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value))); } else { $value = var_export($value, true); } diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index f382f223f2..598dced263 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -72,7 +72,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getConnection() instanceof ClusterInterface && !$redisClient->getConnection() instanceof PredisCluster) { - throw new InvalidArgumentException(sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, \get_class($redisClient->getConnection()))); + throw new InvalidArgumentException(sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, get_debug_type($redisClient->getConnection()))); } if (\defined('Redis::OPT_COMPRESSION') && ($redisClient instanceof \Redis || $redisClient instanceof \RedisArray || $redisClient instanceof \RedisCluster)) { diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 16d819ee46..48b12d36f9 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -41,7 +41,7 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt public function get(string $key, callable $callback, float $beta = null, array &$metadata = null) { if (!$this->pool instanceof CacheInterface) { - throw new \BadMethodCallException(sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', \get_class($this->pool), CacheInterface::class)); + throw new \BadMethodCallException(sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class)); } $isHit = true; @@ -54,7 +54,7 @@ class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInt $event = $this->start(__FUNCTION__); try { $value = $this->pool->get($key, $callback, $beta, $metadata); - $event->result[$key] = \is_object($value) ? \get_class($value) : \gettype($value); + $event->result[$key] = get_debug_type($value); } finally { $event->end = microtime(true); } diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index d147a95b07..fac5f9004e 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -82,7 +82,7 @@ final class CacheItem implements ItemInterface } elseif ($expiration instanceof \DateTimeInterface) { $this->expiry = (float) $expiration->format('U.u'); } else { - throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given.', \is_object($expiration) ? \get_class($expiration) : \gettype($expiration))); + throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given.', get_debug_type($expiration))); } return $this; @@ -102,7 +102,7 @@ final class CacheItem implements ItemInterface } elseif (\is_int($time)) { $this->expiry = $time + microtime(true); } else { - throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given.', \is_object($time) ? \get_class($time) : \gettype($time))); + throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given.', get_debug_type($time))); } return $this; @@ -121,7 +121,7 @@ final class CacheItem implements ItemInterface } foreach ($tags as $tag) { if (!\is_string($tag)) { - throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given.', \is_object($tag) ? \get_class($tag) : \gettype($tag))); + throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given.', get_debug_type($tag))); } if (isset($this->newMetadata[self::METADATA_TAGS][$tag])) { continue; @@ -156,7 +156,7 @@ final class CacheItem implements ItemInterface public static function validateKey($key): string { if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); + throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', get_debug_type($key))); } if ('' === $key) { throw new InvalidArgumentException('Cache key length must be greater than zero.'); diff --git a/src/Symfony/Component/Cache/Psr16Cache.php b/src/Symfony/Component/Cache/Psr16Cache.php index 7358bf5184..16cf8d815d 100644 --- a/src/Symfony/Component/Cache/Psr16Cache.php +++ b/src/Symfony/Component/Cache/Psr16Cache.php @@ -144,7 +144,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', \is_object($keys) ? \get_class($keys) : \gettype($keys))); + throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', get_debug_type($keys))); } try { @@ -193,7 +193,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf { $valuesIsArray = \is_array($values); if (!$valuesIsArray && !$values instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given.', \is_object($values) ? \get_class($values) : \gettype($values))); + throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given.', get_debug_type($values))); } $items = []; @@ -247,7 +247,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', \is_object($keys) ? \get_class($keys) : \gettype($keys))); + throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', get_debug_type($keys))); } try { diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index a7431f4d01..3601075075 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -56,7 +56,7 @@ trait RedisTrait } if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) { - throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($redisClient))); } if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) { diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index a049e04ebb..a3665359d9 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -25,6 +25,7 @@ "psr/cache": "~1.0", "psr/log": "~1.0", "symfony/cache-contracts": "^1.1.7|^2", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2", "symfony/var-exporter": "^4.4|^5.0" }, diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 36ec517cb6..d4fa55c0ab 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -207,7 +207,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface protected function finalizeValue($value) { if (false === $value) { - throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value))); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); } foreach ($this->children as $name => $child) { @@ -250,7 +250,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface protected function validateType($value) { if (!\is_array($value) && (!$this->allowFalse || false !== $value)) { - $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), \gettype($value))); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/BooleanNode.php b/src/Symfony/Component/Config/Definition/BooleanNode.php index c43c46f016..c64ecb8394 100644 --- a/src/Symfony/Component/Config/Definition/BooleanNode.php +++ b/src/Symfony/Component/Config/Definition/BooleanNode.php @@ -26,7 +26,7 @@ class BooleanNode extends ScalarNode protected function validateType($value) { if (!\is_bool($value)) { - $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), \gettype($value))); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "bool", but got "%s".', $this->getPath(), get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/FloatNode.php b/src/Symfony/Component/Config/Definition/FloatNode.php index 8e229ed4c5..527f996efa 100644 --- a/src/Symfony/Component/Config/Definition/FloatNode.php +++ b/src/Symfony/Component/Config/Definition/FloatNode.php @@ -31,7 +31,7 @@ class FloatNode extends NumericNode } if (!\is_float($value)) { - $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), \gettype($value))); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "float", but got "%s".', $this->getPath(), get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/IntegerNode.php b/src/Symfony/Component/Config/Definition/IntegerNode.php index e8c6a81c30..dfb4cc674d 100644 --- a/src/Symfony/Component/Config/Definition/IntegerNode.php +++ b/src/Symfony/Component/Config/Definition/IntegerNode.php @@ -26,7 +26,7 @@ class IntegerNode extends NumericNode protected function validateType($value) { if (!\is_int($value)) { - $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected int, but got %s.', $this->getPath(), \gettype($value))); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index cad428f72c..8e18d077d3 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -175,7 +175,7 @@ class PrototypedArrayNode extends ArrayNode protected function finalizeValue($value) { if (false === $value) { - throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value))); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); } foreach ($value as $k => $v) { diff --git a/src/Symfony/Component/Config/Definition/ScalarNode.php b/src/Symfony/Component/Config/Definition/ScalarNode.php index 5ad28ec4c5..5296c27960 100644 --- a/src/Symfony/Component/Config/Definition/ScalarNode.php +++ b/src/Symfony/Component/Config/Definition/ScalarNode.php @@ -33,7 +33,7 @@ class ScalarNode extends VariableNode protected function validateType($value) { if (!is_scalar($value) && null !== $value) { - $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), \gettype($value))); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index 4413baf3c7..b8bca9c942 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -96,7 +96,7 @@ class ScalarNodeTest extends TestCase $node = new ScalarNode('test'); $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); - $this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.'); + $this->expectExceptionMessage('Invalid type for path "test". Expected "scalar", but got "array".'); $node->normalize([]); } @@ -107,7 +107,7 @@ class ScalarNodeTest extends TestCase $node->setInfo('"the test value"'); $this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException'); - $this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); + $this->expectExceptionMessage("Invalid type for path \"test\". Expected \"scalar\", but got \"array\".\nHint: \"the test value\""); $node->normalize([]); } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index 78db0bb31d..332450ae6a 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -19,7 +19,8 @@ "php": "^7.2.5", "symfony/deprecation-contracts": "^2.1", "symfony/filesystem": "^4.4|^5.0", - "symfony/polyfill-ctype": "~1.8" + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/event-dispatcher": "^4.4|^5.0", diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index deae866c0e..f3914bb788 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -467,7 +467,7 @@ class Application implements ResetInterface $command->getDefinition(); if (!$command->getName()) { - throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command))); + throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command))); } $this->commands[$command->getName()] = $command; @@ -774,17 +774,16 @@ class Application implements ResetInterface do { $message = trim($e->getMessage()); if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $class = \get_class($e); - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $class = get_debug_type($e); $title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : ''); $len = Helper::strlen($title); } else { $len = 0; } - if (false !== strpos($message, "class@anonymous\0")) { - $message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0]))).'@anonymous' : $m[0]; + if (false !== strpos($message, "@anonymous\0")) { + $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { + return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); } diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 29a9415b81..7f600ec3af 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -258,7 +258,7 @@ class Command $statusCode = $this->execute($input, $output); if (!\is_int($statusCode)) { - throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, \gettype($statusCode))); + throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode))); } } diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index df85e38105..2834cd0aa6 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -55,7 +55,7 @@ abstract class Descriptor implements DescriptorInterface $this->describeApplication($object, $options); break; default: - throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object))); + throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))); } } diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php index 944c593957..0198968157 100644 --- a/src/Symfony/Component/Console/Helper/ProcessHelper.php +++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php @@ -47,7 +47,7 @@ class ProcessHelper extends Helper } if (!\is_array($cmd)) { - throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, \is_object($cmd) ? \get_class($cmd) : \gettype($cmd))); + throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd))); } if (\is_string($cmd[0] ?? null)) { diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 8fc1d74296..7f3d4a3b6d 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -218,7 +218,7 @@ class Table public function setColumnMaxWidth(int $columnIndex, int $width): self { if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) { - throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_class($this->output->getFormatter()))); + throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter()))); } $this->columnMaxWidths[$columnIndex] = $width; @@ -606,7 +606,7 @@ class Table $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { - throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \gettype($cell))); + throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index cd8904ea72..fea889a794 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -893,12 +893,12 @@ class ApplicationTest extends TestCase $application = new Application(); $application->setAutoExit(false); $application->register('foo')->setCode(function () { - throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { }))); + throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', get_debug_type(new class() { }))); }); $tester = new ApplicationTester($application); $tester->run(['command' => 'foo'], ['decorated' => false]); - $this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true)); + $this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true)); } public function testRenderExceptionStackTraceContainsRootException() @@ -916,12 +916,12 @@ class ApplicationTest extends TestCase $application = new Application(); $application->setAutoExit(false); $application->register('foo')->setCode(function () { - throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', \get_class(new class() { }))); + throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', get_debug_type(new class() { }))); }); $tester = new ApplicationTester($application); $tester->run(['command' => 'foo'], ['decorated' => false]); - $this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true)); + $this->assertStringContainsString('Dummy type "class@anonymous" is invalid.', $tester->getDisplay(true)); } public function testRun() diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index b92d62554d..61f85df4e9 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -19,6 +19,7 @@ "php": "^7.2.5", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2", "symfony/string": "^5.1" }, diff --git a/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php b/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php index e3946ab394..777e405669 100644 --- a/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php +++ b/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php @@ -45,7 +45,7 @@ trait ReferenceSetArgumentTrait { foreach ($values as $k => $v) { if (null !== $v && !$v instanceof Reference) { - throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \is_object($v) ? \get_class($v) : \gettype($v))); + throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, get_debug_type($v))); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php index a992d26ae1..1249bf19b3 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php @@ -209,7 +209,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface $arg = $this->processValue(new Reference($id)); $this->inExpression = false; if (!$arg instanceof Reference) { - throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, \is_object($arg) ? \get_class($arg) : \gettype($arg), $id)); + throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id)); } $arg = sprintf('"%s"', $arg); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index 2d69fe6eb6..d47b77f3f5 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -265,7 +265,7 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass $checkFunction = sprintf('is_%s', $parameter->getType()->getName()); if (!$parameter->getType()->isBuiltin() || !$checkFunction($value)) { - throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : \gettype($value), $parameter); + throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : get_debug_type($value), $parameter); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php index bfeb7b84b9..fd31c53a5c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php @@ -169,7 +169,7 @@ class MergeExtensionConfigurationContainerBuilder extends ContainerBuilder */ public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0): self { - throw new LogicException(sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', \get_class($pass), $this->extensionClass)); + throw new LogicException(sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', get_debug_type($pass), $this->extensionClass)); } /** @@ -177,7 +177,7 @@ class MergeExtensionConfigurationContainerBuilder extends ContainerBuilder */ public function registerExtension(ExtensionInterface $extension) { - throw new LogicException(sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', \get_class($extension), $this->extensionClass)); + throw new LogicException(sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', get_debug_type($extension), $this->extensionClass)); } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php index c24d5976b3..6a30ef7cc9 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php @@ -125,7 +125,7 @@ class PriorityTaggedServiceUtil $defaultIndex = $rm->invoke(null); if (!\is_string($defaultIndex)) { - throw new InvalidArgumentException(sprintf('Either method "%s::%s()" should return a string (got "%s") or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, \gettype($defaultIndex), $tagName, $serviceId, $indexAttribute)); + throw new InvalidArgumentException(sprintf('Either method "%s::%s()" should return a string (got "%s") or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, get_debug_type($defaultIndex), $tagName, $serviceId, $indexAttribute)); } return $defaultIndex; @@ -154,7 +154,7 @@ class PriorityTaggedServiceUtil $defaultPriority = $rm->invoke(null); if (!\is_int($defaultPriority)) { - throw new InvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got "%s") or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, \gettype($defaultPriority), $tagName, $serviceId)); + throw new InvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got "%s") or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, get_debug_type($defaultPriority), $tagName, $serviceId)); } return $defaultPriority; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php index 7d9c366da8..9e08d79408 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php @@ -71,7 +71,7 @@ class RegisterServiceSubscribersPass extends AbstractRecursivePass foreach ($class::getSubscribedServices() as $key => $type) { if (!\is_string($type) || !preg_match('/^\??[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $type)) { - throw new InvalidArgumentException(sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : \gettype($type))); + throw new InvalidArgumentException(sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : get_debug_type($type))); } if ($optionalBehavior = '?' === $type[0]) { $type = substr($type, 1); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php index 4e9ebb3933..b86c1b7864 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php @@ -134,7 +134,7 @@ class ResolveBindingsPass extends AbstractRecursivePass } if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) { - throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, "%s", "%s", "%s" or ServiceLocatorArgument, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue))); + throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, "%s", "%s", "%s" or ServiceLocatorArgument, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, get_debug_type($bindingValue))); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php index 2c4abec518..e0a019493a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php @@ -76,7 +76,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass } if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { - throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of "%s" or an instance of "%s", "%s" given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, \gettype($argument))); + throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of "%s" or an instance of "%s", "%s" given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, get_debug_type($argument))); } $typeFound = false; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php index 5985451b34..19a6a14c7d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php @@ -59,7 +59,7 @@ final class ServiceLocatorTagPass extends AbstractRecursivePass continue; } if (!$v instanceof Reference) { - throw new InvalidArgumentException(sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set, "%s" found for key "%s".', $this->currentId, \is_object($v) ? \get_class($v) : \gettype($v), $k)); + throw new InvalidArgumentException(sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set, "%s" found for key "%s".', $this->currentId, get_debug_type($v), $k)); } if ($i === $k) { @@ -98,7 +98,7 @@ final class ServiceLocatorTagPass extends AbstractRecursivePass { foreach ($refMap as $id => $ref) { if (!$ref instanceof Reference) { - throw new InvalidArgumentException(sprintf('Invalid service locator definition: only services can be referenced, "%s" found for key "%s". Inject parameter values using constructors instead.', \is_object($ref) ? \get_class($ref) : \gettype($ref), $id)); + throw new InvalidArgumentException(sprintf('Invalid service locator definition: only services can be referenced, "%s" found for key "%s". Inject parameter values using constructors instead.', get_debug_type($ref), $id)); } $refMap[$id] = new ServiceClosureArgument($ref); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php index be0f1edd20..1045991ded 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php @@ -52,7 +52,7 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface $values = []; if (false === $i = strpos($env, ':')) { $default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::$typeFixtures['string']; - $defaultType = null !== $default ? self::getType($default) : 'string'; + $defaultType = null !== $default ? get_debug_type($default) : 'string'; $values[$defaultType] = $default; } else { $prefix = substr($env, 0, $i); @@ -99,18 +99,4 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface $this->extensionConfig = []; } } - - private static function getType($value): string - { - switch ($type = \gettype($value)) { - case 'boolean': - return 'bool'; - case 'double': - return 'float'; - case 'integer': - return 'int'; - } - - return $type; - } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 05750bb910..a3c3e28746 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1131,7 +1131,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } if (!\is_callable($callable)) { - throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', \get_class($service))); + throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', get_debug_type($service))); } $callable($service); @@ -1390,7 +1390,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface $completed = true; } else { if (!\is_string($resolved) && !is_numeric($resolved)) { - throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type "%s" inside string value "%s".', $env, \gettype($resolved), $this->resolveEnvPlaceholders($value))); + throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type "%s" inside string value "%s".', $env, get_debug_type($resolved), $this->resolveEnvPlaceholders($value))); } $value = str_ireplace($placeholder, $resolved, $value); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 82cedc381c..82279b522b 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1490,7 +1490,7 @@ EOF; if (\is_array($value)) { $value = $this->exportParameters($value, $path.'/'.$key, $indent + 4); } elseif ($value instanceof ArgumentInterface) { - throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain special arguments. "%s" found in "%s".', \get_class($value), $path.'/'.$key)); + throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain special arguments. "%s" found in "%s".', get_debug_type($value), $path.'/'.$key)); } elseif ($value instanceof Variable) { throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path.'/'.$key)); } elseif ($value instanceof Definition) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index bba092c64e..9cfa23a7cf 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -264,7 +264,7 @@ class YamlDumper extends Dumper } elseif ($value instanceof ServiceLocatorArgument) { $tag = 'service_locator'; } else { - throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', \get_class($value))); + throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', get_debug_type($value))); } return new TaggedValue($tag, $this->dumpValue($value->getValues())); diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index f54c2603dd..af5c0999f2 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -79,7 +79,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if (!isset($array[$key]) && !\array_key_exists($key, $array)) { - throw new EnvNotFoundException(sprintf('Key "%s" not found in "%s" (resolved from "%s").', $key, json_encode($array), $next)); + throw new EnvNotFoundException(sprintf('Key "%s" not found in %s (resolved from "%s").', $key, json_encode($array), $next)); } return $array[$key]; @@ -231,7 +231,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if (null !== $env && !\is_array($env)) { - throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, \gettype($env))); + throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, get_debug_type($env))); } return $env; @@ -275,7 +275,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } $value = $this->container->getParameter($match[1]); if (!is_scalar($value)) { - throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \gettype($value))); + throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, get_debug_type($value))); } return $value; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php index 6f9323f1c2..23e64bb94f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php @@ -91,6 +91,6 @@ abstract class AbstractConfigurator } } - throw new InvalidArgumentException(sprintf('Cannot use values of type "%s" in service configuration files.', \is_object($value) ? \get_class($value) : \gettype($value))); + throw new InvalidArgumentException(sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value))); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index c8b1ce9805..0511fe80eb 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -57,7 +57,7 @@ abstract class FileLoader extends BaseFileLoader if ($ignoreNotFound = 'not_found' === $ignoreErrors) { $args[2] = false; } elseif (!\is_bool($ignoreErrors)) { - throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, \gettype($ignoreErrors))); + throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, get_debug_type($ignoreErrors))); } try { @@ -143,7 +143,7 @@ abstract class FileLoader extends BaseFileLoader if ($this->isLoadingInstanceof) { if (!$definition instanceof ChildDefinition) { - throw new InvalidArgumentException(sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_class($definition))); + throw new InvalidArgumentException(sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, get_debug_type($definition))); } $this->instanceof[$id] = $definition; } else { diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 8cd315c5d7..74e828665d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -596,7 +596,7 @@ class XmlFileLoader extends FileLoader $path = str_replace([$ns, str_replace('http://', 'https://', $ns)], str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]); if (!is_file($path)) { - throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s".', \get_class($extension), $path)); + throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s".', get_debug_type($extension), $path)); } $schemaLocations[$items[$i]] = $path; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 459aa71107..0a7971b860 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -213,7 +213,7 @@ class YamlFileLoader extends FileLoader unset($content['services']['_instanceof']); if (!\is_array($instanceof)) { - throw new InvalidArgumentException(sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', \gettype($instanceof), $file)); + throw new InvalidArgumentException(sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', get_debug_type($instanceof), $file)); } $this->instanceof = []; $this->isLoadingInstanceof = true; @@ -247,7 +247,7 @@ class YamlFileLoader extends FileLoader unset($content['services']['_defaults']); if (!\is_array($defaults)) { - throw new InvalidArgumentException(sprintf('Service "_defaults" key must be an array, "%s" given in "%s".', \gettype($defaults), $file)); + throw new InvalidArgumentException(sprintf('Service "_defaults" key must be an array, "%s" given in "%s".', get_debug_type($defaults), $file)); } foreach ($defaults as $key => $default) { @@ -339,7 +339,7 @@ class YamlFileLoader extends FileLoader } if (!\is_array($service)) { - throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \gettype($service), $id, $file)); + throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', get_debug_type($service), $id, $file)); } $this->checkDefinition($id, $service, $file); @@ -465,7 +465,7 @@ class YamlFileLoader extends FileLoader foreach ($service['calls'] as $k => $call) { if (!\is_array($call) && (!\is_string($k) || !$call instanceof TaggedValue)) { - throw new InvalidArgumentException(sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof TaggedValue ? '!'.$call->getTag() : \gettype($call), $file)); + throw new InvalidArgumentException(sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof TaggedValue ? '!'.$call->getTag() : get_debug_type($call), $file)); } if (\is_string($k)) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php index 8012a21fb5..ed128fa5ea 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php @@ -48,7 +48,7 @@ class EnvPlaceholderParameterBag extends ParameterBag throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name)); } if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) { - throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); + throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', get_debug_type($defaultValue), $name)); } $uniqueName = md5($name.'_'.self::$counter++); @@ -147,7 +147,7 @@ class EnvPlaceholderParameterBag extends ParameterBag foreach ($this->envPlaceholders as $env => $placeholders) { if ($this->has($name = "env($env)") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) { - throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \gettype($default))); + throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, get_debug_type($default))); } } } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index ce63e3cf50..77d6630a56 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -227,7 +227,7 @@ class ParameterBag implements ParameterBagInterface $resolved = $this->get($key); if (!\is_string($resolved) && !is_numeric($resolved)) { - throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \gettype($resolved), $value)); + throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, get_debug_type($resolved), $value)); } $resolved = (string) $resolved; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php index 081db17468..51ad6d4697 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php @@ -67,7 +67,7 @@ class CheckTypeDeclarationsPassTest extends TestCase public function testProcessFailsWhenPassingNullToRequiredArgument() { $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\Bar::__construct" accepts "stdClass", "NULL" passed.'); + $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\Bar::__construct" accepts "stdClass", "null" passed.'); $container = new ContainerBuilder(); @@ -245,7 +245,7 @@ class CheckTypeDeclarationsPassTest extends TestCase public function testProcessSuccessWhenPassingNullToOptionalThatDoesNotAcceptNull() { $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarOptionalArgumentNotNull::__construct" accepts "int", "NULL" passed.'); + $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarOptionalArgumentNotNull::__construct" accepts "int", "null" passed.'); $container = new ContainerBuilder(); @@ -288,7 +288,7 @@ class CheckTypeDeclarationsPassTest extends TestCase public function testProcessFailsOnPassingScalarTypeToConstructorTypedWithClass() { $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\Bar::__construct" accepts "stdClass", "integer" passed.'); + $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\Bar::__construct" accepts "stdClass", "int" passed.'); $container = new ContainerBuilder(); @@ -376,7 +376,7 @@ class CheckTypeDeclarationsPassTest extends TestCase public function testProcessSuccessWhenPassingIntegerToArrayTypedParameter() { $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException::class); - $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall::setArray" accepts "array", "integer" passed.'); + $this->expectExceptionMessage('Invalid definition for service "bar": argument 1 of "Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall::setArray" accepts "array", "int" passed.'); $container = new ContainerBuilder(); @@ -564,7 +564,7 @@ class CheckTypeDeclarationsPassTest extends TestCase public function testProcessThrowsOnIterableTypeWhenScalarPassed() { $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid definition for service "bar_call": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarMethodCall::setIterable" accepts "iterable", "integer" passed.'); + $this->expectExceptionMessage('Invalid definition for service "bar_call": argument 1 of "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CheckTypeDeclarationsPass\\BarMethodCall::setIterable" accepts "iterable", "int" passed.'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php index f6c255484a..c45eaf4677 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php @@ -386,7 +386,7 @@ class IntegrationTest extends TestCase /** @var ServiceLocator $serviceLocator */ $serviceLocator = $s->getParam(); - $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', \is_object($serviceLocator) ? \get_class($serviceLocator) : \gettype($serviceLocator))); + $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', get_debug_type($serviceLocator))); $same = [ 'bar' => $serviceLocator->get('bar'), @@ -419,7 +419,7 @@ class IntegrationTest extends TestCase /** @var ServiceLocator $serviceLocator */ $serviceLocator = $s->getParam(); - $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', \is_object($serviceLocator) ? \get_class($serviceLocator) : \gettype($serviceLocator))); + $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', get_debug_type($serviceLocator))); $same = [ 'bar' => $serviceLocator->get('bar'), @@ -451,7 +451,7 @@ class IntegrationTest extends TestCase /** @var ServiceLocator $serviceLocator */ $serviceLocator = $s->getParam(); - $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', \is_object($serviceLocator) ? \get_class($serviceLocator) : \gettype($serviceLocator))); + $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', get_debug_type($serviceLocator))); $same = [ 'bar_tab_class_with_defaultmethod' => $serviceLocator->get('bar_tab_class_with_defaultmethod'), @@ -478,7 +478,7 @@ class IntegrationTest extends TestCase /** @var ServiceLocator $serviceLocator */ $serviceLocator = $s->getParam(); - $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', \is_object($serviceLocator) ? \get_class($serviceLocator) : \gettype($serviceLocator))); + $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', get_debug_type($serviceLocator))); $expected = [ 'bar_tag' => $container->get('bar_tag'), @@ -504,7 +504,7 @@ class IntegrationTest extends TestCase /** @var ServiceLocator $serviceLocator */ $serviceLocator = $s->getParam(); - $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', \is_object($serviceLocator) ? \get_class($serviceLocator) : \gettype($serviceLocator))); + $this->assertTrue($s->getParam() instanceof ServiceLocator, sprintf('Wrong instance, should be an instance of ServiceLocator, %s given', get_debug_type($serviceLocator))); $expected = [ 'baz' => $container->get('bar_tag'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index ca25fb7558..d48bdf96b6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -58,7 +58,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase public function testDefaultEnvWithoutPrefixIsValidatedInConfig() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "double" given to "env(FLOATISH)".'); + $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "float" given to "env(FLOATISH)".'); $container = new ContainerBuilder(); $container->setParameter('env(FLOATISH)', 3.2); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 0a56e7a4ac..3d422c6506 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -707,7 +707,7 @@ class YamlFileLoaderTest extends TestCase public function testEmptyDefaultsThrowsClearException() { $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); - $this->expectExceptionMessageRegExp('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./'); + $this->expectExceptionMessageRegExp('/Service "_defaults" key must be an array, "null" given in ".+bad_empty_defaults\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('bad_empty_defaults.yml'); @@ -716,7 +716,7 @@ class YamlFileLoaderTest extends TestCase public function testEmptyInstanceofThrowsClearException() { $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); - $this->expectExceptionMessageRegExp('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./'); + $this->expectExceptionMessageRegExp('/Service "_instanceof" key must be an array, "null" given in ".+bad_empty_instanceof\.yml"\./'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('bad_empty_instanceof.yml'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php index 8d3c48165f..0f5982adef 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php @@ -112,7 +112,7 @@ class EnvPlaceholderParameterBagTest extends TestCase public function testResolveEnvRequiresStrings() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "integer" given.'); + $this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "int" given.'); $bag = new EnvPlaceholderParameterBag(); $bag->get('env(INT_VAR)'); @@ -123,7 +123,7 @@ class EnvPlaceholderParameterBagTest extends TestCase public function testGetDefaultScalarEnv() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "integer" given to "env(INT_VAR)".'); + $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "int" given to "env(INT_VAR)".'); $bag = new EnvPlaceholderParameterBag(); $bag->set('env(INT_VAR)', 2); diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 12d6febe95..a28dd124b6 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -19,11 +19,12 @@ "php": "^7.2.5", "psr/container": "^1.0", "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1.6|^2" }, "require-dev": { "symfony/yaml": "^4.4|^5.0", - "symfony/config": "^5.0", + "symfony/config": "^5.1", "symfony/expression-language": "^4.4|^5.0" }, "suggest": { @@ -34,7 +35,7 @@ "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, "conflict": { - "symfony/config": "<5.0", + "symfony/config": "<5.1", "symfony/finder": "<4.4", "symfony/proxy-manager-bridge": "<4.4", "symfony/yaml": "<4.4" diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index cf5a9ea742..0eddcfdb4e 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -122,7 +122,7 @@ class Crawler implements \Countable, \IteratorAggregate } elseif (\is_string($node)) { $this->addContent($node); } elseif (null !== $node) { - throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', \is_object($node) ? \get_class($node) : \gettype($node))); + throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', get_debug_type($node))); } } @@ -802,7 +802,7 @@ class Crawler implements \Countable, \IteratorAggregate $node = $this->getNode(0); if (!$node instanceof \DOMElement) { - throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node))); + throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node))); } return new Link($node, $this->baseHref, $method); @@ -820,7 +820,7 @@ class Crawler implements \Countable, \IteratorAggregate $links = []; foreach ($this->nodes as $node) { if (!$node instanceof \DOMElement) { - throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node))); + throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_debug_type($node))); } $links[] = new Link($node, $this->baseHref, 'get'); @@ -845,7 +845,7 @@ class Crawler implements \Countable, \IteratorAggregate $node = $this->getNode(0); if (!$node instanceof \DOMElement) { - throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node))); + throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node))); } return new Image($node, $this->baseHref); @@ -861,7 +861,7 @@ class Crawler implements \Countable, \IteratorAggregate $images = []; foreach ($this as $node) { if (!$node instanceof \DOMElement) { - throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node))); + throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_debug_type($node))); } $images[] = new Image($node, $this->baseHref); @@ -886,7 +886,7 @@ class Crawler implements \Countable, \IteratorAggregate $node = $this->getNode(0); if (!$node instanceof \DOMElement) { - throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node))); + throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node))); } $form = new Form($node, $this->uri, $method, $this->baseHref); diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index ae5cf5ca05..0810f671d4 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -18,7 +18,8 @@ "require": { "php": "^7.2.5", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/css-selector": "^4.4|^5.0", diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 523c2ef786..04226c6ce1 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -406,7 +406,7 @@ class DebugClassLoader } $deprecations = []; - $className = isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $className = false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; // Don't trigger deprecations for classes in the same vendor if ($class !== $className) { diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index 059f822f82..1253d40f21 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -435,7 +435,7 @@ class ErrorHandler $context = $e; } - if (false !== strpos($message, "class@anonymous\0")) { + if (false !== strpos($message, "@anonymous\0")) { $logMessage = $this->parseAnonymousClass($message); } else { $logMessage = $this->levels[$type].': '.$message; @@ -558,7 +558,7 @@ class ErrorHandler } if ($this->loggedErrors & $type) { - if (false !== strpos($message = $exception->getMessage(), "class@anonymous\0")) { + if (false !== strpos($message = $exception->getMessage(), "@anonymous\0")) { $message = $this->parseAnonymousClass($message); } @@ -768,8 +768,8 @@ class ErrorHandler */ private function parseAnonymousClass(string $message): string { - return preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', static function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0]))).'@anonymous' : $m[0]; + return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', static function ($m) { + return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); } } diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php index 96ac3729e1..11f3a606f1 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php @@ -46,11 +46,11 @@ class HtmlErrorRenderer implements ErrorRendererInterface public function __construct($debug = false, string $charset = null, $fileLinkFormat = null, string $projectDir = null, $outputBuffer = '', LoggerInterface $logger = null) { if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, get_debug_type($debug))); } if (!\is_string($outputBuffer) && !\is_callable($outputBuffer)) { - throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($outputBuffer) ? \get_class($outputBuffer) : \gettype($outputBuffer))); + throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, get_debug_type($outputBuffer))); } $this->debug = $debug; diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php index de68354329..5f9b038c11 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php @@ -35,11 +35,11 @@ class SerializerErrorRenderer implements ErrorRendererInterface public function __construct(SerializerInterface $serializer, $format, ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false) { if (!\is_string($format) && !\is_callable($format)) { - throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($format) ? \get_class($format) : \gettype($format))); + throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, get_debug_type($format))); } if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 4 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 4 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, get_debug_type($debug))); } $this->serializer = $serializer; diff --git a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php index c1a10903d4..6dfde78528 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php @@ -142,7 +142,7 @@ class FlattenException */ public function setClass($class): self { - $this->class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $this->class = false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; return $this; } @@ -199,9 +199,9 @@ class FlattenException */ public function setMessage($message): self { - if (false !== strpos($message, "class@anonymous\0")) { - $message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0]))).'@anonymous' : $m[0]; + if (false !== strpos($message, "@anonymous\0")) { + $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { + return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); } diff --git a/src/Symfony/Component/ErrorHandler/composer.json b/src/Symfony/Component/ErrorHandler/composer.json index e36794b065..95deee0250 100644 --- a/src/Symfony/Component/ErrorHandler/composer.json +++ b/src/Symfony/Component/ErrorHandler/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "psr/log": "^1.0", + "symfony/polyfill-php80": "^1.15", "symfony/var-dumper": "^4.4|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php index 295bcae88a..58a5ed9813 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php @@ -43,7 +43,7 @@ final class WrappedListener $this->stoppedPropagation = false; if (\is_array($listener)) { - $this->name = \is_object($listener[0]) ? \get_class($listener[0]) : $listener[0]; + $this->name = \is_object($listener[0]) ? get_debug_type($listener[0]) : $listener[0]; $this->pretty = $this->name.'::'.$listener[1]; } elseif ($listener instanceof \Closure) { $r = new \ReflectionFunction($listener); @@ -58,7 +58,7 @@ final class WrappedListener } elseif (\is_string($listener)) { $this->pretty = $this->name = $listener; } else { - $this->name = \get_class($listener); + $this->name = get_debug_type($listener); $this->pretty = $this->name.'::__invoke'; } diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 5e4a83363a..403acf0366 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -18,7 +18,8 @@ "require": { "php": "^7.2.5", "symfony/deprecation-contracts": "^2.1", - "symfony/event-dispatcher-contracts": "^2" + "symfony/event-dispatcher-contracts": "^2", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/dependency-injection": "^4.4|^5.0", diff --git a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php b/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php index 7d86b53bc2..edc4e96ebf 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php @@ -83,7 +83,7 @@ class GetAttrNode extends Node throw new \RuntimeException('Unable to call method of a non-object.'); } if (!\is_callable($toCall = [$obj, $this->nodes['attribute']->attributes['value']])) { - throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], \get_class($obj))); + throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_debug_type($obj))); } return $toCall(...array_values($this->nodes['arguments']->evaluate($functions, $values))); diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index 0742a3ef7b..28f6ebece5 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "symfony/cache": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2" }, "autoload": { diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/Cache/AbstractStaticOption.php b/src/Symfony/Component/Form/ChoiceList/Factory/Cache/AbstractStaticOption.php index 2f8ac98078..42b31e0275 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/Cache/AbstractStaticOption.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/Cache/AbstractStaticOption.php @@ -41,7 +41,7 @@ abstract class AbstractStaticOption final public function __construct($formType, $option, $vary = null) { if (!$formType instanceof FormTypeInterface && !$formType instanceof FormTypeExtensionInterface) { - throw new \TypeError(sprintf('Expected an instance of "%s" or "%s", but got "%s".', FormTypeInterface::class, FormTypeExtensionInterface::class, \is_object($formType) ? \get_class($formType) : \gettype($formType))); + throw new \TypeError(sprintf('Expected an instance of "%s" or "%s", but got "%s".', FormTypeInterface::class, FormTypeExtensionInterface::class, get_debug_type($formType))); } $hash = CachingFactoryDecorator::generateHash([static::class, $formType, $vary]); diff --git a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php index e085795bb5..520212373c 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/Descriptor.php @@ -58,7 +58,7 @@ abstract class Descriptor implements DescriptorInterface $this->describeOption($object, $options); break; default: - throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object))); + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))); } } diff --git a/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php index c9aa11eb47..d25d4705fa 100644 --- a/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php @@ -15,6 +15,6 @@ class UnexpectedTypeException extends InvalidArgumentException { public function __construct($value, string $expectedType) { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value))); + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value))); } } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/WeekToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/WeekToArrayTransformer.php index 51475e235c..37405998fa 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/WeekToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/WeekToArrayTransformer.php @@ -38,7 +38,7 @@ class WeekToArrayTransformer implements DataTransformerInterface } if (!\is_string($value)) { - throw new TransformationFailedException(sprintf('Value is expected to be a string but was "%s".', \is_object($value) ? \get_class($value) : \gettype($value))); + throw new TransformationFailedException(sprintf('Value is expected to be a string but was "%s".', get_debug_type($value))); } if (0 === preg_match('/^(?P\d{4})-W(?P\d{2})$/', $value, $matches)) { @@ -68,7 +68,7 @@ class WeekToArrayTransformer implements DataTransformerInterface } if (!\is_array($value)) { - throw new TransformationFailedException(sprintf('Value is expected to be an array, but was "%s".', \is_object($value) ? \get_class($value) : \gettype($value))); + throw new TransformationFailedException(sprintf('Value is expected to be an array, but was "%s".', get_debug_type($value))); } if (!\array_key_exists('year', $value)) { @@ -88,11 +88,11 @@ class WeekToArrayTransformer implements DataTransformerInterface } if (!\is_int($value['year'])) { - throw new TransformationFailedException(sprintf('Year is expected to be an integer, but was "%s".', \is_object($value['year']) ? \get_class($value['year']) : \gettype($value['year']))); + throw new TransformationFailedException(sprintf('Year is expected to be an integer, but was "%s".', get_debug_type($value['year']))); } if (!\is_int($value['week'])) { - throw new TransformationFailedException(sprintf('Week is expected to be an integer, but was "%s".', \is_object($value['week']) ? \get_class($value['week']) : \gettype($value['week']))); + throw new TransformationFailedException(sprintf('Week is expected to be an integer, but was "%s".', get_debug_type($value['week']))); } // The 28th December is always in the last week of the year diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php index 95763c26c7..facd925c0e 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php @@ -50,7 +50,7 @@ class TransformationFailureListener implements EventSubscriberInterface } } - $clientDataAsString = is_scalar($form->getViewData()) ? (string) $form->getViewData() : \gettype($form->getViewData()); + $clientDataAsString = is_scalar($form->getViewData()) ? (string) $form->getViewData() : get_debug_type($form->getViewData()); $messageTemplate = 'The value {{ value }} is not valid.'; if (null !== $this->translator) { diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index da592985f9..57e39617fd 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -61,7 +61,7 @@ class FormType extends BaseType } if (!method_exists($builder, 'setIsEmptyCallback')) { - trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated.', FormConfigBuilderInterface::class, \get_class($builder)); + trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated.', FormConfigBuilderInterface::class, get_debug_type($builder)); return; } diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index e0885eae6b..3d3b2c8092 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -125,7 +125,7 @@ class FormValidator extends ConstraintValidator if ($childrenSynchronized) { $clientDataAsString = is_scalar($form->getViewData()) ? (string) $form->getViewData() - : \gettype($form->getViewData()); + : get_debug_type($form->getViewData()); $failure = $form->getTransformationFailure(); diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 60a33115d6..adc46ac4fe 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -357,11 +357,9 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac $dataClass = $this->config->getDataClass(); if (null !== $dataClass && !$viewData instanceof $dataClass) { - $actualType = \is_object($viewData) - ? 'an instance of class '.\get_class($viewData) - : 'a(n) '.\gettype($viewData); + $actualType = get_debug_type($viewData); - throw new LogicException('The form\'s view data is expected to be an instance of class '.$dataClass.', but is '.$actualType.'. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms '.$actualType.' to an instance of '.$dataClass.'.'); + throw new LogicException('The form\'s view data is expected to be a "'.$dataClass.'", but it is a "'.$actualType.'". You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms "'.$actualType.'" to an instance of "'.$dataClass.'".'); } } diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index 86aa26fbfd..3f84f3c342 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -48,7 +48,7 @@ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \Array { foreach ($errors as $error) { if (!($error instanceof FormError || $error instanceof self)) { - throw new InvalidArgumentException(sprintf('The errors must be instances of "Symfony\Component\Form\FormError" or "%s". Got: "%s".', __CLASS__, \is_object($error) ? \get_class($error) : \gettype($error))); + throw new InvalidArgumentException(sprintf('The errors must be instances of "Symfony\Component\Form\FormError" or "%s". Got: "%s".', __CLASS__, get_debug_type($error))); } } diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php index 6dd1500a5f..836984d5c3 100644 --- a/src/Symfony/Component/Form/ResolvedFormType.php +++ b/src/Symfony/Component/Form/ResolvedFormType.php @@ -96,7 +96,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface try { $options = $this->getOptionsResolver()->resolve($options); } catch (ExceptionInterface $e) { - throw new $e(sprintf('An error has occurred resolving the options of the form "%s": %s.', \get_class($this->getInnerType()), $e->getMessage()), $e->getCode(), $e); + throw new $e(sprintf('An error has occurred resolving the options of the form "%s": %s.', get_debug_type($this->getInnerType()), $e->getMessage()), $e->getCode(), $e); } // Should be decoupled from the specific option at some point diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php index 3f681622a8..5c855bb868 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/WeekToArrayTransformerTest.php @@ -106,11 +106,11 @@ class WeekToArrayTransformerTest extends TestCase return [ 'missing year' => [['week' => 1], 'Key "year" is missing.'], 'missing week' => [['year' => 2019], 'Key "week" is missing.'], - 'integer instead of array' => [0, 'Value is expected to be an array, but was "integer"'], + 'integer instead of array' => [0, 'Value is expected to be an array, but was "int"'], 'string instead of array' => ['12345', 'Value is expected to be an array, but was "string"'], 'week invalid' => [['year' => 2019, 'week' => 66], 'Week "66" does not exist for year "2019".'], - 'year null' => [['year' => null, 'week' => 1], 'Year is expected to be an integer, but was "NULL".'], - 'week null' => [['year' => 2019, 'week' => null], 'Week is expected to be an integer, but was "NULL".'], + 'year null' => [['year' => null, 'week' => 1], 'Year is expected to be an integer, but was "null".'], + 'week null' => [['year' => 2019, 'week' => null], 'Week is expected to be an integer, but was "null".'], 'year non-integer' => [['year' => '2019', 'week' => 1], 'Year is expected to be an integer, but was "string".'], 'week non-integer' => [['year' => 2019, 'week' => '1'], 'Week is expected to be an integer, but was "string".'], 'unexpected key' => [['year' => 2019, 'bar' => 'baz', 'week' => 1, 'foo' => 'foobar'], 'Expected only keys "year" and "week" to be present, but also got ["bar", "foo"].'], diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 40413c66e2..08a39f595e 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -23,6 +23,7 @@ "symfony/options-resolver": "^5.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/property-access": "^5.0", "symfony/service-contracts": "^1.1|^2" }, diff --git a/src/Symfony/Component/HttpClient/AmpHttpClient.php b/src/Symfony/Component/HttpClient/AmpHttpClient.php index c62b847910..1520d22a27 100644 --- a/src/Symfony/Component/HttpClient/AmpHttpClient.php +++ b/src/Symfony/Component/HttpClient/AmpHttpClient.php @@ -138,7 +138,7 @@ final class AmpHttpClient implements HttpClientInterface, LoggerAwareInterface, if ($responses instanceof AmpResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of AmpResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of AmpResponse objects, %s given.', __METHOD__, get_debug_type($responses))); } return new ResponseStream(AmpResponse::stream($responses, $timeout)); diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index 0327791193..75f6d5d918 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -114,7 +114,7 @@ class CachingHttpClient implements HttpClientInterface if ($responses instanceof ResponseInterface) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('"%s()" expects parameter 1 to be an iterable of ResponseInterface objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('"%s()" expects parameter 1 to be an iterable of ResponseInterface objects, "%s" given.', __METHOD__, get_debug_type($responses))); } $mockResponses = []; diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 9f9fbd0a8a..38f7462ef1 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -163,7 +163,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, } if (!\is_string($options['auth_ntlm'])) { - throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', \gettype($options['auth_ntlm']))); + throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', get_debug_type($options['auth_ntlm']))); } $curlopts[CURLOPT_USERPWD] = $options['auth_ntlm']; @@ -319,7 +319,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if ($responses instanceof CurlResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, "%s" given.', __METHOD__, get_debug_type($responses))); } $active = 0; @@ -439,7 +439,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, { if (!$eof && \strlen($buffer) < $length) { if (!\is_string($data = $body($length))) { - throw new TransportException(sprintf('The return value of the "body" option callback must be a string, "%s" returned.', \gettype($data))); + throw new TransportException(sprintf('The return value of the "body" option callback must be a string, "%s" returned.', get_debug_type($data))); } $buffer .= $data; diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 7ccc435e6b..f27041c848 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -49,7 +49,7 @@ trait HttpClientTrait $options['buffer'] = static function (array $headers) use ($buffer) { if (!\is_bool($buffer = $buffer($headers))) { if (!\is_array($bufferInfo = @stream_get_meta_data($buffer))) { - throw new \LogicException(sprintf('The closure passed as option "buffer" must return bool or stream resource, got "%s".', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); + throw new \LogicException(sprintf('The closure passed as option "buffer" must return bool or stream resource, got "%s".', get_debug_type($buffer))); } if (false === strpbrk($bufferInfo['mode'], 'acew+')) { @@ -61,7 +61,7 @@ trait HttpClientTrait }; } elseif (!\is_bool($buffer)) { if (!\is_array($bufferInfo = @stream_get_meta_data($buffer))) { - throw new InvalidArgumentException(sprintf('Option "buffer" must be bool, stream resource or Closure, "%s" given.', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); + throw new InvalidArgumentException(sprintf('Option "buffer" must be bool, stream resource or Closure, "%s" given.', get_debug_type($buffer))); } if (false === strpbrk($bufferInfo['mode'], 'acew+')) { @@ -95,7 +95,7 @@ trait HttpClientTrait // Validate on_progress if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) { - throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress))); + throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', get_debug_type($onProgress))); } if (\is_array($options['auth_basic'] ?? null)) { @@ -108,11 +108,11 @@ trait HttpClientTrait } if (!\is_string($options['auth_basic'] ?? '')) { - throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, "%s" given.', \gettype($options['auth_basic']))); + throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, "%s" given.', get_debug_type($options['auth_basic']))); } if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._=~+/0-9a-zA-Z]++$}', $options['auth_bearer']))) { - throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : '"'.\gettype($options['auth_bearer']).'"')); + throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : '"'.get_debug_type($options['auth_bearer']).'"')); } if (isset($options['auth_basic'], $options['auth_bearer'])) { @@ -232,13 +232,13 @@ trait HttpClientTrait if (\is_int($name)) { if (!\is_string($values)) { - throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, \gettype($values))); + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, get_debug_type($values))); } [$name, $values] = explode(':', $values, 2); $values = [ltrim($values)]; } elseif (!is_iterable($values)) { if (\is_object($values)) { - throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, \get_class($values))); + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, get_debug_type($values))); } $values = (array) $values; @@ -313,7 +313,7 @@ trait HttpClientTrait } if (!\is_array(@stream_get_meta_data($body))) { - throw new InvalidArgumentException(sprintf('Option "body" must be string, stream resource, iterable or callable, "%s" given.', \is_resource($body) ? get_resource_type($body) : \gettype($body))); + throw new InvalidArgumentException(sprintf('Option "body" must be string, stream resource, iterable or callable, "%s" given.', get_debug_type($body))); } return $body; @@ -339,7 +339,7 @@ trait HttpClientTrait $fingerprint[$algo] = 'pin-sha256' === $algo ? (array) $hash : str_replace(':', '', $hash); } } else { - throw new InvalidArgumentException(sprintf('Option "peer_fingerprint" must be string or array, "%s" given.', \gettype($fingerprint))); + throw new InvalidArgumentException(sprintf('Option "peer_fingerprint" must be string or array, "%s" given.', get_debug_type($fingerprint))); } return $fingerprint; diff --git a/src/Symfony/Component/HttpClient/HttplugClient.php b/src/Symfony/Component/HttpClient/HttplugClient.php index ec00b3234a..edf46dcc8b 100644 --- a/src/Symfony/Component/HttpClient/HttplugClient.php +++ b/src/Symfony/Component/HttpClient/HttplugClient.php @@ -184,7 +184,7 @@ final class HttplugClient implements HttplugInterface, HttpAsyncClient, RequestF } elseif (\is_resource($body)) { $stream = $this->streamFactory->createStreamFromResource($body); } else { - throw new \InvalidArgumentException(sprintf('"%s()" expects string, resource or StreamInterface, "%s" given.', __METHOD__, \gettype($body))); + throw new \InvalidArgumentException(sprintf('"%s()" expects string, resource or StreamInterface, "%s" given.', __METHOD__, get_debug_type($body))); } if ($stream->isSeekable()) { diff --git a/src/Symfony/Component/HttpClient/Internal/AmpBody.php b/src/Symfony/Component/HttpClient/Internal/AmpBody.php index 5f9f81cac9..bd4542001c 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpBody.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpBody.php @@ -133,7 +133,7 @@ class AmpBody implements RequestBody, InputStream } if (!\is_string($data)) { - throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data))); + throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', get_debug_type($data))); } return new Success($data); diff --git a/src/Symfony/Component/HttpClient/MockHttpClient.php b/src/Symfony/Component/HttpClient/MockHttpClient.php index 2d929ebfc3..63e0fbdee8 100644 --- a/src/Symfony/Component/HttpClient/MockHttpClient.php +++ b/src/Symfony/Component/HttpClient/MockHttpClient.php @@ -82,7 +82,7 @@ class MockHttpClient implements HttpClientInterface if ($responses instanceof ResponseInterface) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse objects, "%s" given.', __METHOD__, get_debug_type($responses))); } return new ResponseStream(MockResponse::stream($responses, $timeout)); diff --git a/src/Symfony/Component/HttpClient/NativeHttpClient.php b/src/Symfony/Component/HttpClient/NativeHttpClient.php index bea05f65e0..11ed5ee69d 100644 --- a/src/Symfony/Component/HttpClient/NativeHttpClient.php +++ b/src/Symfony/Component/HttpClient/NativeHttpClient.php @@ -235,7 +235,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac if ($responses instanceof NativeResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse objects, "%s" given.', __METHOD__, get_debug_type($responses))); } return new ResponseStream(NativeResponse::stream($responses, $timeout)); @@ -255,7 +255,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac while ('' !== $data = $body(self::$CHUNK_SIZE)) { if (!\is_string($data)) { - throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data))); + throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', get_debug_type($data))); } $result .= $data; diff --git a/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php b/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php index 215990beea..3d86f09e76 100644 --- a/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php +++ b/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php @@ -54,7 +54,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa public function __construct(HttpClientInterface $client, $subnets = null) { if (!(\is_array($subnets) || \is_string($subnets) || null === $subnets)) { - throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be of the type array, string or null. "%s" given.', __METHOD__, \is_object($subnets) ? \get_class($subnets) : \gettype($subnets))); + throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be of the type array, string or null. "%s" given.', __METHOD__, get_debug_type($subnets))); } if (!class_exists(IpUtils::class)) { @@ -72,7 +72,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa { $onProgress = $options['on_progress'] ?? null; if (null !== $onProgress && !\is_callable($onProgress)) { - throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress))); + throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', get_debug_type($onProgress))); } $subnets = $this->subnets; diff --git a/src/Symfony/Component/HttpClient/Response/MockResponse.php b/src/Symfony/Component/HttpClient/Response/MockResponse.php index 0f359f30b3..e2ae37ece1 100644 --- a/src/Symfony/Component/HttpClient/Response/MockResponse.php +++ b/src/Symfony/Component/HttpClient/Response/MockResponse.php @@ -228,7 +228,7 @@ class MockResponse implements ResponseInterface } elseif ($body instanceof \Closure) { while ('' !== $data = $body(16372)) { if (!\is_string($data)) { - throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data))); + throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', get_debug_type($data))); } // "notify" upload progress diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index f49ca68338..7b11d40878 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -161,7 +161,7 @@ trait ResponseTrait } if (!\is_array($content)) { - throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned for "%s".', \gettype($content), $this->getInfo('url'))); + throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned for "%s".', get_debug_type($content), $this->getInfo('url'))); } if (null !== $this->content) { diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index 477c33d924..9662081825 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -179,7 +179,7 @@ class HttpClientTraitTest extends TestCase public function testInvalidAuthBearerOption() { $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, "object" given.'); + $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, "stdClass" given.'); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS); } @@ -249,7 +249,7 @@ class HttpClientTraitTest extends TestCase public function testNormalizePeerFingerprintTypeException() { $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "object" given.'); + $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "stdClass" given.'); $fingerprint = new \stdClass(); $this->normalizePeerFingerprint($fingerprint); diff --git a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php index 77c4461aa1..1e099689b1 100755 --- a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php @@ -122,7 +122,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase public function testConstructor() { $this->expectException(\TypeError::class); - $this->expectExceptionMessage('Argument 2 passed to "Symfony\Component\HttpClient\NoPrivateNetworkHttpClient::__construct()" must be of the type array, string or null. "integer" given.'); + $this->expectExceptionMessage('Argument 2 passed to "Symfony\Component\HttpClient\NoPrivateNetworkHttpClient::__construct()" must be of the type array, string or null. "int" given.'); new NoPrivateNetworkHttpClient(new MockHttpClient(), 3); } diff --git a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php index 1b3ab16a84..77b0dfa7c8 100644 --- a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php +++ b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php @@ -62,7 +62,7 @@ class MockResponseTest extends TestCase yield [ 'content' => '8', 'responseHeaders' => [], - 'message' => 'JSON content was expected to decode to an array, "integer" returned for "https://example.com/file.json".', + 'message' => 'JSON content was expected to decode to an array, "int" returned for "https://example.com/file.json".', ]; } } diff --git a/src/Symfony/Component/HttpClient/TraceableHttpClient.php b/src/Symfony/Component/HttpClient/TraceableHttpClient.php index f609c5bef3..34fa33e643 100644 --- a/src/Symfony/Component/HttpClient/TraceableHttpClient.php +++ b/src/Symfony/Component/HttpClient/TraceableHttpClient.php @@ -67,13 +67,13 @@ final class TraceableHttpClient implements HttpClientInterface, ResetInterface, if ($responses instanceof TraceableResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($responses))); } return $this->client->stream(\Closure::bind(static function () use ($responses) { foreach ($responses as $k => $r) { if (!$r instanceof TraceableResponse) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, \is_object($r) ? \get_class($r) : \gettype($r))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, get_debug_type($r))); } yield $k => $r->response; diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index 47ddbcaa2e..75cccf6717 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -25,6 +25,7 @@ "psr/log": "^1.0", "symfony/http-client-contracts": "^1.1.8|^2", "symfony/polyfill-php73": "^1.11", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.0|^2" }, "require-dev": { diff --git a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php index 82b982b378..8533f99a8c 100644 --- a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php @@ -15,6 +15,6 @@ class UnexpectedTypeException extends FileException { public function __construct($value, string $expectedType) { - parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value))); + parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, get_debug_type($value))); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index f0d07dd487..2bb9584996 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -54,7 +54,7 @@ class RedisSessionHandler extends AbstractSessionHandler !$redis instanceof RedisProxy && !$redis instanceof RedisClusterProxy ) { - throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); + throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($redis))); } if ($diff = array_diff(array_keys($options), ['prefix', 'ttl'])) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php index a5ebd29eba..dcdde80795 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php @@ -27,7 +27,7 @@ class SessionHandlerFactory public static function createHandler($connection): AbstractSessionHandler { if (!\is_string($connection) && !\is_object($connection)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, get_debug_type($connection))); } switch (true) { @@ -46,7 +46,7 @@ class SessionHandlerFactory return new PdoSessionHandler($connection); case !\is_string($connection): - throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection))); + throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection))); case 0 === strpos($connection, 'file://'): return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7))); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php index 4292a3b2f0..3cf4a6f479 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php @@ -24,7 +24,7 @@ class StrictSessionHandler extends AbstractSessionHandler public function __construct(\SessionHandlerInterface $handler) { if ($handler instanceof \SessionUpdateTimestampHandlerInterface) { - throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', \get_class($handler), self::class)); + throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', get_debug_type($handler), self::class)); } $this->handler = $handler; diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index b214a11562..344d900243 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -18,7 +18,8 @@ "require": { "php": "^7.2.5", "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-mbstring": "~1.1" + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "predis/predis": "~1.0", diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index e8057737ed..2e65f67c9d 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -69,7 +69,7 @@ abstract class Bundle implements BundleInterface if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); + throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); } // check naming convention diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php index 43bbe178d5..530a6f6ede 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php @@ -62,7 +62,7 @@ final class ArgumentResolver implements ArgumentResolverInterface } if (!$atLeastOne) { - throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver))); + throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', get_debug_type($resolver))); } // continue to the next controller argument diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php index ed61420e67..a8f7e0f440 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php @@ -38,7 +38,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface $values = $request->attributes->get($argument->getName()); if (!\is_array($values)) { - throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), \gettype($values))); + throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); } yield from $values; diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 1f8354291b..d90cb3a76c 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -161,11 +161,11 @@ class ControllerResolver implements ControllerResolverInterface $availableMethods = $this->getClassMethodsWithoutMagicMethods($callable); $alternativeMsg = $availableMethods ? sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; - return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', \get_class($callable), $alternativeMsg); + return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); } if (!\is_array($callable)) { - return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', \gettype($callable)); + return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); } if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) { @@ -178,7 +178,7 @@ class ControllerResolver implements ControllerResolverInterface return sprintf('Class "%s" does not exist.', $controller); } - $className = \is_object($controller) ? \get_class($controller) : $controller; + $className = \is_object($controller) ? get_debug_type($controller) : $controller; if (method_exists($controller, $method)) { return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 9585c130f0..b92518d806 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -400,7 +400,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter $r = new \ReflectionMethod($controller[0], $controller[1]); return [ - 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFileName(), 'line' => $r->getStartLine(), @@ -409,7 +409,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter if (\is_callable($controller)) { // using __call or __callStatic return [ - 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => 'n/a', 'line' => 'n/a', diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 3aa197b767..680703a75b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -218,8 +218,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl public function getBundle(string $name) { if (!isset($this->bundles[$name])) { - $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $class = get_debug_type($this); throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, $class)); } @@ -394,7 +393,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl protected function getContainerClass() { $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; + $class = false !== strpos($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 4f2601134c..e60792f689 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -22,6 +22,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.15", "psr/log": "~1.0" }, "require-dev": { diff --git a/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php index 9ec42753e0..180d477edc 100644 --- a/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php @@ -20,6 +20,6 @@ class UnexpectedTypeException extends InvalidArgumentException { public function __construct($value, string $expectedType) { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value))); + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value))); } } diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index ecde1acba2..5be303b01c 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -25,7 +25,8 @@ ], "require": { "php": "^7.2.5", - "symfony/polyfill-intl-icu": "~1.0" + "symfony/polyfill-intl-icu": "~1.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/filesystem": "^4.4|^5.0" diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php index c09b1b8e10..ca3e5decd9 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php @@ -38,7 +38,7 @@ class UpdateOperation throw new UpdateOperationException(sprintf('"%s" is not a valid modification type.', $operationType)); } if (LDAP_MODIFY_BATCH_REMOVE_ALL === $operationType && null !== $values) { - throw new UpdateOperationException(sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', \gettype($values))); + throw new UpdateOperationException(sprintf('$values must be null for LDAP_MODIFY_BATCH_REMOVE_ALL operation, "%s" given.', get_debug_type($values))); } $this->operationType = $operationType; diff --git a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php index e8965c070b..28bd1d4c68 100644 --- a/src/Symfony/Component/Ldap/Security/LdapUserProvider.php +++ b/src/Symfony/Component/Ldap/Security/LdapUserProvider.php @@ -105,7 +105,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa public function refreshUser(UserInterface $user) { if (!$user instanceof LdapUser) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles()); @@ -117,7 +117,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa public function upgradePassword(UserInterface $user, string $newEncodedPassword): void { if (!$user instanceof LdapUser) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } if (null === $this->passwordAttribute) { diff --git a/src/Symfony/Component/Ldap/composer.json b/src/Symfony/Component/Ldap/composer.json index 1642386e70..c578ad6973 100644 --- a/src/Symfony/Component/Ldap/composer.json +++ b/src/Symfony/Component/Ldap/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "symfony/options-resolver": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15", "ext-ldap": "*" }, "require-dev": { diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index c9cd036a5b..673238a9fb 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -70,7 +70,7 @@ final class Lock implements LockInterface, LoggerAwareInterface try { if ($blocking) { if (!$this->store instanceof BlockingStoreInterface) { - throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store))); + throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', get_debug_type($this->store))); } $this->store->waitAndSave($this->key); } else { diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index b261a03e73..19d5bd1a24 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -44,7 +44,7 @@ class CombinedStore implements PersistingStoreInterface, LoggerAwareInterface { foreach ($stores as $store) { if (!$store instanceof PersistingStoreInterface) { - throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, \get_class($store))); + throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, get_debug_type($store))); } } diff --git a/src/Symfony/Component/Lock/Store/MongoDbStore.php b/src/Symfony/Component/Lock/Store/MongoDbStore.php index 50d8a208a5..296c68be10 100644 --- a/src/Symfony/Component/Lock/Store/MongoDbStore.php +++ b/src/Symfony/Component/Lock/Store/MongoDbStore.php @@ -133,7 +133,7 @@ class MongoDbStore implements BlockingStoreInterface $this->uri = $mongo; } else { - throw new InvalidArgumentException(sprintf('"%s()" requires "%s" or "%s" or URI as first argument, "%s" given.', __METHOD__, Collection::class, Client::class, \is_object($mongo) ? \get_class($mongo) : \gettype($mongo))); + throw new InvalidArgumentException(sprintf('"%s()" requires "%s" or "%s" or URI as first argument, "%s" given.', __METHOD__, Collection::class, Client::class, get_debug_type($mongo))); } if ($this->options['gcProbablity'] < 0.0 || $this->options['gcProbablity'] > 1.0) { diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index f3ca669185..437f361d31 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -95,7 +95,7 @@ class PdoStore implements PersistingStoreInterface } elseif (\is_string($connOrDsn)) { $this->dsn = $connOrDsn; } else { - throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, \is_object($connOrDsn) ? \get_class($connOrDsn) : \gettype($connOrDsn))); + throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, get_debug_type($connOrDsn))); } $this->table = $options['db_table'] ?? $this->table; diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 8747308bb2..7c1ac7f157 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -38,7 +38,7 @@ class RedisStore implements PersistingStoreInterface public function __construct($redisClient, float $initialTtl = 300.0) { if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) { - throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($redisClient))); } if ($initialTtl <= 0) { @@ -141,7 +141,7 @@ class RedisStore implements PersistingStoreInterface return $this->redis->eval(...array_merge([$script, 1, $resource], $args)); } - throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis))); + throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($this->redis))); } private function getUniqueToken(Key $key): string diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index 01285eb2da..69b53c792e 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -33,7 +33,7 @@ class StoreFactory public static function createStore($connection) { if (!\is_string($connection) && !\is_object($connection)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, get_debug_type($connection))); } switch (true) { @@ -59,7 +59,7 @@ class StoreFactory return new ZookeeperStore($connection); case !\is_string($connection): - throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection))); + throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection))); case 'flock' === $connection: return new FlockStore(); diff --git a/src/Symfony/Component/Lock/composer.json b/src/Symfony/Component/Lock/composer.json index b76bdd35f8..e038a82e84 100644 --- a/src/Symfony/Component/Lock/composer.json +++ b/src/Symfony/Component/Lock/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": "^7.2.5", - "psr/log": "~1.0" + "psr/log": "~1.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "doctrine/dbal": "~2.5", diff --git a/src/Symfony/Component/Mailer/Envelope.php b/src/Symfony/Component/Mailer/Envelope.php index 266d251609..cdf99d1d2f 100644 --- a/src/Symfony/Component/Mailer/Envelope.php +++ b/src/Symfony/Component/Mailer/Envelope.php @@ -64,7 +64,7 @@ class Envelope $this->recipients = []; foreach ($recipients as $recipient) { if (!$recipient instanceof Address) { - throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, \is_object($recipient) ? \get_class($recipient) : \gettype($recipient))); + throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, get_debug_type($recipient))); } $this->recipients[] = new Address($recipient->getAddress()); } diff --git a/src/Symfony/Component/Mailer/composer.json b/src/Symfony/Component/Mailer/composer.json index e611fbfc98..2f1a36c10f 100644 --- a/src/Symfony/Component/Mailer/composer.json +++ b/src/Symfony/Component/Mailer/composer.json @@ -21,6 +21,7 @@ "psr/log": "~1.0", "symfony/event-dispatcher": "^4.4|^5.0", "symfony/mime": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1|^2" }, "require-dev": { diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index 7c49c2b248..2f0971a609 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -249,7 +249,7 @@ class Connection } if (!is_numeric($arguments[$key])) { - throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", "%s" given.', $key, \gettype($arguments[$key]))); + throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", "%s" given.', $key, get_debug_type($arguments[$key]))); } $arguments[$key] = (int) $arguments[$key]; diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php index efa84f73d1..219550b315 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php @@ -28,7 +28,7 @@ class DoctrineTransportFactory implements TransportFactoryInterface public function __construct($registry) { if (!$registry instanceof RegistryInterface && !$registry instanceof ConnectionRegistry) { - throw new \TypeError(sprintf('Expected an instance of "%s" or "%s", but got "%s".', RegistryInterface::class, ConnectionRegistry::class, \is_object($registry) ? \get_class($registry) : \gettype($registry))); + throw new \TypeError(sprintf('Expected an instance of "%s" or "%s", but got "%s".', RegistryInterface::class, ConnectionRegistry::class, get_debug_type($registry))); } $this->registry = $registry; diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index 5d0c6b178f..116977a3c5 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -102,7 +102,7 @@ class MessengerPass implements CompilerPassInterface $message = $options; $options = []; } else { - throw new RuntimeException(sprintf('The handler configuration needs to return an array of messages or an associated array of message and configuration. Found value of type "%s" at position "%d" for service "%s".', \gettype($options), $message, $serviceId)); + throw new RuntimeException(sprintf('The handler configuration needs to return an array of messages or an associated array of message and configuration. Found value of type "%s" at position "%d" for service "%s".', get_debug_type($options), $message, $serviceId)); } } diff --git a/src/Symfony/Component/Messenger/Envelope.php b/src/Symfony/Component/Messenger/Envelope.php index 94a41d1451..7e2fdfac89 100644 --- a/src/Symfony/Component/Messenger/Envelope.php +++ b/src/Symfony/Component/Messenger/Envelope.php @@ -30,7 +30,7 @@ final class Envelope public function __construct($message, array $stamps = []) { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got "%s".', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got "%s".', __METHOD__, get_debug_type($message))); } $this->message = $message; diff --git a/src/Symfony/Component/Messenger/HandleTrait.php b/src/Symfony/Component/Messenger/HandleTrait.php index 7ba5deb7c0..72ac94ef27 100644 --- a/src/Symfony/Component/Messenger/HandleTrait.php +++ b/src/Symfony/Component/Messenger/HandleTrait.php @@ -37,7 +37,7 @@ trait HandleTrait private function handle($message) { if (!$this->messageBus instanceof MessageBusInterface) { - throw new LogicException(sprintf('You must provide a "%s" instance in the "%s::$messageBus" property, "%s" given.', MessageBusInterface::class, static::class, \is_object($this->messageBus) ? \get_class($this->messageBus) : \gettype($this->messageBus))); + throw new LogicException(sprintf('You must provide a "%s" instance in the "%s::$messageBus" property, "%s" given.', MessageBusInterface::class, static::class, get_debug_type($this->messageBus))); } $envelope = $this->messageBus->dispatch($message); @@ -45,7 +45,7 @@ trait HandleTrait $handledStamps = $envelope->all(HandledStamp::class); if (!$handledStamps) { - throw new LogicException(sprintf('Message of type "%s" was handled zero times. Exactly one handler is expected when using "%s::%s()".', \get_class($envelope->getMessage()), static::class, __FUNCTION__)); + throw new LogicException(sprintf('Message of type "%s" was handled zero times. Exactly one handler is expected when using "%s::%s()".', get_debug_type($envelope->getMessage()), static::class, __FUNCTION__)); } if (\count($handledStamps) > 1) { @@ -53,7 +53,7 @@ trait HandleTrait return sprintf('"%s"', $stamp->getHandlerName()); }, $handledStamps)); - throw new LogicException(sprintf('Message of type "%s" was handled multiple times. Only one handler is expected when using "%s::%s()", got %d: %s.', \get_class($envelope->getMessage()), static::class, __FUNCTION__, \count($handledStamps), $handlers)); + throw new LogicException(sprintf('Message of type "%s" was handled multiple times. Only one handler is expected when using "%s::%s()", got %d: %s.', get_debug_type($envelope->getMessage()), static::class, __FUNCTION__, \count($handledStamps), $handlers)); } return $handledStamps[0]->getResult(); diff --git a/src/Symfony/Component/Messenger/MessageBus.php b/src/Symfony/Component/Messenger/MessageBus.php index d8146070a8..4819b7218a 100644 --- a/src/Symfony/Component/Messenger/MessageBus.php +++ b/src/Symfony/Component/Messenger/MessageBus.php @@ -62,7 +62,7 @@ class MessageBus implements MessageBusInterface public function dispatch($message, array $stamps = []): Envelope { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got "%s".', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got "%s".', __METHOD__, get_debug_type($message))); } $envelope = Envelope::wrap($message, $stamps); $middlewareIterator = $this->middlewareAggregate->getIterator(); diff --git a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php index 42aef7ee12..aeb954c9cc 100644 --- a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php @@ -37,7 +37,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface } elseif ($middlewareIterator instanceof MiddlewareInterface) { $this->stack->stack[] = $middlewareIterator; } elseif (!is_iterable($middlewareIterator)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be iterable of "%s", "%s" given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be iterable of "%s", "%s" given.', __METHOD__, MiddlewareInterface::class, get_debug_type($middlewareIterator))); } else { $this->stack->iterator = (function () use ($middlewareIterator) { yield from $middlewareIterator; diff --git a/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php b/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php index c073ba761e..bedade318f 100644 --- a/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php @@ -78,8 +78,7 @@ class TraceableStack implements StackInterface if ($this->stack === $nextMiddleware = $this->stack->next()) { $this->currentEvent = 'Tail'; } else { - $class = \get_class($nextMiddleware); - $this->currentEvent = sprintf('"%s"', 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class); + $this->currentEvent = sprintf('"%s"', get_debug_type($nextMiddleware)); } $this->currentEvent .= sprintf(' on "%s"', $this->busName); diff --git a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php index 10247cf761..7e07815fbe 100644 --- a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php +++ b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php @@ -15,7 +15,7 @@ class HandleTraitTest extends TestCase public function testItThrowsOnNoMessageBusInstance() { $this->expectException('Symfony\Component\Messenger\Exception\LogicException'); - $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "NULL" given.'); + $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "null" given.'); $queryBus = new TestQueryBus(null); $query = new DummyMessage('Hello'); diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index ec32dc1bab..6f42d71383 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -21,6 +21,7 @@ "symfony/amqp-messenger": "^5.1", "symfony/deprecation-contracts": "^2.1", "symfony/doctrine-messenger": "^5.1", + "symfony/polyfill-php80": "^1.15", "symfony/redis-messenger": "^5.1" }, "require-dev": { diff --git a/src/Symfony/Component/Mime/Address.php b/src/Symfony/Component/Mime/Address.php index b0dcbd0880..6d663e93b7 100644 --- a/src/Symfony/Component/Mime/Address.php +++ b/src/Symfony/Component/Mime/Address.php @@ -92,7 +92,7 @@ final class Address return new self($address); } - throw new InvalidArgumentException(sprintf('An address can be an instance of Address or a string ("%s") given).', \is_object($address) ? \get_class($address) : \gettype($address))); + throw new InvalidArgumentException(sprintf('An address can be an instance of Address or a string ("%s") given).', get_debug_type($address))); } /** diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index 9de506e36e..57c99c41fc 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -150,7 +150,7 @@ final class Headers $name = strtolower($header->getName()); if (isset($map[$name]) && !$header instanceof $map[$name]) { - throw new LogicException(sprintf('The "%s" header must be an instance of "%s" (got "%s").', $header->getName(), $map[$name], \get_class($header))); + throw new LogicException(sprintf('The "%s" header must be an instance of "%s" (got "%s").', $header->getName(), $map[$name], get_debug_type($header))); } if (\in_array($name, self::$uniqueHeaders, true) && isset($this->headers[$name]) && \count($this->headers[$name]) > 0) { diff --git a/src/Symfony/Component/Mime/MessageConverter.php b/src/Symfony/Component/Mime/MessageConverter.php index a810cb704a..788a5ff996 100644 --- a/src/Symfony/Component/Mime/MessageConverter.php +++ b/src/Symfony/Component/Mime/MessageConverter.php @@ -55,13 +55,13 @@ final class MessageConverter } elseif ($parts[0] instanceof TextPart) { $email = self::createEmailFromTextPart($message, $parts[0]); } else { - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($message))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($message))); } return self::attachParts($email, \array_slice($parts, 1)); } - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($message))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($message))); } private static function createEmailFromTextPart(Message $message, TextPart $part): Email @@ -73,7 +73,7 @@ final class MessageConverter return (new Email(clone $message->getHeaders()))->html($part->getBody(), $part->getPreparedHeaders()->getHeaderParameter('Content-Type', 'charset') ?: 'utf-8'); } - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($message))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($message))); } private static function createEmailFromAlternativePart(Message $message, AlternativePart $part): Email @@ -90,7 +90,7 @@ final class MessageConverter ; } - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($message))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($message))); } private static function createEmailFromRelatedPart(Message $message, RelatedPart $part): Email @@ -101,7 +101,7 @@ final class MessageConverter } elseif ($parts[0] instanceof TextPart) { $email = self::createEmailFromTextPart($message, $parts[0]); } else { - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($message))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($message))); } return self::attachParts($email, \array_slice($parts, 1)); @@ -111,7 +111,7 @@ final class MessageConverter { foreach ($parts as $part) { if (!$part instanceof DataPart) { - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', \get_class($email))); + throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as the body is too complex.', get_debug_type($email))); } $headers = $part->getPreparedHeaders(); diff --git a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php index 6838620325..76c48e46f7 100644 --- a/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php +++ b/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php @@ -34,7 +34,7 @@ final class FormDataPart extends AbstractMultipartPart foreach ($fields as $name => $value) { if (!\is_string($value) && !\is_array($value) && !$value instanceof TextPart) { - throw new InvalidArgumentException(sprintf('A form field value can only be a string, an array, or an instance of TextPart ("%s" given).', \is_object($value) ? \get_class($value) : \gettype($value))); + throw new InvalidArgumentException(sprintf('A form field value can only be a string, an array, or an instance of TextPart ("%s" given).', get_debug_type($value))); } $this->fields[$name] = $value; diff --git a/src/Symfony/Component/Mime/Part/SMimePart.php b/src/Symfony/Component/Mime/Part/SMimePart.php index 1dfc1aef03..2a6fe3d997 100644 --- a/src/Symfony/Component/Mime/Part/SMimePart.php +++ b/src/Symfony/Component/Mime/Part/SMimePart.php @@ -31,7 +31,7 @@ class SMimePart extends AbstractPart parent::__construct(); if (!\is_string($body) && !is_iterable($body)) { - throw new \TypeError(sprintf('The body of "%s" must be a string or a iterable (got "%s").', self::class, \is_object($body) ? \get_class($body) : \gettype($body))); + throw new \TypeError(sprintf('The body of "%s" must be a string or a iterable (got "%s").', self::class, get_debug_type($body))); } $this->body = $body; diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index a41d91ddec..988bf23cf7 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -40,7 +40,7 @@ class TextPart extends AbstractPart parent::__construct(); if (!\is_string($body) && !\is_resource($body)) { - throw new \TypeError(sprintf('The body of "%s" must be a string or a resource (got "%s").', self::class, \is_object($body) ? \get_class($body) : \gettype($body))); + throw new \TypeError(sprintf('The body of "%s" must be a string or a resource (got "%s").', self::class, get_debug_type($body))); } $this->body = $body; diff --git a/src/Symfony/Component/Mime/composer.json b/src/Symfony/Component/Mime/composer.json index e2f387adbc..dbe77ed244 100644 --- a/src/Symfony/Component/Mime/composer.json +++ b/src/Symfony/Component/Mime/composer.json @@ -18,7 +18,8 @@ "require": { "php": "^7.2.5", "symfony/polyfill-intl-idn": "^1.10", - "symfony/polyfill-mbstring": "^1.0" + "symfony/polyfill-mbstring": "^1.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "egulias/email-validator": "^2.1.10", diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php b/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php index 98f8721ef1..5a3509c63e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php @@ -53,7 +53,7 @@ final class FirebaseTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php index 123abe8348..dae3e5ac5b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php @@ -53,7 +53,7 @@ final class MattermostTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s/api/v4/post', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php index ae46ffbea2..8a7f80b3ac 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php @@ -54,7 +54,7 @@ final class NexmoTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); } $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [ diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php index 9954144bf6..357fa59a32 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php @@ -56,7 +56,7 @@ final class OvhCloudTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s/1.0/sms/%s/jobs', $this->getEndpoint(), $this->serviceName); diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php index f3fd43f661..151912b24b 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php @@ -58,7 +58,7 @@ final class RocketChatTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); } if ($message->getOptions() && !$message->getOptions() instanceof RocketChatOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, RocketChatOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php b/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php index 20f3706926..51e94a5df2 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php @@ -54,7 +54,7 @@ final class SinchTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s/xms/v1/%s/batches', $this->getEndpoint(), $this->accountSid); diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php index fb18f7c913..cdf199ab62 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php @@ -58,7 +58,7 @@ final class SlackTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); } if ($message->getOptions() && !$message->getOptions() instanceof SlackOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, SlackOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php index 4f9cb3b374..8367f9bde6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php @@ -63,7 +63,7 @@ final class TelegramTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s/bot%s/sendMessage', $this->getEndpoint(), $this->token); diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json index 0b6f8126d1..f6e1114495 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.0" + "symfony/notifier": "^5.1" }, "require-dev": { "symfony/event-dispatcher": "^4.3|^5.0" diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php b/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php index 79131282ac..2e2c64508e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php @@ -54,7 +54,7 @@ final class TwilioTransport extends AbstractTransport protected function doSend(MessageInterface $message): void { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); } $endpoint = sprintf('https://%s/2010-04-01/Accounts/%s/Messages.json', $this->getEndpoint(), $this->accountSid); diff --git a/src/Symfony/Component/Notifier/Channel/EmailChannel.php b/src/Symfony/Component/Notifier/Channel/EmailChannel.php index f00c52726c..45add9fc33 100644 --- a/src/Symfony/Component/Notifier/Channel/EmailChannel.php +++ b/src/Symfony/Component/Notifier/Channel/EmailChannel.php @@ -58,7 +58,7 @@ class EmailChannel implements ChannelInterface if ($email instanceof Email) { if (!$email->getFrom()) { if (null === $this->from) { - throw new LogicException(sprintf('To send the "%s" notification by email, you should either configure a global "from" or set it in the "asEmailMessage()" method.', \get_class($notification))); + throw new LogicException(sprintf('To send the "%s" notification by email, you should either configure a global "from" or set it in the "asEmailMessage()" method.', get_debug_type($notification))); } $email->from($this->from); diff --git a/src/Symfony/Component/Notifier/Message/SmsMessage.php b/src/Symfony/Component/Notifier/Message/SmsMessage.php index 571bbcb9ad..137c6c5db0 100644 --- a/src/Symfony/Component/Notifier/Message/SmsMessage.php +++ b/src/Symfony/Component/Notifier/Message/SmsMessage.php @@ -37,7 +37,7 @@ final class SmsMessage implements MessageInterface public static function fromNotification(Notification $notification, Recipient $recipient): self { if (!$recipient instanceof SmsRecipientInterface) { - throw new LogicException(sprintf('To send a SMS message, "%s" should implement "%s" or the recipient should implement "%s".', \get_class($notification), SmsNotificationInterface::class, SmsRecipientInterface::class)); + throw new LogicException(sprintf('To send a SMS message, "%s" should implement "%s" or the recipient should implement "%s".', get_debug_type($notification), SmsNotificationInterface::class, SmsRecipientInterface::class)); } return new self($recipient->getPhone(), $notification->getSubject()); diff --git a/src/Symfony/Component/Notifier/composer.json b/src/Symfony/Component/Notifier/composer.json index 3b3a0a1c34..bb27fe516e 100644 --- a/src/Symfony/Component/Notifier/composer.json +++ b/src/Symfony/Component/Notifier/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": "^7.2.5" + "php": "^7.2.5", + "symfony/polyfill-php80": "^1.15" }, "conflict": { "symfony/http-kernel": "<4.4" diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 247f7415c8..9a0e616e39 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -434,7 +434,7 @@ class OptionsResolver implements Options } if (!\is_string($deprecationMessage) && !$deprecationMessage instanceof \Closure) { - throw new InvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', \gettype($deprecationMessage))); + throw new InvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', get_debug_type($deprecationMessage))); } // ignore if empty string @@ -929,7 +929,7 @@ class OptionsResolver implements Options } if (!\is_array($value)) { - throw new InvalidOptionsException(sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), $this->formatTypeOf($value))); + throw new InvalidOptionsException(sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), get_debug_type($value))); } // The following section must be protected from cyclic calls. @@ -1059,7 +1059,7 @@ class OptionsResolver implements Options $this->calling[$option] = true; try { if (!\is_string($deprecationMessage = $deprecationMessage($this, $value))) { - throw new InvalidOptionsException(sprintf('Invalid type for deprecation message, expected string but got "%s", return an empty string to ignore.', \gettype($deprecationMessage))); + throw new InvalidOptionsException(sprintf('Invalid type for deprecation message, expected string but got "%s", return an empty string to ignore.', get_debug_type($deprecationMessage))); } } finally { unset($this->calling[$option]); @@ -1120,7 +1120,7 @@ class OptionsResolver implements Options } if (!$invalidTypes || $level > 0) { - $invalidTypes[$this->formatTypeOf($value)] = true; + $invalidTypes[get_debug_type($value)] = true; } return false; @@ -1186,18 +1186,6 @@ class OptionsResolver implements Options return \count($this->defaults); } - /** - * Returns a string representation of the type of the value. - * - * @param mixed $value The value to return the type of - * - * @return string The type of the value - */ - private function formatTypeOf($value): string - { - return \is_object($value) ? \get_class($value) : \gettype($value); - } - /** * Returns a string representation of the value. * diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 339fae6877..2b22adb6cb 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -460,7 +460,7 @@ class OptionsResolverTest extends TestCase public function testSetDeprecatedFailsIfInvalidDeprecationMessageType() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "boolean".'); + $this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "bool".'); $this->resolver ->setDefined('foo') ->setDeprecated('foo', true) @@ -470,7 +470,7 @@ class OptionsResolverTest extends TestCase public function testLazyDeprecationFailsIfInvalidDeprecationMessageType() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "boolean", return an empty string to ignore.'); + $this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "bool", return an empty string to ignore.'); $this->resolver ->setDefined('foo') ->setDeprecated('foo', function (Options $options, $value) { @@ -814,7 +814,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsWithCorrectLevelsButWrongScalar() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "double".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "float".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); @@ -842,18 +842,18 @@ class OptionsResolverTest extends TestCase public function provideInvalidTypes() { return [ - [true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'], - [false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'], - [fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'], + [true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "bool".'], + [false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "bool".'], + [fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource (stream)".'], [[], 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'], [new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'], - [42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'], - [null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'], + [42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "int".'], + [null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "null".'], ['bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'], - [['foo', 12], 'string[]', 'The option "option" with value array is expected to be of type "string[]", but one of the elements is of type "integer".'], - [123, ['string[]', 'string'], 'The option "option" with value 123 is expected to be of type "string[]" or "string", but is of type "integer".'], - [[null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "NULL".'], - [['string', null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "NULL".'], + [['foo', 12], 'string[]', 'The option "option" with value array is expected to be of type "string[]", but one of the elements is of type "int".'], + [123, ['string[]', 'string'], 'The option "option" with value 123 is expected to be of type "string[]" or "string", but is of type "int".'], + [[null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "null".'], + [['string', null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "null".'], [[\stdClass::class], ['string'], 'The option "option" with value array is expected to be of type "string", but is of type "array".'], ]; } @@ -869,7 +869,7 @@ class OptionsResolverTest extends TestCase public function testResolveFailsIfInvalidTypeMultiple() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer".'); + $this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "int".'); $this->resolver->setDefault('foo', 42); $this->resolver->setAllowedTypes('foo', ['string', 'bool']); @@ -1906,7 +1906,7 @@ class OptionsResolverTest extends TestCase public function testNestedArraysException() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "int".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'float[][][][]'); @@ -1924,7 +1924,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException1() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); $this->resolver->resolve([ @@ -1937,7 +1937,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException2() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean|string|array".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "bool|string|array".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); $this->resolver->resolve([ @@ -1950,7 +1950,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException3() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|integer".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string|int".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'string[][][]'); $this->resolver->resolve([ @@ -1963,7 +1963,7 @@ class OptionsResolverTest extends TestCase public function testNestedArrayException4() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer".'); + $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "int".'); $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'string[][][]'); $this->resolver->resolve([ @@ -2031,7 +2031,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfInvalidTypeNestedOption() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The option "database[logging]" with value null is expected to be of type "bool", but is of type "NULL".'); + $this->expectExceptionMessage('The option "database[logging]" with value null is expected to be of type "bool", but is of type "null".'); $this->resolver->setDefaults([ 'name' => 'default', 'database' => function (OptionsResolver $resolver) { @@ -2048,7 +2048,7 @@ class OptionsResolverTest extends TestCase public function testFailsIfNotArrayIsGivenForNestedOptions() { $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "NULL".'); + $this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "null".'); $this->resolver->setDefaults([ 'name' => 'default', 'database' => function (OptionsResolver $resolver) { diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index 31fb6a91ba..4a580cb386 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": "^7.2.5", - "symfony/deprecation-contracts": "^2.1" + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15" }, "autoload": { "psr-4": { "Symfony\\Component\\OptionsResolver\\": "" }, diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index 92076efb53..83dc262519 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -103,7 +103,7 @@ abstract class AbstractPipes implements PipesInterface } elseif (!isset($this->inputBuffer[0])) { if (!\is_string($input)) { if (!is_scalar($input)) { - throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported.', \get_class($this->input), \gettype($input))); + throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported.', get_debug_type($this->input), get_debug_type($input))); } $input = (string) $input; } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 79c657a968..fa703a0bff 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": "^7.2.5" + "php": "^7.2.5", + "symfony/polyfill-php80": "^1.15" }, "autoload": { "psr-4": { "Symfony\\Component\\Process\\": "" }, diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 0243c9b02c..cbe81bdeb5 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -349,7 +349,7 @@ class PropertyAccessor implements PropertyAccessorInterface private function readIndex(array $zval, $index): array { if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) { - throw new NoSuchIndexException(sprintf('Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, \get_class($zval[self::VALUE]))); + throw new NoSuchIndexException(sprintf('Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, get_debug_type($zval[self::VALUE]))); } $result = self::$resultProto; @@ -457,7 +457,7 @@ class PropertyAccessor implements PropertyAccessorInterface private function writeIndex(array $zval, $index, $value) { if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) { - throw new NoSuchIndexException(sprintf('Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, \get_class($zval[self::VALUE]))); + throw new NoSuchIndexException(sprintf('Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess.', $index, get_debug_type($zval[self::VALUE]))); } $zval[self::REF][$index] = $value; @@ -497,7 +497,7 @@ class PropertyAccessor implements PropertyAccessorInterface throw new NoSuchPropertyException(implode('. ', $mutator->getErrors()).'.'); } - throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $property, \get_class($object))); + throw new NoSuchPropertyException(sprintf('Could not determine access type for property "%s" in class "%s".', $property, get_debug_type($object))); } } diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index 9f713ef664..0b4ef88637 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -77,7 +77,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface return; } if (!\is_string($propertyPath)) { - throw new InvalidArgumentException(sprintf('The property path constructor needs a string or an instance of "Symfony\Component\PropertyAccess\PropertyPath". Got: "%s".', \is_object($propertyPath) ? \get_class($propertyPath) : \gettype($propertyPath))); + throw new InvalidArgumentException(sprintf('The property path constructor needs a string or an instance of "Symfony\Component\PropertyAccess\PropertyPath". Got: "%s".', get_debug_type($propertyPath))); } if ('' === $propertyPath) { diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 411f8121d5..0a91fdda12 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "symfony/inflector": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15", "symfony/property-info": "^5.1" }, "require-dev": { diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php index 09daf83f75..0f5a3e16ea 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php @@ -100,7 +100,7 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti private function assertIsString($string) { if (!\is_string($string)) { - throw new \InvalidArgumentException(sprintf('"%s" expects strings, given "%s".', __CLASS__, \gettype($string))); + throw new \InvalidArgumentException(sprintf('"%s" expects strings, given "%s".', __CLASS__, get_debug_type($string))); } } } diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index a1b21c6741..08333ad63e 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -24,7 +24,8 @@ ], "require": { "php": "^7.2.5", - "symfony/inflector": "^4.4|^5.0" + "symfony/inflector": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/serializer": "^4.4|^5.0", diff --git a/src/Symfony/Component/Routing/Loader/ObjectLoader.php b/src/Symfony/Component/Routing/Loader/ObjectLoader.php index 963ddf9ada..d6ec1a7277 100644 --- a/src/Symfony/Component/Routing/Loader/ObjectLoader.php +++ b/src/Symfony/Component/Routing/Loader/ObjectLoader.php @@ -52,19 +52,19 @@ abstract class ObjectLoader extends Loader $loaderObject = $this->getObject($parts[0]); if (!\is_object($loaderObject)) { - throw new \TypeError(sprintf('"%s:getObject()" must return an object: "%s" returned.', static::class, \gettype($loaderObject))); + throw new \TypeError(sprintf('"%s:getObject()" must return an object: "%s" returned.', static::class, get_debug_type($loaderObject))); } if (!\is_callable([$loaderObject, $method])) { - throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s".', $method, \get_class($loaderObject), $resource)); + throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s".', $method, get_debug_type($loaderObject), $resource)); } $routeCollection = $loaderObject->$method($this); if (!$routeCollection instanceof RouteCollection) { - $type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection); + $type = get_debug_type($routeCollection); - throw new \LogicException(sprintf('The "%s::%s()" method must return a RouteCollection: "%s" returned.', \get_class($loaderObject), $method, $type)); + throw new \LogicException(sprintf('The "%s::%s()" method must return a RouteCollection: "%s" returned.', get_debug_type($loaderObject), $method, $type)); } // make the object file tracked so that if it changes, the cache rebuilds diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 32861e37f6..febdb14ae8 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": "^7.2.5", - "symfony/deprecation-contracts": "^2.1" + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/config": "^5.0", diff --git a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php index 0c0a206293..a0c95ab812 100644 --- a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php +++ b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php @@ -65,7 +65,7 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface foreach ($this->providers as $provider) { if (!$provider instanceof AuthenticationProviderInterface) { - throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', \get_class($provider))); + throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', get_debug_type($provider))); } if (!$provider->supports($token)) { diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php index 670390e446..9a688adce5 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php @@ -52,7 +52,7 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac $user = $token->getUser(); if (!$token->getUser() instanceof UserInterface) { - throw new LogicException(sprintf('Method "%s::getUser()" must return a "%s" instance, "%s" returned.', \get_class($token), UserInterface::class, \is_object($user) ? \get_class($user) : \gettype($user))); + throw new LogicException(sprintf('Method "%s::getUser()" must return a "%s" instance, "%s" returned.', get_debug_type($token), UserInterface::class, get_debug_type($user))); } $this->userChecker->checkPreAuth($user); diff --git a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php index cad50180d1..06bc591e6e 100644 --- a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php +++ b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php @@ -50,7 +50,7 @@ class EncoderFactory implements EncoderFactoryInterface } if (null === $encoderKey) { - throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? \get_class($user) : $user)); + throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? get_debug_type($user) : $user)); } if (!$this->encoders[$encoderKey] instanceof PasswordEncoderInterface) { diff --git a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php index af5a0ebb0c..233212508b 100644 --- a/src/Symfony/Component/Security/Core/User/ChainUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/ChainUserProvider.php @@ -91,7 +91,7 @@ class ChainUserProvider implements UserProviderInterface, PasswordUpgraderInterf $e->setUsername($user->getUsername()); throw $e; } else { - throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', \get_class($user))); + throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', get_debug_type($user))); } } diff --git a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php index 71bdec54a8..8d084cd575 100644 --- a/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php @@ -74,7 +74,7 @@ class InMemoryUserProvider implements UserProviderInterface public function refreshUser(UserInterface $user) { if (!$user instanceof User) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user))); } $storedUser = $this->getUser($user->getUsername()); diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index c8bfb07d05..fc500b285f 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "symfony/event-dispatcher-contracts": "^1.1|^2", + "symfony/polyfill-php80": "^1.15", "symfony/service-contracts": "^1.1.6|^2", "symfony/deprecation-contracts": "^2.1" }, diff --git a/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php b/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php index 6a28fea63b..da28302b78 100644 --- a/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php +++ b/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php @@ -59,7 +59,7 @@ class CsrfTokenManager implements CsrfTokenManagerInterface } elseif (\is_callable($namespace) || \is_string($namespace)) { $this->namespace = $namespace; } else { - throw new InvalidArgumentException(sprintf('$namespace must be a string, a callable returning a string, null or an instance of "RequestStack". "%s" given.', \gettype($namespace))); + throw new InvalidArgumentException(sprintf('$namespace must be a string, a callable returning a string, null or an instance of "RequestStack". "%s" given.', get_debug_type($namespace))); } } diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 3846455e44..9e0cbd7574 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -134,7 +134,7 @@ class GuardAuthenticationListener extends AbstractListener $credentials = $guardAuthenticator->getCredentials($request); if (null === $credentials) { - throw new \UnexpectedValueException(sprintf('The return value of "%1$s::getCredentials()" must not be null. Return false from "%1$s::supports()" instead.', \get_class($guardAuthenticator))); + throw new \UnexpectedValueException(sprintf('The return value of "%1$s::getCredentials()" must not be null. Return false from "%1$s::supports()" instead.', get_debug_type($guardAuthenticator))); } // create a token with the unique key, so that the provider knows which authenticator to use @@ -218,7 +218,7 @@ class GuardAuthenticationListener extends AbstractListener } if (!$response instanceof Response) { - throw new \LogicException(sprintf('%s::onAuthenticationSuccess *must* return a Response if you want to use the remember me functionality. Return a Response, or set remember_me to false under the guard configuration.', \get_class($guardAuthenticator))); + throw new \LogicException(sprintf('%s::onAuthenticationSuccess *must* return a Response if you want to use the remember me functionality. Return a Response, or set remember_me to false under the guard configuration.', get_debug_type($guardAuthenticator))); } $this->rememberMeServices->loginSuccess($request, $response, $token); diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php index e5b9cfb0b7..b4c59d5181 100644 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php +++ b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php @@ -75,7 +75,7 @@ class GuardAuthenticatorHandler return $response; } - throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); + throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), get_debug_type($response))); } /** @@ -105,7 +105,7 @@ class GuardAuthenticatorHandler return $response; } - throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); + throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), get_debug_type($response))); } /** diff --git a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php index 09e16a9fa4..92f3fd6540 100644 --- a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php @@ -105,20 +105,20 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface $user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider); if (null === $user) { - throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator))); + throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', get_debug_type($guardAuthenticator))); } if (!$user instanceof UserInterface) { - throw new \UnexpectedValueException(sprintf('The "%s::getUser()" method must return a UserInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($user) ? \get_class($user) : \gettype($user))); + throw new \UnexpectedValueException(sprintf('The "%s::getUser()" method must return a UserInterface. You returned "%s".', get_debug_type($guardAuthenticator), get_debug_type($user))); } $this->userChecker->checkPreAuth($user); if (true !== $checkCredentialsResult = $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) { if (false !== $checkCredentialsResult) { - throw new \TypeError(sprintf('%s::checkCredentials() must return a boolean value.', \get_class($guardAuthenticator))); + throw new \TypeError(sprintf('%s::checkCredentials() must return a boolean value.', get_debug_type($guardAuthenticator))); } - throw new BadCredentialsException(sprintf('Authentication failed because "%s::checkCredentials()" did not return true.', \get_class($guardAuthenticator))); + throw new BadCredentialsException(sprintf('Authentication failed because "%s::checkCredentials()" did not return true.', get_debug_type($guardAuthenticator))); } if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordEncoder && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && method_exists($this->passwordEncoder, 'needsRehash') && $this->passwordEncoder->needsRehash($user)) { $this->userProvider->upgradePassword($user, $this->passwordEncoder->encodePassword($user, $password)); @@ -128,7 +128,7 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface // turn the UserInterface into a TokenInterface $authenticatedToken = $guardAuthenticator->createAuthenticatedToken($user, $this->providerKey); if (!$authenticatedToken instanceof TokenInterface) { - throw new \UnexpectedValueException(sprintf('The "%s::createAuthenticatedToken()" method must return a TokenInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($authenticatedToken) ? \get_class($authenticatedToken) : \gettype($authenticatedToken))); + throw new \UnexpectedValueException(sprintf('The "%s::createAuthenticatedToken()" method must return a TokenInterface. You returned "%s".', get_debug_type($guardAuthenticator), get_debug_type($authenticatedToken))); } return $authenticatedToken; diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index 86540f33e9..1b2337f829 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -18,7 +18,8 @@ "require": { "php": "^7.2.5", "symfony/security-core": "^5.0", - "symfony/security-http": "^4.4.1|^5.0.1" + "symfony/security-http": "^4.4.1|^5.0.1", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "psr/log": "~1.0" diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 6e89088197..6c23769f82 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -201,7 +201,7 @@ class ContextListener extends AbstractListener foreach ($this->userProviders as $provider) { if (!$provider instanceof UserProviderInterface) { - throw new \InvalidArgumentException(sprintf('User provider "%s" must implement "%s".', \get_class($provider), UserProviderInterface::class)); + throw new \InvalidArgumentException(sprintf('User provider "%s" must implement "%s".', get_debug_type($provider), UserProviderInterface::class)); } if (!$provider->supportsClass($userClass)) { diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index b2deb42f08..678de4c34d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -214,9 +214,9 @@ class ExceptionListener $response = $this->authenticationEntryPoint->start($request, $authException); if (!$response instanceof Response) { - $given = \is_object($response) ? \get_class($response) : \gettype($response); + $given = get_debug_type($response); - throw new \LogicException(sprintf('The "%s::start()" method must return a Response object ("%s" returned).', \get_class($this->authenticationEntryPoint), $given)); + throw new \LogicException(sprintf('The "%s::start()" method must return a Response object ("%s" returned).', get_debug_type($this->authenticationEntryPoint), $given)); } return $response; diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index b3661eae8a..7e69f33c8f 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -86,7 +86,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL } if (!\is_string($username) && (!\is_object($username) || !method_exists($username, '__toString'))) { - throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); + throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], get_debug_type($username))); } $username = trim($username); diff --git a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php index 33427517ca..a670045ac4 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php @@ -50,7 +50,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices } if (!$user instanceof UserInterface) { - throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', \get_class($user))); + throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', get_debug_type($user))); } if (true !== hash_equals($this->generateCookieHash($class, $username, $expires, $user->getPassword()), $hash)) { diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index b978777084..90adbf90db 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -110,7 +110,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase public function testHandleNonStringUsernameWithInt($postOnly) { $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); - $this->expectExceptionMessage('The key "_username" must be a string, "integer" given.'); + $this->expectExceptionMessage('The key "_username" must be a string, "int" given.'); $request = Request::create('/login_check', 'POST', ['_username' => 42]); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( @@ -133,7 +133,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase public function testHandleNonStringUsernameWithObject($postOnly) { $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); - $this->expectExceptionMessage('The key "_username" must be a string, "object" given.'); + $this->expectExceptionMessage('The key "_username" must be a string, "stdClass" given.'); $request = Request::create('/login_check', 'POST', ['_username' => new \stdClass()]); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 52b59d083d..c4862c1dbc 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -20,6 +20,7 @@ "symfony/security-core": "^4.4|^5.0", "symfony/http-foundation": "^4.4|^5.0", "symfony/http-kernel": "^4.4|^5.0", + "symfony/polyfill-php80": "^1.15", "symfony/property-access": "^4.4|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index 183e02fce1..523bbdaa47 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -241,7 +241,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface $asCollection = $context[self::AS_COLLECTION_KEY] ?? $this->defaultContext[self::AS_COLLECTION_KEY]; if (!\is_array($headers)) { - throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, \gettype($headers))); + throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, get_debug_type($headers))); } return [$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas, $outputBom, $asCollection]; diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php index e5698d777d..0a65da5d53 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php @@ -40,7 +40,7 @@ trait ClassResolverTrait } if (!\is_object($value)) { - throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s".', \gettype($value))); + throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s".', get_debug_type($value))); } return \get_class($value); diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php b/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php index f422f11c7d..aa428a3bdd 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php @@ -40,7 +40,7 @@ class LoaderChain implements LoaderInterface { foreach ($loaders as $loader) { if (!$loader instanceof LoaderInterface) { - throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader))); + throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', get_debug_type($loader))); } } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index c5d8b727e2..5d30cb7beb 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -213,7 +213,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn return $circularReferenceHandler($object, $format, $context); } - throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d).', \get_class($object), $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT])); + throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d).', get_debug_type($object), $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT])); } /** diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 0acc28de71..f0ab9af988 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -442,7 +442,7 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer return $data; } - throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be one of "%s" ("%s" given).', $attribute, $currentClass, implode('", "', array_keys($expectedTypes)), \gettype($data))); + throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be one of "%s" ("%s" given).', $attribute, $currentClass, implode('", "', array_keys($expectedTypes)), get_debug_type($data))); } /** diff --git a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php index e1359053da..3389227738 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php @@ -42,7 +42,7 @@ class ArrayDenormalizer implements ContextAwareDenormalizerInterface, Serializer throw new BadMethodCallException('Please set a serializer before calling denormalize()!'); } if (!\is_array($data)) { - throw new InvalidArgumentException('Data expected to be an array, '.\gettype($data).' given.'); + throw new InvalidArgumentException('Data expected to be an array, '.get_debug_type($data).' given.'); } if ('[]' !== substr($type, -2)) { throw new InvalidArgumentException('Unsupported class: '.$type); @@ -54,7 +54,7 @@ class ArrayDenormalizer implements ContextAwareDenormalizerInterface, Serializer $builtinType = isset($context['key_type']) ? $context['key_type']->getBuiltinType() : null; foreach ($data as $key => $value) { if (null !== $builtinType && !('is_'.$builtinType)($key)) { - throw new NotNormalizableValueException(sprintf('The type of the key "%s" must be "%s" ("%s" given).', $key, $builtinType, \gettype($key))); + throw new NotNormalizableValueException(sprintf('The type of the key "%s" must be "%s" ("%s" given).', $key, $builtinType, get_debug_type($key))); } $data[$key] = $serializer->denormalize($value, $type, $format, $context); diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index 2f7d59a7ef..de028b3434 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -72,7 +72,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa public function denormalize($data, string $type, string $format = null, array $context = []) { if (!\is_string($data)) { - throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.', \gettype($data))); + throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.', get_debug_type($data))); } if (!$this->isISO8601($data)) { diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 302b0a53ef..bd481bf23e 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -87,7 +87,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface } if (!($normalizer instanceof NormalizerInterface || $normalizer instanceof DenormalizerInterface)) { - throw new InvalidArgumentException(sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class)); + throw new InvalidArgumentException(sprintf('The class "%s" neither implements "%s" nor "%s".', get_debug_type($normalizer), NormalizerInterface::class, DenormalizerInterface::class)); } } $this->normalizers = $normalizers; @@ -106,7 +106,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface } if (!($encoder instanceof EncoderInterface || $encoder instanceof DecoderInterface)) { - throw new InvalidArgumentException(sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($encoder), EncoderInterface::class, DecoderInterface::class)); + throw new InvalidArgumentException(sprintf('The class "%s" neither implements "%s" nor "%s".', get_debug_type($encoder), EncoderInterface::class, DecoderInterface::class)); } } $this->encoder = new ChainEncoder($realEncoders); @@ -171,7 +171,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface throw new LogicException('You must register at least one normalizer to be able to normalize objects.'); } - throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', \get_class($data))); + throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', get_debug_type($data))); } throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data)))); @@ -186,7 +186,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface { if (isset(self::SCALAR_TYPES[$type])) { if (!('is_'.$type)($data)) { - throw new NotNormalizableValueException(sprintf('Data expected to be of type "%s" ("%s" given).', $type, \is_object($data) ? \get_class($data) : \gettype($data))); + throw new NotNormalizableValueException(sprintf('Data expected to be of type "%s" ("%s" given).', $type, get_debug_type($data))); } return $data; diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 086b3766ca..79a6b02302 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": "^7.2.5", - "symfony/polyfill-ctype": "~1.8" + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "doctrine/annotations": "~1.0", diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index 22fd212d58..9b9c667cfb 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -28,7 +28,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromCallable($callback, ...$arguments): self { if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, \gettype($callback))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, get_debug_type($callback))); } $lazyString = new static(); @@ -57,7 +57,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromStringable($value): self { if (!self::isStringable($value)) { - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, \is_object($value) ? \get_class($value) : \gettype($value))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, get_debug_type($value))); } if (\is_object($value)) { @@ -143,7 +143,7 @@ class LazyString implements \Stringable, \JsonSerializable } if (\is_array($callback)) { - $class = \is_object($callback[0]) ? \get_class($callback[0]) : $callback[0]; + $class = \is_object($callback[0]) ? get_debug_type($callback[0]) : $callback[0]; $method = $callback[1]; } elseif ($callback instanceof \Closure) { $r = new \ReflectionFunction($callback); @@ -155,14 +155,10 @@ class LazyString implements \Stringable, \JsonSerializable $class = $class->name; $method = $r->name; } else { - $class = \get_class($callback); + $class = get_debug_type($callback); $method = '__invoke'; } - if (isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00")) { - $class = (get_parent_class($class) ?: key(class_implements($class))).'@anonymous'; - } - return $class.'::'.$method; } } diff --git a/src/Symfony/Component/Translation/DataCollectorTranslator.php b/src/Symfony/Component/Translation/DataCollectorTranslator.php index 87ad168a98..2a5783c247 100644 --- a/src/Symfony/Component/Translation/DataCollectorTranslator.php +++ b/src/Symfony/Component/Translation/DataCollectorTranslator.php @@ -38,7 +38,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter public function __construct(TranslatorInterface $translator) { if (!$translator instanceof TranslatorBagInterface || !$translator instanceof LocaleAwareInterface) { - throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface, TranslatorBagInterface and LocaleAwareInterface.', \get_class($translator))); + throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface, TranslatorBagInterface and LocaleAwareInterface.', get_debug_type($translator))); } $this->translator = $translator; diff --git a/src/Symfony/Component/Translation/LoggingTranslator.php b/src/Symfony/Component/Translation/LoggingTranslator.php index c6e8078fd2..9e72ecbd7e 100644 --- a/src/Symfony/Component/Translation/LoggingTranslator.php +++ b/src/Symfony/Component/Translation/LoggingTranslator.php @@ -34,7 +34,7 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface, public function __construct(TranslatorInterface $translator, LoggerInterface $logger) { if (!$translator instanceof TranslatorBagInterface || !$translator instanceof LocaleAwareInterface) { - throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface, TranslatorBagInterface and LocaleAwareInterface.', \get_class($translator))); + throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface, TranslatorBagInterface and LocaleAwareInterface.', get_debug_type($translator))); } $this->translator = $translator; diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 45ca498e16..a814d5f9ba 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -18,6 +18,7 @@ "require": { "php": "^7.2.5", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/translation-contracts": "^2" }, "require-dev": { diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index 02a8261eff..b65d244907 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -58,7 +58,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ protected function formatTypeOf($value) { - return \is_object($value) ? \get_class($value) : \gettype($value); + return get_debug_type($value); } /** diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 3b3aba0450..ba7eebf5cb 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -55,7 +55,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator try { $comparedValue = $this->getPropertyAccessor()->getValue($object, $path); } catch (NoSuchPropertyException $e) { - throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $path, \get_class($constraint), $e->getMessage()), 0, $e); + throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $path, get_debug_type($constraint), $e->getMessage()), 0, $e); } } else { $comparedValue = $constraint->value; @@ -72,7 +72,7 @@ abstract class AbstractComparisonValidator extends ConstraintValidator try { $comparedValue = new $dateTimeClass($comparedValue); } catch (\Exception $e) { - throw new ConstraintDefinitionException(sprintf('The compared value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $comparedValue, $dateTimeClass, \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The compared value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $comparedValue, $dateTimeClass, get_debug_type($constraint))); } } diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index a2c9f7a412..0439f5f641 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -130,7 +130,7 @@ class BicValidator extends ConstraintValidator try { $iban = $this->getPropertyAccessor()->getValue($object, $path); } catch (NoSuchPropertyException $e) { - throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $path, \get_class($constraint), $e->getMessage()), 0, $e); + throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $path, get_debug_type($constraint), $e->getMessage()), 0, $e); } } if (!$iban) { diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index ef1c10b181..3048ba4fa3 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -46,7 +46,7 @@ class CallbackValidator extends ConstraintValidator $method($object, $this->context, $constraint->payload); } elseif (null !== $object) { if (!method_exists($object, $method)) { - throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class "%s".', $method, \get_class($object))); + throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class "%s".', $method, get_debug_type($object))); } $reflMethod = new \ReflectionMethod($object, $method); diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index b9962f095d..a48939766f 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -101,7 +101,7 @@ abstract class Composite extends Constraint $excessGroups = array_diff($constraint->groups, $this->groups); if (\count($excessGroups) > 0) { - throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint "%s" should also be passed to its containing constraint "%s".', implode('", "', $excessGroups), \get_class($constraint), static::class)); + throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint "%s" should also be passed to its containing constraint "%s".', implode('", "', $excessGroups), get_debug_type($constraint), static::class)); } } else { $constraint->groups = $this->groups; diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index c427173034..22895ad356 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -62,7 +62,7 @@ class Email extends Constraint } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 865c1d07ce..4008792f6e 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -70,7 +70,7 @@ class EmailValidator extends ConstraintValidator } if (!\in_array($constraint->mode, Email::$validationModes, true)) { - throw new \InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', \get_class($constraint))); + throw new \InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', get_debug_type($constraint))); } if (Email::VALIDATION_MODE_STRICT === $constraint->mode) { diff --git a/src/Symfony/Component/Validator/Constraints/Ip.php b/src/Symfony/Component/Validator/Constraints/Ip.php index c550749f31..b4bb592855 100644 --- a/src/Symfony/Component/Validator/Constraints/Ip.php +++ b/src/Symfony/Component/Validator/Constraints/Ip.php @@ -87,7 +87,7 @@ class Ip extends Constraint } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/Constraints/Length.php b/src/Symfony/Component/Validator/Constraints/Length.php index 7b4c9c589d..d3404277be 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -62,7 +62,7 @@ class Length extends Constraint } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/Constraints/NotBlank.php b/src/Symfony/Component/Validator/Constraints/NotBlank.php index 5a5b68556d..7e001a3f5f 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlank.php @@ -38,7 +38,7 @@ class NotBlank extends Constraint parent::__construct($options); if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/Constraints/RangeValidator.php b/src/Symfony/Component/Validator/Constraints/RangeValidator.php index 9b7c40ce5a..06b2ed7f8b 100644 --- a/src/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -69,7 +69,7 @@ class RangeValidator extends ConstraintValidator try { $min = new $dateTimeClass($min); } catch (\Exception $e) { - throw new ConstraintDefinitionException(sprintf('The min value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $min, $dateTimeClass, \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The min value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $min, $dateTimeClass, get_debug_type($constraint))); } } @@ -79,7 +79,7 @@ class RangeValidator extends ConstraintValidator try { $max = new $dateTimeClass($max); } catch (\Exception $e) { - throw new ConstraintDefinitionException(sprintf('The max value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $max, $dateTimeClass, \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The max value "%s" could not be converted to a "%s" instance in the "%s" constraint.', $max, $dateTimeClass, get_debug_type($constraint))); } } } @@ -157,7 +157,7 @@ class RangeValidator extends ConstraintValidator try { return $this->getPropertyAccessor()->getValue($object, $propertyPath); } catch (NoSuchPropertyException $e) { - throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $propertyPath, \get_class($constraint), $e->getMessage()), 0, $e); + throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s.', $propertyPath, get_debug_type($constraint), $e->getMessage()), 0, $e); } } diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index 87601cd433..ccb815ca9c 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -39,7 +39,7 @@ class Regex extends Constraint parent::__construct($options); if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } diff --git a/src/Symfony/Component/Validator/Constraints/Url.php b/src/Symfony/Component/Validator/Constraints/Url.php index 31d3395f10..71b1121d69 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -38,7 +38,7 @@ class Url extends Constraint parent::__construct($options); if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/Constraints/Uuid.php b/src/Symfony/Component/Validator/Constraints/Uuid.php index 006cae1282..80cbf609e5 100644 --- a/src/Symfony/Component/Validator/Constraints/Uuid.php +++ b/src/Symfony/Component/Validator/Constraints/Uuid.php @@ -83,7 +83,7 @@ class Uuid extends Constraint parent::__construct($options); if (null !== $this->normalizer && !\is_callable($this->normalizer)) { - throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer))); + throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer))); } } } diff --git a/src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php b/src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php index 62e5530dc2..0b5baed4b9 100644 --- a/src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php +++ b/src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php @@ -46,7 +46,7 @@ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryI $this->validators[$name] = $this->container->get($name); } else { if (!class_exists($name)) { - throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint))); + throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, get_debug_type($constraint))); } $this->validators[$name] = new $name(); diff --git a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php index 55d56dd9c8..86a7c03211 100644 --- a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php @@ -15,6 +15,6 @@ class UnexpectedTypeException extends ValidatorException { public function __construct($value, string $expectedType) { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value))); + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value))); } } diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 12763bee06..a5418e1896 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -174,7 +174,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface public function addConstraint(Constraint $constraint) { if (!\in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) { - throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', get_debug_type($constraint))); } if ($constraint instanceof Traverse) { diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 4e986ba814..25aafa13ac 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -72,7 +72,7 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface public function getMetadataFor($value) { if (!\is_object($value) && !\is_string($value)) { - throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: "%s".', \gettype($value))); + 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, '\\'); diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 6243d9618e..f470f1d98d 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -138,7 +138,7 @@ class GenericMetadata implements MetadataInterface public function addConstraint(Constraint $constraint) { if ($constraint instanceof Traverse) { - throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', get_debug_type($constraint))); } if ($constraint instanceof Valid && null === $constraint->groups) { diff --git a/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php b/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php index 5eb17ee375..b3d6184652 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php @@ -36,7 +36,7 @@ class LoaderChain implements LoaderInterface { foreach ($loaders as $loader) { if (!$loader instanceof LoaderInterface) { - throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader))); + throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', get_debug_type($loader))); } } diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index a8d2f2c856..68196350f4 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -72,7 +72,7 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat public function addConstraint(Constraint $constraint) { if (!\in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) { - throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on properties or getters.', \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on properties or getters.', get_debug_type($constraint))); } parent::addConstraint($constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index 2e6c47a48c..efc79b0b78 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -266,7 +266,7 @@ abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTe $this->buildViolation('Constraint Message') ->setParameter('{{ value }}', $dirtyValueAsString) ->setParameter('{{ compared_value }}', 'null') - ->setParameter('{{ compared_value_type }}', 'NULL') + ->setParameter('{{ compared_value_type }}', 'null') ->setParameter('{{ compared_value_path }}', 'value') ->setCode($this->getErrorCode()) ->assertRaised(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php index f892dc93a1..623ac4c192 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php @@ -69,11 +69,11 @@ class DivisibleByValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [1, '1', 2, '2', 'integer'], - [10, '10', 3, '3', 'integer'], - [10, '10', 0, '0', 'integer'], - [42, '42', INF, 'INF', 'double'], - [4.15, '4.15', 0.1, '0.1', 'double'], + [1, '1', 2, '2', 'int'], + [10, '10', 3, '3', 'int'], + [10, '10', 0, '0', 'int'], + [42, '42', INF, 'INF', 'float'], + [4.15, '4.15', 0.1, '0.1', 'float'], ['22', '"22"', '10', '"10"', 'string'], ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index 70832fc04b..db825543fb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -68,7 +68,7 @@ class EqualToValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [1, '1', 2, '2', 'integer'], + [1, '1', 2, '2', 'int'], ['22', '"22"', '333', '"333"', 'string'], [new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 44924c2767..7484e9ff5d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -72,7 +72,7 @@ class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCas public function provideInvalidComparisons(): array { return [ - [1, '1', 2, '2', 'integer'], + [1, '1', 2, '2', 'int'], [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'], [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'], [new \DateTime('2000/01/01 UTC'), 'Jan 1, 2000, 12:00 AM', '2005/01/01 UTC', 'Jan 1, 2005, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php index 8db8eddf7c..c614572ae1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php @@ -47,9 +47,9 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate public function provideInvalidComparisons(): array { return [ - [-1, '-1', 0, '0', 'integer'], - [-2, '-2', 0, '0', 'integer'], - [-2.5, '-2.5', 0, '0', 'integer'], + [-1, '-1', 0, '0', 'int'], + [-2, '-2', 0, '0', 'int'], + [-2.5, '-2.5', 0, '0', 'int'], ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index eef12d5570..7c6b693d32 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -67,8 +67,8 @@ class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [1, '1', 2, '2', 'integer'], - [2, '2', 2, '2', 'integer'], + [1, '1', 2, '2', 'int'], + [2, '2', 2, '2', 'int'], [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'], [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', '2005/01/01', 'Jan 1, 2005, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php index ef10787bcc..471f7016e6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php @@ -44,10 +44,10 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato public function provideInvalidComparisons(): array { return [ - [0, '0', 0, '0', 'integer'], - [-1, '-1', 0, '0', 'integer'], - [-2, '-2', 0, '0', 'integer'], - [-2.5, '-2.5', 0, '0', 'integer'], + [0, '0', 0, '0', 'int'], + [-1, '-1', 0, '0', 'int'], + [-2, '-2', 0, '0', 'int'], + [-2.5, '-2.5', 0, '0', 'int'], ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index e7856a8b99..98c467bc76 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -86,7 +86,7 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [1, '1', 2, '2', 'integer'], + [1, '1', 2, '2', 'int'], [2, '2', '2', '"2"', 'string'], ['22', '"22"', '333', '"333"', 'string'], [new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index ab05e3ca64..73c9a1d154 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -74,7 +74,7 @@ class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [2, '2', 1, '1', 'integer'], + [2, '2', 1, '1', 'int'], [new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2010-01-01 UTC'), 'Jan 1, 2010, 12:00 AM', '2000-01-01 UTC', 'Jan 1, 2000, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php index 5e4fff253b..66633d8db9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php @@ -45,9 +45,9 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO public function provideInvalidComparisons(): array { return [ - [2, '2', 0, '0', 'integer'], - [2.5, '2.5', 0, '0', 'integer'], - [333, '333', 0, '0', 'integer'], + [2, '2', 0, '0', 'int'], + [2.5, '2.5', 0, '0', 'int'], + [333, '333', 0, '0', 'int'], ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index d8aaa99a98..7241203fcb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -67,8 +67,8 @@ class LessThanValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [3, '3', 2, '2', 'integer'], - [2, '2', 2, '2', 'integer'], + [3, '3', 2, '2', 'int'], + [2, '2', 2, '2', 'int'], [new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php index 642bd8341f..41ca8ded52 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php @@ -44,10 +44,10 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest public function provideInvalidComparisons(): array { return [ - [0, '0', 0, '0', 'integer'], - [2, '2', 0, '0', 'integer'], - [2.5, '2.5', 0, '0', 'integer'], - [333, '333', 0, '0', 'integer'], + [0, '0', 0, '0', 'int'], + [2, '2', 0, '0', 'int'], + [2.5, '2.5', 0, '0', 'int'], + [333, '333', 0, '0', 'int'], ]; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index 22f9b3b110..47cdcac966 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -67,8 +67,8 @@ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase public function provideInvalidComparisons(): array { return [ - [3, '3', 3, '3', 'integer'], - ['2', '"2"', 2, '2', 'integer'], + [3, '3', 3, '3', 'int'], + ['2', '"2"', 2, '2', 'int'], ['a', '"a"', 'a', '"a"', 'string'], [new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'], [new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', '2000-01-01', 'Jan 1, 2000, 12:00 AM', 'DateTime'], diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 8a36828f1e..41660bda51 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -86,7 +86,7 @@ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase $object = new ComparisonTest_Class(2); $comparisons = [ - [3, '3', 3, '3', 'integer'], + [3, '3', 3, '3', 'int'], ['a', '"a"', 'a', '"a"', 'string'], [$date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime'], [$object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'], diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index f3c639ee07..e161af75af 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -29,7 +29,7 @@ class FakeMetadataFactory implements MetadataFactoryInterface } if (!\is_string($class)) { - throw new NoSuchMetadataException(sprintf('No metadata for type "%s".', \gettype($class))); + throw new NoSuchMetadataException(sprintf('No metadata for type "%s".', get_debug_type($class))); } if (!isset($this->metadatas[$class])) { diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index 502ce1abde..89b096d54c 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -157,7 +157,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface return $this; } - throw new RuntimeException(sprintf('Cannot validate values of type "%s" automatically. Please provide a constraint.', \gettype($value))); + throw new RuntimeException(sprintf('Cannot validate values of type "%s" automatically. Please provide a constraint.', get_debug_type($value))); } /** @@ -168,7 +168,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $classMetadata = $this->metadataFactory->getMetadataFor($object); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); + throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', get_debug_type($classMetadata))); } $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); @@ -212,7 +212,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); + throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', get_debug_type($classMetadata))); } $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); @@ -303,7 +303,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface $classMetadata = $this->metadataFactory->getMetadataFor($object); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); + throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', get_debug_type($classMetadata))); } $this->validateClassNode( @@ -498,7 +498,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // returns two metadata objects, not just one foreach ($metadata->getPropertyMetadata($propertyName) as $propertyMetadata) { if (!$propertyMetadata instanceof PropertyMetadataInterface) { - throw new UnsupportedMetadataException(sprintf('The property metadata instances should implement "Symfony\Component\Validator\Mapping\PropertyMetadataInterface", got: "%s".', \is_object($propertyMetadata) ? \get_class($propertyMetadata) : \gettype($propertyMetadata))); + throw new UnsupportedMetadataException(sprintf('The property metadata instances should implement "Symfony\Component\Validator\Mapping\PropertyMetadataInterface", got: "%s".', get_debug_type($propertyMetadata))); } $propertyValue = $propertyMetadata->getPropertyValue($object); @@ -535,7 +535,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface // If TRAVERSE, fail if we have no Traversable if (!$object instanceof \Traversable) { - throw new ConstraintDefinitionException(sprintf('Traversal was enabled for "%s", but this class does not implement "\Traversable".', \get_class($object))); + throw new ConstraintDefinitionException(sprintf('Traversal was enabled for "%s", but this class does not implement "\Traversable".', get_debug_type($object))); } $this->validateEachObjectIn( diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 7755bb24e6..a96e11fcc2 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -19,6 +19,7 @@ "php": "^7.2.5", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/translation-contracts": "^1.1|^2" }, "require-dev": { diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index bac696defc..0e0aac3cb7 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -44,7 +44,7 @@ class Caster * * @return array The array-cast of the object, with prefixed dynamic properties */ - public static function castObject(object $obj, string $class, bool $hasDebugInfo = false): array + public static function castObject(object $obj, string $class, bool $hasDebugInfo = false, string $debugClass = null): array { if ($hasDebugInfo) { try { @@ -63,6 +63,7 @@ class Caster if ($a) { static $publicProperties = []; + $debugClass = $debugClass ?? get_debug_type($obj); $i = 0; $prefixedKeys = []; @@ -76,8 +77,8 @@ class Caster if (!isset($publicProperties[$class][$k])) { $prefixedKeys[$i] = self::PREFIX_DYNAMIC.$k; } - } elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) { - $prefixedKeys[$i] = "\0".(get_parent_class($class) ?: key(class_implements($class))).'@anonymous'.strrchr($k, "\0"); + } elseif ($debugClass !== $class && 1 === strpos($k, $class)) { + $prefixedKeys[$i] = "\0".$debugClass.strrchr($k, "\0"); } ++$i; } diff --git a/src/Symfony/Component/VarDumper/Caster/ClassStub.php b/src/Symfony/Component/VarDumper/Caster/ClassStub.php index cc3351da40..612a7ca2d9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ClassStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ClassStub.php @@ -55,9 +55,9 @@ class ClassStub extends ConstStub } } - if (false !== strpos($identifier, "class@anonymous\0")) { - $this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0]))).'@anonymous' : $m[0]; + if (false !== strpos($identifier, "@anonymous\0")) { + $this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { + return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $identifier); } diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php index c1fa9a8885..9895a0979f 100644 --- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php @@ -73,8 +73,7 @@ class ExceptionCaster if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) { $b = (array) $a[$xPrefix.'previous']; - $class = \get_class($a[$xPrefix.'previous']); - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $class = get_debug_type($a[$xPrefix.'previous']); self::traceUnshift($b[$xPrefix.'trace'], $class, $b[$prefix.'file'], $b[$prefix.'line']); $a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value)); } @@ -282,9 +281,9 @@ class ExceptionCaster } unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']); - if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) { - $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0]))).'@anonymous' : $m[0]; + if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) { + $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { + return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $a[Caster::PREFIX_PROTECTED.'message']); } diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 06fa4884e9..c2e9897c73 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -297,8 +297,8 @@ abstract class AbstractCloner implements ClonerInterface $obj = $stub->value; $class = $stub->class; - if (isset($class[15]) && "\0" === $class[15] && 0 === strpos($class, "class@anonymous\x00")) { - $stub->class = (get_parent_class($class) ?: key(class_implements($class))).'@anonymous'; + if (\PHP_VERSION_ID < 80000 ? "\0" === ($class[15] ?? null) : false !== strpos($class, "@anonymous\0")) { + $stub->class = get_debug_type($obj); } if (isset($this->classInfo[$class])) { list($i, $parents, $hasDebugInfo, $fileInfo) = $this->classInfo[$class]; @@ -327,7 +327,7 @@ abstract class AbstractCloner implements ClonerInterface } $stub->attr += $fileInfo; - $a = Caster::castObject($obj, $class, $hasDebugInfo); + $a = Caster::castObject($obj, $class, $hasDebugInfo, $stub->class); try { while ($i--) { diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index bafcb31eaf..eb3ceed9cd 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -122,7 +122,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate public function getIterator() { if (!\is_array($value = $this->getValue())) { - throw new \LogicException(sprintf('%s object holds non-iterable type "%s".', self::class, \gettype($value))); + throw new \LogicException(sprintf('%s object holds non-iterable type "%s".', self::class, get_debug_type($value))); } yield from $value; diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 146330d05a..3b323dc1da 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": "^7.2.5", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "ext-iconv": "*", diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 38f7fbf1af..07612dd41a 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -271,7 +271,7 @@ class Exporter return self::exportHydrator($value, $indent, $subIndent); } - throw new \UnexpectedValueException(sprintf('Cannot export value of type "%s".', \is_object($value) ? \get_class($value) : \gettype($value))); + throw new \UnexpectedValueException(sprintf('Cannot export value of type "%s".', get_debug_type($value))); } private static function exportRegistry(Registry $value, string $indent, string $subIndent): string diff --git a/src/Symfony/Component/VarExporter/composer.json b/src/Symfony/Component/VarExporter/composer.json index 6262047f00..1678e352db 100644 --- a/src/Symfony/Component/VarExporter/composer.json +++ b/src/Symfony/Component/VarExporter/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": "^7.2.5" + "php": "^7.2.5", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "symfony/var-dumper": "^4.4|^5.0" diff --git a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php index 39d2ccec21..63ef2a966f 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php @@ -51,7 +51,7 @@ final class MethodMarkingStore implements MarkingStoreInterface $method = 'get'.ucfirst($this->property); if (!method_exists($subject, $method)) { - throw new LogicException(sprintf('The method "%s::%s()" does not exist.', \get_class($subject), $method)); + throw new LogicException(sprintf('The method "%s::%s()" does not exist.', get_debug_type($subject), $method)); } $marking = $subject->{$method}(); @@ -81,7 +81,7 @@ final class MethodMarkingStore implements MarkingStoreInterface $method = 'set'.ucfirst($this->property); if (!method_exists($subject, $method)) { - throw new LogicException(sprintf('The method "%s::%s()" does not exist.', \get_class($subject), $method)); + throw new LogicException(sprintf('The method "%s::%s()" does not exist.', get_debug_type($subject), $method)); } $subject->{$method}($marking, $context); diff --git a/src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php b/src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php index a170ffacf1..04cd52cc68 100644 --- a/src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php +++ b/src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php @@ -43,6 +43,6 @@ trait GetMetadataTrait return $metadataBag[$key] ?? null; } - throw new InvalidArgumentException(sprintf('Could not find a MetadataBag for the subject of type "%s".', \is_object($subject) ? \get_class($subject) : \gettype($subject))); + throw new InvalidArgumentException(sprintf('Could not find a MetadataBag for the subject of type "%s".', get_debug_type($subject))); } } diff --git a/src/Symfony/Component/Workflow/Registry.php b/src/Symfony/Component/Workflow/Registry.php index bd6a9d0d6a..967db71c69 100644 --- a/src/Symfony/Component/Workflow/Registry.php +++ b/src/Symfony/Component/Workflow/Registry.php @@ -52,7 +52,7 @@ class Registry } if (!$matched) { - throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', \get_class($subject))); + throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', get_debug_type($subject))); } if (2 <= \count($matched)) { @@ -60,7 +60,7 @@ class Registry return $workflow->getName(); }, $matched); - throw new InvalidArgumentException(sprintf('Too many workflows (%s) match this subject (%s); set a different name on each and use the second (name) argument of this method.', implode(', ', $names), \get_class($subject))); + throw new InvalidArgumentException(sprintf('Too many workflows (%s) match this subject (%s); set a different name on each and use the second (name) argument of this method.', implode(', ', $names), get_debug_type($subject))); } return $matched[0]; diff --git a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php index 5e5c8fec6f..ba54bcd287 100644 --- a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php +++ b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php @@ -78,7 +78,7 @@ class InMemoryMetadataStoreTest extends TestCase public function testGetMetadataWithUnknownType() { $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "boolean".'); + $this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "bool".'); $this->store->getMetadata('title', true); } } diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index a1644f7dfe..179123bacc 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -20,7 +20,8 @@ } ], "require": { - "php": "^7.2.5" + "php": "^7.2.5", + "symfony/polyfill-php80": "^1.15" }, "require-dev": { "psr/log": "~1.0",