PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 4.1.2
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v4.1.2
4.1.2 4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
← All changes | includes/vendor/composer/ClassLoader.php +24 -15 1.0.04.1.2 View file →
@@ -41,8 +41,11 @@
41 41 * @see https://www.php-fig.org/psr/psr-4/
42 42 */
43 43 class ClassLoader
44 44 {
45 + /** @var \Closure(string):void */
46 + private static $includeFile;
47 +
45 48 /** @var ?string */
46 49 private $vendorDir;
47 50
48 51 // PSR-4
@@ -105,8 +108,9 @@
105 108 */
106 109 public function __construct($vendorDir = null)
107 110 {
108 111 $this->vendorDir = $vendorDir;
112 + self::initializeIncludeClosure();
109 113 }
110 114
111 115 /**
112 116 * @return string[]
@@ -148,9 +152,9 @@
148 152 }
149 153
150 154 /**
151 155 * @return string[] Array of classname => path
152 - * @psalm-var array<string, string>
156 + * @psalm-return array<string, string>
153 157 */
154 158 public function getClassMap()
155 159 {
156 160 return $this->classMap;
@@ -424,9 +428,9 @@
424 428 */
425 429 public function loadClass($class)
426 430 {
427 431 if ($file = $this->findFile($class)) {
428 - includeFile($file);
432 + (self::$includeFile)($file);
429 433
430 434 return true;
431 435 }
432 436
@@ -554,19 +558,24 @@
554 558 }
555 559
556 560 return false;
557 561 }
558 -}
559 562
560 -/**
561 - * Scope isolated include.
562 - *
563 - * Prevents access to $this/self from included files.
564 - *
565 - * @param string $file
566 - * @return void
567 - * @private
568 - */
569 -function includeFile($file)
570 -{
571 - include $file;
563 + private static function initializeIncludeClosure(): void
564 + {
565 + if (self::$includeFile !== null) {
566 + return;
567 + }
568 +
569 + /**
570 + * Scope isolated include.
571 + *
572 + * Prevents access to $this/self from included files.
573 + *
574 + * @param string $file
575 + * @return void
576 + */
577 + self::$includeFile = static function($file) {
578 + include $file;
579 + };
580 + }
572 581 }