for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DH\NavigationBundle\Provider;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* An abstract factory that makes it easier to implement new factories. A class that extend the AbstractFactory
* should override AbstractFactory::configureOptionResolver().
*
* @author Tobias Nyholm <[email protected]>
*/
abstract class AbstractFactory implements ProviderFactoryInterface
{
abstract protected function getProvider(array $config): ProviderInterface;
* {@inheritdoc}
public function createProvider(array $options = []): ProviderInterface
$resolver = new OptionsResolver();
static::configureOptionResolver($resolver);
$config = $resolver->resolve($options);
return $this->getProvider($config);
}
public static function validate(array $options, $providerName): void
try {
$resolver->resolve($options);
} catch (\Exception $e) {
$message = sprintf(
'Error while configure provider "%s". Verify your configuration. %s',
$providerName,
$e->getMessage()
);
throw new InvalidConfigurationException($message, $e->getCode(), $e);
* By default we do not have any options to configure.
* A factory should override this function and configure the options resolver.
protected static function configureOptionResolver(OptionsResolver $resolver): void
$resolver
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected static function configureOptionResolver(/** @scrutinizer ignore-unused */ OptionsResolver $resolver): void
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.