Completed
Push — master ( 51c1ff...5f15fa )
by Christian
02:32 queued 12s
created

Configuration::addExceptionSection()   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 87

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 71
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 87
ccs 71
cts 71
cp 1
rs 7.6614
c 0
b 0
f 0
cc 6
nc 1
nop 1
crap 6

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
use Symfony\Component\Serializer\Encoder\XmlEncoder;
21
22
/**
23
 * This class contains the configuration information for the bundle.
24
 *
25
 * This information is solely responsible for how the different configuration
26
 * sections are normalized, and merged.
27
 *
28
 * @author Lukas Kahwe Smith <[email protected]>
29
 *
30
 * @internal
31
 */
32
final class Configuration implements ConfigurationInterface
33
{
34
    private $debug;
35
36 62
    public function __construct(bool $debug)
37
    {
38 62
        $this->debug = $debug;
39 62
    }
40
41 61
    public function getConfigTreeBuilder(): TreeBuilder
42
    {
43 61
        $treeBuilder = new TreeBuilder('fos_rest');
44
45 61
        $rootNode = $treeBuilder->getRootNode();
46
47
        $rootNode
48 61
            ->children()
49 61
                ->scalarNode('disable_csrf_role')->defaultNull()->end()
50 61
                ->arrayNode('access_denied_listener')
51 61
                    ->canBeEnabled()
52 61
                    ->beforeNormalization()
53 View Code Duplication
                        ->ifArray()->then(function ($v) {
54
                            if (!empty($v) && empty($v['formats'])) {
55
                                unset($v['enabled']);
56
                                $v = ['enabled' => true, 'formats' => $v];
57
                            }
58
59
                            return $v;
60 61
                        })
61 61
                    ->end()
62 61
                    ->fixXmlConfig('format', 'formats')
63 61
                    ->children()
64 61
                        ->scalarNode('service')->defaultNull()->end()
65 61
                        ->arrayNode('formats')
66 61
                            ->useAttributeAsKey('name')
67 61
                            ->prototype('boolean')->end()
68 61
                        ->end()
69 61
                    ->end()
70 61
                ->end()
71 61
                ->scalarNode('unauthorized_challenge')->defaultNull()->end()
72 61
                ->arrayNode('param_fetcher_listener')
73 61
                    ->beforeNormalization()
74 61
                        ->ifString()
75 View Code Duplication
                        ->then(function ($v) {
76 1
                            return ['enabled' => in_array($v, ['force', 'true']), 'force' => 'force' === $v];
77 61
                        })
78 61
                    ->end()
79 61
                    ->canBeEnabled()
80 61
                    ->children()
81 61
                        ->booleanNode('force')->defaultFalse()->end()
82 61
                        ->scalarNode('service')->defaultNull()->end()
83 61
                    ->end()
84 61
                ->end()
85 61
                ->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue('%kernel.cache_dir%/fos_rest')->end()
86 61
                ->arrayNode('allowed_methods_listener')
87 61
                    ->canBeEnabled()
88 61
                    ->children()
89 61
                        ->scalarNode('service')->defaultNull()->end()
90 61
                    ->end()
91 61
                ->end()
92 61
                ->booleanNode('routing_loader')
93 61
                    ->defaultValue(false)
94 61
                    ->validate()
95 61
                        ->ifTrue()
96 61
                        ->thenInvalid('only "false" is supported')
97 61
                    ->end()
98 61
                ->end()
99 61
                ->arrayNode('body_converter')
100 61
                    ->canBeEnabled()
101 61
                    ->children()
102 61
                        ->scalarNode('validate')
103 61
                            ->defaultFalse()
104 61
                            ->beforeNormalization()
105 61
                                ->ifTrue()
106
                                ->then(function ($value) {
107 1
                                    if (!class_exists(OptionsResolver::class)) {
108
                                        throw new InvalidConfigurationException("'body_converter.validate: true' requires OptionsResolver component installation ( composer require symfony/options-resolver )");
109
                                    }
110
111 1
                                    return $value;
112 61
                                })
113 61
                            ->end()
114 61
                        ->end()
115 61
                        ->scalarNode('validation_errors_argument')->defaultValue('validationErrors')->end()
116 61
                    ->end()
117 61
                ->end()
118 61
                ->arrayNode('service')
119 61
                    ->addDefaultsIfNotSet()
120 61
                    ->children()
121 61
                        ->scalarNode('templating')
122 61
                            ->defaultNull()
123 61
                            ->validate()
124 61
                                ->ifString()
125 61
                                ->thenInvalid('only null is supported')
126 61
                            ->end()
127 61
                            ->setDeprecated('The "%path%.%node%" option is deprecated since FOSRestBundle 2.8.')
128 61
                        ->end()
129 61
                        ->scalarNode('serializer')->defaultNull()->end()
130 61
                        ->scalarNode('view_handler')->defaultValue('fos_rest.view_handler.default')->end()
131 61
                        ->scalarNode('inflector')
132 61
                            ->defaultNull()
133 61
                            ->validate()
134 61
                                ->ifString()
135 61
                                ->thenInvalid('only null is supported')
136 61
                            ->end()
137 61
                            ->setDeprecated('The "%path%.%node%" option is deprecated since FOSRestBundle 2.8.')
138 61
                        ->end()
139 61
                        ->scalarNode('validator')->defaultValue('validator')->end()
140 61
                    ->end()
141 61
                ->end()
142 61
                ->arrayNode('serializer')
143 61
                    ->addDefaultsIfNotSet()
144 61
                    ->children()
145 61
                        ->scalarNode('version')->defaultNull()->end()
146 61
                        ->arrayNode('groups')
147 61
                            ->prototype('scalar')->end()
148 61
                        ->end()
149 61
                        ->booleanNode('serialize_null')->defaultFalse()->end()
150 61
                    ->end()
151 61
                ->end()
152 61
                ->arrayNode('zone')
153 61
                    ->cannotBeOverwritten()
154 61
                    ->prototype('array')
155 61
                    ->fixXmlConfig('ip')
156 61
                    ->children()
157 61
                        ->scalarNode('path')
158 61
                            ->defaultNull()
159 61
                            ->info('use the urldecoded format')
160 61
                            ->example('^/path to resource/')
161 61
                        ->end()
162 61
                        ->scalarNode('host')->defaultNull()->end()
163 61
                        ->arrayNode('methods')
164
                            ->beforeNormalization()->ifString()->then(function ($v) {
165
                                return preg_split('/\s*,\s*/', $v);
166 61
                            })->end()
167 61
                            ->prototype('scalar')->end()
168 61
                        ->end()
169 61
                        ->arrayNode('ips')
170
                            ->beforeNormalization()->ifString()->then(function ($v) {
171 1
                                return array($v);
172 61
                            })->end()
173 61
                            ->prototype('scalar')->end()
174 61
                        ->end()
175 61
                    ->end()
176 61
                ->end()
177 61
            ->end()
178 61
        ->end();
179
180 61
        $this->addViewSection($rootNode);
0 ignored issues
show
Compatibility introduced by
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
181 61
        $this->addExceptionSection($rootNode);
0 ignored issues
show
Compatibility introduced by
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
182 61
        $this->addBodyListenerSection($rootNode);
0 ignored issues
show
Compatibility introduced by
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
183 61
        $this->addFormatListenerSection($rootNode);
0 ignored issues
show
Compatibility introduced by
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
184 61
        $this->addVersioningSection($rootNode);
0 ignored issues
show
Compatibility introduced by
$rootNode of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
185
186 61
        return $treeBuilder;
187
    }
188
189 61
    private function addViewSection(ArrayNodeDefinition $rootNode): void
190
    {
191
        $rootNode
192 61
            ->children()
193 61
                ->arrayNode('view')
194 61
                    ->fixXmlConfig('format', 'formats')
195 61
                    ->fixXmlConfig('mime_type', 'mime_types')
196 61
                    ->fixXmlConfig('force_redirect', 'force_redirects')
197 61
                    ->addDefaultsIfNotSet()
198 61
                    ->children()
199 61
                        ->scalarNode('default_engine')
200 61
                            ->defaultNull()
201 61
                            ->validate()
202 61
                                ->ifString()
203 61
                                ->thenInvalid('only null is supported')
204 61
                            ->end()
205 61
                            ->setDeprecated('The "%path%.%node%" option has been deprecated in FOSRestBundle 2.8.')
206 61
                        ->end()
207 61
                        ->arrayNode('force_redirects')
208 61
                            ->setDeprecated('The "%path%.%node%" option has been deprecated in FOSRestBundle 2.8.')
209 61
                            ->useAttributeAsKey('name')
210 61
                            ->defaultValue([])
211 61
                            ->validate()
212
                                ->ifTrue(function ($v) { return [] !== $v; })
213 61
                                ->thenInvalid('only the empty array is supported')
214 61
                            ->end()
215 61
                            ->prototype('boolean')->end()
216 61
                        ->end()
217 61
                        ->arrayNode('mime_types')
218 61
                            ->canBeEnabled()
219 61
                            ->beforeNormalization()
220 View Code Duplication
                                ->ifArray()->then(function ($v) {
221 1
                                    if (!empty($v) && empty($v['formats'])) {
222 1
                                        unset($v['enabled']);
223 1
                                        $v = ['enabled' => true, 'formats' => $v];
224
                                    }
225
226 1
                                    return $v;
227 61
                                })
228 61
                            ->end()
229 61
                            ->fixXmlConfig('format', 'formats')
230 61
                            ->children()
231 61
                                ->scalarNode('service')->defaultNull()->end()
232 61
                                ->arrayNode('formats')
233 61
                                    ->useAttributeAsKey('name')
234 61
                                    ->prototype('array')
235 61
                                        ->beforeNormalization()
236 61
                                            ->ifString()
237
                                            ->then(function ($v) { return array($v); })
238 61
                                        ->end()
239 61
                                        ->prototype('scalar')->end()
240 61
                                    ->end()
241 61
                                ->end()
242 61
                            ->end()
243 61
                        ->end()
244 61
                        ->arrayNode('formats')
245 61
                            ->useAttributeAsKey('name')
246 61
                            ->defaultValue(['json' => true, 'xml' => true])
247 61
                            ->prototype('boolean')->end()
248 61
                        ->end()
249 61
                        ->arrayNode('view_response_listener')
250 61
                            ->beforeNormalization()
251 61
                                ->ifString()
252 View Code Duplication
                                ->then(function ($v) {
253 4
                                    return ['enabled' => in_array($v, ['force', 'true']), 'force' => 'force' === $v];
254 61
                                })
255 61
                            ->end()
256 61
                            ->canBeEnabled()
257 61
                            ->children()
258 61
                                ->booleanNode('force')->defaultFalse()->end()
259 61
                                ->scalarNode('service')->defaultNull()->end()
260 61
                            ->end()
261 61
                        ->end()
262 61
                        ->scalarNode('failed_validation')->defaultValue(Response::HTTP_BAD_REQUEST)->end()
263 61
                        ->scalarNode('empty_content')->defaultValue(Response::HTTP_NO_CONTENT)->end()
264 61
                        ->booleanNode('serialize_null')->defaultFalse()->end()
265 61
                        ->arrayNode('jsonp_handler')
266 61
                            ->canBeUnset()
267 61
                            ->children()
268 61
                                ->scalarNode('callback_param')->defaultValue('callback')->end()
269 61
                                ->scalarNode('mime_type')->defaultValue('application/javascript+jsonp')->end()
270 61
                            ->end()
271 61
                        ->end()
272 61
                    ->end()
273 61
                ->end()
274 61
            ->end();
275 61
    }
276
277 61
    private function addBodyListenerSection(ArrayNodeDefinition $rootNode): void
278
    {
279 61
        $decodersDefaultValue = ['json' => 'fos_rest.decoder.json'];
280 61
        if (class_exists(XmlEncoder::class)) {
281 61
            $decodersDefaultValue['xml'] = 'fos_rest.decoder.xml';
282
        }
283
        $rootNode
284 61
            ->children()
285 61
                ->arrayNode('body_listener')
286 61
                    ->fixXmlConfig('decoder', 'decoders')
287 61
                    ->addDefaultsIfNotSet()
288 61
                    ->canBeUnset()
289 61
                    ->canBeEnabled()
290 61
                    ->children()
291 61
                        ->scalarNode('service')->defaultNull()->end()
292 61
                        ->scalarNode('default_format')->defaultNull()->end()
293 61
                        ->booleanNode('throw_exception_on_unsupported_content_type')
294 61
                            ->defaultFalse()
295 61
                        ->end()
296 61
                        ->arrayNode('decoders')
297 61
                            ->useAttributeAsKey('name')
298 61
                            ->defaultValue($decodersDefaultValue)
299 61
                            ->prototype('scalar')->end()
300 61
                        ->end()
301 61
                        ->arrayNode('array_normalizer')
302 61
                            ->addDefaultsIfNotSet()
303 61
                            ->beforeNormalization()
304
                                ->ifString()->then(function ($v) {
305 1
                                    return ['service' => $v];
306 61
                                })
307 61
                            ->end()
308 61
                            ->children()
309 61
                                ->scalarNode('service')->defaultNull()->end()
310 61
                                ->booleanNode('forms')->defaultFalse()->end()
311 61
                            ->end()
312 61
                        ->end()
313 61
                    ->end()
314 61
                ->end()
315 61
            ->end();
316 61
    }
317
318 61
    private function addFormatListenerSection(ArrayNodeDefinition $rootNode): void
319
    {
320
        $rootNode
321 61
            ->children()
322 61
                ->arrayNode('format_listener')
323 61
                    ->fixXmlConfig('rule', 'rules')
324 61
                    ->addDefaultsIfNotSet()
325 61
                    ->canBeUnset()
326 61
                    ->beforeNormalization()
327
                        ->ifTrue(function ($v) {
328
                            // check if we got an assoc array in rules
329 6
                            return isset($v['rules'])
330 6
                                && is_array($v['rules'])
331 6
                                && array_keys($v['rules']) !== range(0, count($v['rules']) - 1);
332 61
                        })
333
                        ->then(function ($v) {
334 1
                            $v['rules'] = [$v['rules']];
335
336 1
                            return $v;
337 61
                        })
338 61
                    ->end()
339 61
                    ->canBeEnabled()
340 61
                    ->children()
341 61
                        ->scalarNode('service')->defaultNull()->end()
342 61
                        ->arrayNode('rules')
343 61
                            ->performNoDeepMerging()
344 61
                            ->prototype('array')
345 61
                                ->fixXmlConfig('priority', 'priorities')
346 61
                                ->fixXmlConfig('attribute', 'attributes')
347 61
                                ->children()
348 61
                                    ->scalarNode('path')->defaultNull()->info('URL path info')->end()
349 61
                                    ->scalarNode('host')->defaultNull()->info('URL host name')->end()
350 61
                                    ->variableNode('methods')->defaultNull()->info('Method for URL')->end()
351 61
                                    ->arrayNode('attributes')
352 61
                                        ->useAttributeAsKey('name')
353 61
                                        ->prototype('variable')->end()
354 61
                                    ->end()
355 61
                                    ->booleanNode('stop')->defaultFalse()->end()
356 61
                                    ->booleanNode('prefer_extension')->defaultTrue()->end()
357 61
                                    ->scalarNode('fallback_format')->defaultValue('html')->end()
358 61
                                    ->arrayNode('priorities')
359
                                        ->beforeNormalization()->ifString()->then(function ($v) {
360
                                            return preg_split('/\s*,\s*/', $v);
361 61
                                        })->end()
362 61
                                        ->prototype('scalar')->end()
363 61
                                    ->end()
364 61
                                ->end()
365 61
                            ->end()
366 61
                        ->end()
367 61
                    ->end()
368 61
                ->end()
369 61
            ->end();
370 61
    }
371
372 61
    private function addVersioningSection(ArrayNodeDefinition $rootNode): void
373
    {
374
        $rootNode
375 61
        ->children()
376 61
            ->arrayNode('versioning')
377 61
                ->canBeEnabled()
378 61
                ->children()
379 61
                    ->scalarNode('default_version')->defaultNull()->end()
380 61
                    ->arrayNode('resolvers')
381 61
                        ->addDefaultsIfNotSet()
382 61
                        ->children()
383 61
                            ->arrayNode('query')
384 61
                                ->canBeDisabled()
385 61
                                ->children()
386 61
                                    ->scalarNode('parameter_name')->defaultValue('version')->end()
387 61
                                ->end()
388 61
                            ->end()
389 61
                            ->arrayNode('custom_header')
390 61
                                ->canBeDisabled()
391 61
                                ->children()
392 61
                                    ->scalarNode('header_name')->defaultValue('X-Accept-Version')->end()
393 61
                                ->end()
394 61
                            ->end()
395 61
                            ->arrayNode('media_type')
396 61
                                ->canBeDisabled()
397 61
                                ->children()
398 61
                                    ->scalarNode('regex')->defaultValue('/(v|version)=(?P<version>[0-9\.]+)/')->end()
399 61
                                ->end()
400 61
                            ->end()
401 61
                        ->end()
402 61
                    ->end()
403 61
                    ->arrayNode('guessing_order')
404 61
                        ->defaultValue(['query', 'custom_header', 'media_type'])
405 61
                        ->validate()
406
                            ->ifTrue(function ($v) {
407
                                foreach ($v as $resolver) {
408
                                    if (!in_array($resolver, ['query', 'custom_header', 'media_type'])) {
409
                                        return true;
410
                                    }
411
                                }
412 61
                            })
413 61
                            ->thenInvalid('Versioning guessing order can only contain "query", "custom_header", "media_type".')
414 61
                        ->end()
415 61
                        ->prototype('scalar')->end()
416 61
                    ->end()
417 61
                ->end()
418 61
            ->end()
419 61
        ->end();
420 61
    }
421
422 61
    private function addExceptionSection(ArrayNodeDefinition $rootNode): void
423
    {
424
        $rootNode
425 61
            ->children()
426 61
                ->arrayNode('exception')
427 61
                    ->fixXmlConfig('code', 'codes')
428 61
                    ->fixXmlConfig('message', 'messages')
429 61
                    ->addDefaultsIfNotSet()
430 61
                    ->canBeEnabled()
431 61
                    ->children()
432 61
                        ->booleanNode('map_exception_codes')
433 61
                            ->defaultFalse()
434 61
                            ->info('Enables an event listener that maps exception codes to response status codes based on the map configured with the "fos_rest.exception.codes" option.')
435 61
                        ->end()
436 61
                        ->booleanNode('exception_listener')
437 61
                            ->defaultValue(false)
438 61
                            ->validate()
439 61
                                ->ifTrue()
440 61
                                ->thenInvalid('only "false" is supported')
441 61
                            ->end()
442 61
                        ->end()
443 61
                        ->booleanNode('serialize_exceptions')
444 61
                            ->defaultValue(false)
445 61
                            ->validate()
446 61
                                ->ifTrue()
447 61
                                ->thenInvalid('only "false" is supported')
448 61
                            ->end()
449 61
                        ->end()
450 61
                        ->enumNode('flatten_exception_format')
451 61
                            ->defaultValue('legacy')
452 61
                            ->values(['legacy', 'rfc7807'])
453 61
                        ->end()
454 61
                        ->booleanNode('serializer_error_renderer')->defaultValue(false)->end()
455 61
                        ->arrayNode('codes')
456 61
                            ->useAttributeAsKey('name')
457 61
                            ->beforeNormalization()
458 61
                                ->ifArray()
459
                                ->then(function (array $items) {
460 13
                                    foreach ($items as &$item) {
461 13
                                        if (is_int($item)) {
462 3
                                            continue;
463
                                        }
464
465 10
                                        if (!defined(sprintf('%s::%s', Response::class, $item))) {
466 9
                                            throw new InvalidConfigurationException(sprintf('Invalid HTTP code in fos_rest.exception.codes, see %s for all valid codes.', Response::class));
467
                                        }
468
469 1
                                        $item = constant(sprintf('%s::%s', Response::class, $item));
470
                                    }
471
472 4
                                    return $items;
473 61
                                })
474 61
                            ->end()
475 61
                            ->prototype('integer')->end()
476
477 61
                            ->validate()
478 61
                            ->ifArray()
479
                                ->then(function (array $items) {
480 4
                                    foreach ($items as $class => $code) {
481 4
                                        $this->testExceptionExists($class);
482
                                    }
483
484 3
                                    return $items;
485 61
                                })
486 61
                            ->end()
487 61
                        ->end()
488 61
                        ->arrayNode('messages')
489 61
                            ->useAttributeAsKey('name')
490 61
                            ->prototype('boolean')->end()
491 61
                            ->validate()
492 61
                                ->ifArray()
493
                                ->then(function (array $items) {
494 9
                                    foreach ($items as $class => $nomatter) {
495 9
                                        $this->testExceptionExists($class);
496
                                    }
497
498 8
                                    return $items;
499 61
                                })
500 61
                            ->end()
501 61
                        ->end()
502 61
                        ->booleanNode('debug')
503 61
                            ->defaultValue($this->debug)
504 61
                        ->end()
505 61
                    ->end()
506 61
                ->end()
507 61
            ->end();
508 61
    }
509
510 13
    private function testExceptionExists(string $throwable): void
511
    {
512 13
        if (!is_subclass_of($throwable, \Throwable::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Throwable::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
513 2
            throw new InvalidConfigurationException(sprintf('FOSRestBundle exception mapper: Could not load class "%s" or the class does not extend from "%s". Most probably this is a configuration problem.', $throwable, \Throwable::class));
514
        }
515 11
    }
516
}
517