[DependencyInjection] use inheritdoc for loaders

This commit is contained in:
Tobias Schultze 2014-10-13 21:09:32 +02:00
parent ddd2fe2032
commit 63b8c07e5b
6 changed files with 25 additions and 67 deletions

View File

@ -36,23 +36,15 @@ class ClosureLoader extends Loader
} }
/** /**
* Loads a Closure. * {@inheritdoc}
*
* @param \Closure $closure The resource
* @param string $type The resource type
*/ */
public function load($closure, $type = null) public function load($resource, $type = null)
{ {
call_user_func($closure, $this->container); call_user_func($resource, $this->container);
} }
/** /**
* Returns true if this class supports the given resource. * {@inheritdoc}
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {

View File

@ -27,8 +27,8 @@ abstract class FileLoader extends BaseFileLoader
/** /**
* Constructor. * Constructor.
* *
* @param ContainerBuilder $container A ContainerBuilder instance * @param ContainerBuilder $container A ContainerBuilder instance
* @param FileLocatorInterface $locator A FileLocator instance * @param FileLocatorInterface $locator A FileLocator instance
*/ */
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator) public function __construct(ContainerBuilder $container, FileLocatorInterface $locator)
{ {

View File

@ -22,22 +22,17 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
class IniFileLoader extends FileLoader class IniFileLoader extends FileLoader
{ {
/** /**
* Loads a resource. * {@inheritdoc}
*
* @param mixed $file The resource
* @param string $type The resource type
*
* @throws InvalidArgumentException When ini file is not valid
*/ */
public function load($file, $type = null) public function load($resource, $type = null)
{ {
$path = $this->locator->locate($file); $path = $this->locator->locate($resource);
$this->container->addResource(new FileResource($path)); $this->container->addResource(new FileResource($path));
$result = parse_ini_file($path, true); $result = parse_ini_file($path, true);
if (false === $result || array() === $result) { if (false === $result || array() === $result) {
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $file)); throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
} }
if (isset($result['parameters']) && is_array($result['parameters'])) { if (isset($result['parameters']) && is_array($result['parameters'])) {
@ -48,12 +43,7 @@ class IniFileLoader extends FileLoader
} }
/** /**
* Returns true if this class supports the given resource. * {@inheritdoc}
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {

View File

@ -24,18 +24,15 @@ use Symfony\Component\Config\Resource\FileResource;
class PhpFileLoader extends FileLoader class PhpFileLoader extends FileLoader
{ {
/** /**
* Loads a PHP file. * {@inheritdoc}
*
* @param mixed $file The resource
* @param string $type The resource type
*/ */
public function load($file, $type = null) public function load($resource, $type = null)
{ {
// the container and loader variables are exposed to the included file below // the container and loader variables are exposed to the included file below
$container = $this->container; $container = $this->container;
$loader = $this; $loader = $this;
$path = $this->locator->locate($file); $path = $this->locator->locate($resource);
$this->setCurrentDir(dirname($path)); $this->setCurrentDir(dirname($path));
$this->container->addResource(new FileResource($path)); $this->container->addResource(new FileResource($path));
@ -43,12 +40,7 @@ class PhpFileLoader extends FileLoader
} }
/** /**
* Returns true if this class supports the given resource. * {@inheritdoc}
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {

View File

@ -30,14 +30,11 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
class XmlFileLoader extends FileLoader class XmlFileLoader extends FileLoader
{ {
/** /**
* Loads an XML file. * {@inheritdoc}
*
* @param mixed $file The resource
* @param string $type The resource type
*/ */
public function load($file, $type = null) public function load($resource, $type = null)
{ {
$path = $this->locator->locate($file); $path = $this->locator->locate($resource);
$xml = $this->parseFile($path); $xml = $this->parseFile($path);
$xml->registerXPathNamespace('container', 'http://symfony.com/schema/dic/services'); $xml->registerXPathNamespace('container', 'http://symfony.com/schema/dic/services');
@ -61,12 +58,7 @@ class XmlFileLoader extends FileLoader
} }
/** /**
* Returns true if this class supports the given resource. * {@inheritdoc}
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {

View File

@ -32,14 +32,11 @@ class YamlFileLoader extends FileLoader
private $yamlParser; private $yamlParser;
/** /**
* Loads a Yaml file. * {@inheritdoc}
*
* @param mixed $file The resource
* @param string $type The resource type
*/ */
public function load($file, $type = null) public function load($resource, $type = null)
{ {
$path = $this->locator->locate($file); $path = $this->locator->locate($resource);
$content = $this->loadFile($path); $content = $this->loadFile($path);
@ -56,7 +53,7 @@ class YamlFileLoader extends FileLoader
// parameters // parameters
if (isset($content['parameters'])) { if (isset($content['parameters'])) {
if (!is_array($content['parameters'])) { if (!is_array($content['parameters'])) {
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $file)); throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $resource));
} }
foreach ($content['parameters'] as $key => $value) { foreach ($content['parameters'] as $key => $value) {
@ -68,16 +65,11 @@ class YamlFileLoader extends FileLoader
$this->loadFromExtensions($content); $this->loadFromExtensions($content);
// services // services
$this->parseDefinitions($content, $file); $this->parseDefinitions($content, $resource);
} }
/** /**
* Returns true if this class supports the given resource. * {@inheritdoc}
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {