X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fdependency-injection%2FLoader%2FPhpFileLoader.php;h=ff8df43f8408f02c1f6d50b0a0dc246fc5e7e231;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=08c1d9af4f653ddc11a395677a8ecfa23fceb848;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php b/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php index 08c1d9af4..ff8df43f8 100644 --- a/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php @@ -11,7 +11,7 @@ namespace Symfony\Component\DependencyInjection\Loader; -use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; /** * PhpFileLoader loads service definitions from a PHP file. @@ -33,10 +33,19 @@ class PhpFileLoader extends FileLoader $loader = $this; $path = $this->locator->locate($resource); - $this->setCurrentDir(dirname($path)); - $this->container->addResource(new FileResource($path)); + $this->setCurrentDir(\dirname($path)); + $this->container->fileExists($path); - include $path; + // the closure forbids access to the private scope in the included file + $load = \Closure::bind(function ($path) use ($container, $loader, $resource, $type) { + return include $path; + }, $this, ProtectedPhpFileLoader::class); + + $callback = $load($path); + + if ($callback instanceof \Closure) { + $callback(new ContainerConfigurator($this->container, $this, $this->instanceof, $path, $resource), $this->container, $this); + } } /** @@ -44,6 +53,21 @@ class PhpFileLoader extends FileLoader */ public function supports($resource, $type = null) { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION); + if (!\is_string($resource)) { + return false; + } + + if (null === $type && 'php' === pathinfo($resource, PATHINFO_EXTENSION)) { + return true; + } + + return 'php' === $type; } } + +/** + * @internal + */ +final class ProtectedPhpFileLoader extends PhpFileLoader +{ +}