Skip to content

Commit

Permalink
[DependencyInjection] use inheritdoc for loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Oct 13, 2014
1 parent ddd2fe2 commit 63b8c07
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 67 deletions.
16 changes: 4 additions & 12 deletions src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php
Expand Up @@ -36,23 +36,15 @@ public function __construct(ContainerBuilder $container)
}

/**
* Loads a Closure.
*
* @param \Closure $closure The resource
* @param string $type The resource type
* {@inheritdoc}
*/
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.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
Expand Down
Expand Up @@ -27,8 +27,8 @@ abstract class FileLoader extends BaseFileLoader
/**
* Constructor.
*
* @param ContainerBuilder $container A ContainerBuilder instance
* @param FileLocatorInterface $locator A FileLocator instance
* @param ContainerBuilder $container A ContainerBuilder instance
* @param FileLocatorInterface $locator A FileLocator instance
*/
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator)
{
Expand Down
20 changes: 5 additions & 15 deletions src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php
Expand Up @@ -22,22 +22,17 @@
class IniFileLoader extends FileLoader
{
/**
* Loads a resource.
*
* @param mixed $file The resource
* @param string $type The resource type
*
* @throws InvalidArgumentException When ini file is not valid
* {@inheritdoc}
*/
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));

$result = parse_ini_file($path, true);
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'])) {
Expand All @@ -48,12 +43,7 @@ public function load($file, $type = null)
}

/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
Expand Down
16 changes: 4 additions & 12 deletions src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php
Expand Up @@ -24,31 +24,23 @@
class PhpFileLoader extends FileLoader
{
/**
* Loads a PHP file.
*
* @param mixed $file The resource
* @param string $type The resource type
* {@inheritdoc}
*/
public function load($file, $type = null)
public function load($resource, $type = null)
{
// the container and loader variables are exposed to the included file below
$container = $this->container;
$loader = $this;

$path = $this->locator->locate($file);
$path = $this->locator->locate($resource);
$this->setCurrentDir(dirname($path));
$this->container->addResource(new FileResource($path));

include $path;
}

/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
Expand Down
16 changes: 4 additions & 12 deletions src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
Expand Up @@ -30,14 +30,11 @@
class XmlFileLoader extends FileLoader
{
/**
* Loads an XML file.
*
* @param mixed $file The resource
* @param string $type The resource type
* {@inheritdoc}
*/
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->registerXPathNamespace('container', 'http://symfony.com/schema/dic/services');
Expand All @@ -61,12 +58,7 @@ public function load($file, $type = null)
}

/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
Expand Down
Expand Up @@ -32,14 +32,11 @@ class YamlFileLoader extends FileLoader
private $yamlParser;

/**
* Loads a Yaml file.
*
* @param mixed $file The resource
* @param string $type The resource type
* {@inheritdoc}
*/
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);

Expand All @@ -56,7 +53,7 @@ public function load($file, $type = null)
// parameters
if (isset($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) {
Expand All @@ -68,16 +65,11 @@ public function load($file, $type = null)
$this->loadFromExtensions($content);

// services
$this->parseDefinitions($content, $file);
$this->parseDefinitions($content, $resource);
}

/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return bool true if this class supports the given resource, false otherwise
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
Expand Down

0 comments on commit 63b8c07

Please sign in to comment.