Skip to content

Commit bb35af8

Browse files
Leverage PHP8's get_debug_type()
1 parent 233c2ad commit bb35af8

File tree

10 files changed

+13
-12
lines changed

10 files changed

+13
-12
lines changed

CacheWarmer/RouterCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function warmUp(string $cacheDir)
4747
return;
4848
}
4949

50-
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', \get_class($router), WarmableInterface::class));
50+
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));
5151
}
5252

5353
/**

Command/AbstractConfigCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function validateConfiguration(ExtensionInterface $extension, $configurat
116116
}
117117

118118
if (!$configuration instanceof ConfigurationInterface) {
119-
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', \get_class($configuration)));
119+
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration)));
120120
}
121121
}
122122

Command/ContainerLintCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function getContainerBuilder(): ContainerBuilder
8989

9090
if (!$kernel->isDebug() || !(new ConfigCache($kernelContainer->getParameter('debug.container.dump'), true))->isFresh()) {
9191
if (!$kernel instanceof Kernel) {
92-
throw new RuntimeException(sprintf('This command does not support the application kernel: "%s" does not extend "%s".', \get_class($kernel), Kernel::class));
92+
throw new RuntimeException(sprintf('This command does not support the application kernel: "%s" does not extend "%s".', get_debug_type($kernel), Kernel::class));
9393
}
9494

9595
$buildContainer = \Closure::bind(function (): ContainerBuilder {
@@ -102,7 +102,7 @@ private function getContainerBuilder(): ContainerBuilder
102102
$skippedIds = [];
103103
} else {
104104
if (!$kernelContainer instanceof Container) {
105-
throw new RuntimeException(sprintf('This command does not support the application container: "%s" does not extend "%s".', \get_class($kernelContainer), Container::class));
105+
throw new RuntimeException(sprintf('This command does not support the application container: "%s" does not extend "%s".', get_debug_type($kernelContainer), Container::class));
106106
}
107107

108108
(new XmlFileLoader($container = new ContainerBuilder($parameterBag = new EnvPlaceholderParameterBag()), new FileLocator()))->load($kernelContainer->getParameter('debug.container.dump'));

Console/Descriptor/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function describe(OutputInterface $output, $object, array $options = [])
8383
$this->describeCallable($object, $options);
8484
break;
8585
default:
86-
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
86+
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object)));
8787
}
8888
}
8989

Resources/config/session.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
</service>
3737

3838
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag">
39-
<factory service="session" method="getFlashBag"/>
39+
<factory service="session" method="getFlashBag" />
4040
</service>
4141
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
4242

4343
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
44-
<factory service="session" method="getAttributeBag"/>
44+
<factory service="session" method="getAttributeBag" />
4545
</service>
4646

4747
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">

Routing/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private function resolve($value)
171171
return (string) $this->resolve($resolved);
172172
}
173173

174-
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)));
174+
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)));
175175
}, $value);
176176

177177
return str_replace('%%', '%', $escapedValue);

Secrets/SodiumVault.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
3434
public function __construct(string $secretsDir, $decryptionKey = null)
3535
{
3636
if (null !== $decryptionKey && !\is_string($decryptionKey) && !(\is_object($decryptionKey) && method_exists($decryptionKey, '__toString'))) {
37-
throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, "%s" given.', \gettype($decryptionKey)));
37+
throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, "%s" given.', get_debug_type($decryptionKey)));
3838
}
3939

4040
$this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.';

Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ session_setflash:
2020

2121
injected_flashbag_session_setflash:
2222
path: injected_flashbag/session_setflash/{message}
23-
defaults: { _controller: TestBundle:InjectedFlashbagSession:setFlash}
23+
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\InjectedFlashbagSessionController::setFlashAction}
2424

2525
session_showflash:
2626
path: /session_showflash

Tests/Routing/RouterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public function testExceptionOnNonExistentParameterWithSfContainer()
390390
public function testExceptionOnNonStringParameter()
391391
{
392392
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
393-
$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".');
393+
$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".');
394394
$routes = new RouteCollection();
395395

396396
$routes->add('foo', new Route('/%object%'));
@@ -405,7 +405,7 @@ public function testExceptionOnNonStringParameter()
405405
public function testExceptionOnNonStringParameterWithSfContainer()
406406
{
407407
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
408-
$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".');
408+
$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".');
409409
$routes = new RouteCollection();
410410

411411
$routes->add('foo', new Route('/%object%'));

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"symfony/http-foundation": "^4.4|^5.0",
2626
"symfony/http-kernel": "^5.0",
2727
"symfony/polyfill-mbstring": "~1.0",
28+
"symfony/polyfill-php80": "^1.15",
2829
"symfony/filesystem": "^4.4|^5.0",
2930
"symfony/finder": "^4.4|^5.0",
3031
"symfony/routing": "^5.1"

0 commit comments

Comments
 (0)