class ChainVersionResolver implements VersionResolverInterface
22
{
23
private $resolvers = [];
24
25
/**
26
* @var VersionResolverInterface[]
27
*/
28
8
public function __construct(array $resolvers)
29
{
30
8
foreach ($resolvers as $resolver) {
31
$this->addResolver($resolver);
32
}
33
8
}
34
35
/**
36
* {@inheritdoc}
37
*/
38
8
public function resolve(Request $request)
39
{
40
8
foreach ($this->resolvers as $resolver) {
41
8
$version = $resolver->resolve($request);
42
43
8
if (null !== $version && !is_string($version)) {
44
@trigger_error(sprintf('Not returning a string or null from %s::resolve() when implementing the %s is deprecated since FOSRestBundle 2.8.', get_class($resolver), VersionResolverInterface::class), E_USER_DEPRECATED);
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
Loading history...
45
}
46
47
8
if (null !== $version && false !== $version) {
48
4
return $version;
49
}
50
}
51
52
4
return null;
53
}
54
55
8
public function addResolver(VersionResolverInterface $resolver)
If you suppress an error, we recommend checking for the error condition explicitly: