summaryrefslogtreecommitdiff
path: root/vendor/symfony/translation/Loader/PhpFileLoader.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/translation/Loader/PhpFileLoader.php')
-rw-r--r--vendor/symfony/translation/Loader/PhpFileLoader.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/vendor/symfony/translation/Loader/PhpFileLoader.php b/vendor/symfony/translation/Loader/PhpFileLoader.php
index a0050e8db1..0991c3d3a2 100644
--- a/vendor/symfony/translation/Loader/PhpFileLoader.php
+++ b/vendor/symfony/translation/Loader/PhpFileLoader.php
@@ -18,11 +18,25 @@ namespace Symfony\Component\Translation\Loader;
*/
class PhpFileLoader extends FileLoader
{
+ private static $cache = [];
+
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
{
- return require $resource;
+ if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
+ self::$cache = null;
+ }
+
+ if (null === self::$cache) {
+ return require $resource;
+ }
+
+ if (isset(self::$cache[$resource])) {
+ return self::$cache[$resource];
+ }
+
+ return self::$cache[$resource] = require $resource;
}
}