minor #35945 Leverage PHP8's get_debug_type() (nicolas-grekas)
This PR was merged into the 5.1-dev branch.
Discussion
----------
Leverage PHP8's get_debug_type()
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
See https://github.com/symfony/polyfill/pull/226 for background.
We might have to port part of the patch to 4.4 when we'll work on having it support PHP 8, but that's not needed for now.
Commits
-------
daf1c6605e
Leverage PHP8's get_debug_type()
This commit is contained in:
commit
c650fe6dfc
@ -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);
|
||||
|
@ -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 [
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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": {
|
||||
|
@ -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;
|
||||
|
@ -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, [
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'));
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,12 +36,12 @@
|
||||
</service>
|
||||
|
||||
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag">
|
||||
<factory service="session" method="getFlashBag"/>
|
||||
<factory service="session" method="getFlashBag" />
|
||||
</service>
|
||||
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
|
||||
|
||||
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
|
||||
<factory service="session" method="getAttributeBag"/>
|
||||
<factory service="session" method="getAttributeBag" />
|
||||
</service>
|
||||
|
||||
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">
|
||||
|
@ -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);
|
||||
|
@ -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).'.';
|
||||
|
@ -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
|
||||
|
@ -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%'));
|
||||
|
@ -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"
|
||||
|
@ -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());
|
||||
|
@ -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",
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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]);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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()) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.');
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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([]);
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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'),
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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": {
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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)));
|
||||
|
@ -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": {
|
||||
|
@ -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]);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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<year>\d{4})-W(?P<week>\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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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.'".');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"].'],
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user