Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bcff647

Browse filesBrowse files
minor #28910 [Serializer] Improve perf a bit by not using a signaling exception when not needed (nicolas-grekas)
This PR was merged into the 4.2-dev branch. Discussion ---------- [Serializer] Improve perf a bit by not using a signaling exception when not needed | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - And disabling unneeded autoload calls for interface_exists checks meanwhile. Commits ------- 2a2914e [Serializer] Improve perf a bit by not using a signaling exception when not needed
2 parents dd432c4 + 2a2914e commit bcff647
Copy full SHA for bcff647

File tree

5 files changed

+5
-14
lines changed
Filter options

5 files changed

+5
-14
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
285285
->prototype('scalar')
286286
->cannotBeEmpty()
287287
->validate()
288-
->ifTrue(function ($v) { return !class_exists($v) && !interface_exists($v); })
288+
->ifTrue(function ($v) { return !class_exists($v) && !interface_exists($v, false); })
289289
->thenInvalid('The supported class or interface "%s" does not exist.')
290290
->end()
291291
->end()

‎src/Symfony/Component/Form/FormConfigBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function __construct($name, ?string $dataClass, EventDispatcherInterface
179179
{
180180
self::validateName($name);
181181

182-
if (null !== $dataClass && !class_exists($dataClass) && !interface_exists($dataClass)) {
182+
if (null !== $dataClass && !class_exists($dataClass) && !interface_exists($dataClass, false)) {
183183
throw new InvalidArgumentException(sprintf('Class "%s" not found. Is the "data_class" form option set correctly?', $dataClass));
184184
}
185185

‎src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
131131
$method = $method['method'] ?? '__invoke';
132132
}
133133

134-
if (!\class_exists($messageClass) && !\interface_exists($messageClass)) {
134+
if (!\class_exists($messageClass) && !\interface_exists($messageClass, false)) {
135135
$messageClassLocation = isset($tag['handles']) ? 'declared in your tag attribute "handles"' : $r->implementsInterface(MessageSubscriberInterface::class) ? sprintf('returned by method "%s::getHandledMessages()"', $r->getName()) : sprintf('used as argument type in method "%s::%s()"', $r->getName(), $method);
136136

137137
throw new RuntimeException(sprintf('Invalid handler service "%s": message class "%s" %s does not exist.', $serviceId, $messageClass, $messageClassLocation));

‎src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Serializer\Mapping\Factory;
1313

14-
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1514
use Symfony\Component\Serializer\Mapping\ClassMetadata;
1615
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
1716

@@ -70,14 +69,6 @@ public function getMetadataFor($value)
7069
*/
7170
public function hasMetadataFor($value)
7271
{
73-
try {
74-
$this->getClass($value);
75-
76-
return true;
77-
} catch (InvalidArgumentException $invalidArgumentException) {
78-
// Return false in case of exception
79-
}
80-
81-
return false;
72+
return \is_object($value) || (\is_string($value) && (\class_exists($value) || \interface_exists($value, false)));
8273
}
8374
}

‎src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait ClassResolverTrait
3434
private function getClass($value)
3535
{
3636
if (\is_string($value)) {
37-
if (!class_exists($value) && !interface_exists($value)) {
37+
if (!class_exists($value) && !interface_exists($value, false)) {
3838
throw new InvalidArgumentException(sprintf('The class or interface "%s" does not exist.', $value));
3939
}
4040

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.