2424 */
2525class InstalledVersions
2626{
27- /**
28- * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
29- * @internal
30- */
31- private static $ selfDir = null ;
3227 /**
3328 * @var mixed[]|null
3429 * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
@@ -57,12 +52,12 @@ public static function getInstalledPackages()
5752 {
5853 $ packages = array ();
5954 foreach (self ::getInstalled () as $ installed ) {
60- $ packages [] = \ array_keys ($ installed ['versions ' ]);
55+ $ packages [] = array_keys ($ installed ['versions ' ]);
6156 }
6257 if (1 === \count ($ packages )) {
6358 return $ packages [0 ];
6459 }
65- return \ array_keys (\ array_flip (\call_user_func_array ('ComfortSmtpScoped \\ array_merge ' , $ packages )));
60+ return array_keys (array_flip (\call_user_func_array ('array_merge ' , $ packages )));
6661 }
6762 /**
6863 * Returns a list of all package names with a specific type e.g. 'library'
@@ -138,16 +133,16 @@ public static function getVersionRanges($packageName)
138133 if (isset ($ installed ['versions ' ][$ packageName ]['pretty_version ' ])) {
139134 $ ranges [] = $ installed ['versions ' ][$ packageName ]['pretty_version ' ];
140135 }
141- if (\ array_key_exists ('aliases ' , $ installed ['versions ' ][$ packageName ])) {
142- $ ranges = \ array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['aliases ' ]);
136+ if (array_key_exists ('aliases ' , $ installed ['versions ' ][$ packageName ])) {
137+ $ ranges = array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['aliases ' ]);
143138 }
144- if (\ array_key_exists ('replaced ' , $ installed ['versions ' ][$ packageName ])) {
145- $ ranges = \ array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['replaced ' ]);
139+ if (array_key_exists ('replaced ' , $ installed ['versions ' ][$ packageName ])) {
140+ $ ranges = array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['replaced ' ]);
146141 }
147- if (\ array_key_exists ('provided ' , $ installed ['versions ' ][$ packageName ])) {
148- $ ranges = \ array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['provided ' ]);
142+ if (array_key_exists ('provided ' , $ installed ['versions ' ][$ packageName ])) {
143+ $ ranges = array_merge ($ ranges , $ installed ['versions ' ][$ packageName ]['provided ' ]);
149144 }
150- return \ implode (' || ' , $ ranges );
145+ return implode (' || ' , $ ranges );
151146 }
152147 throw new \OutOfBoundsException ('Package " ' . $ packageName . '" is not installed ' );
153148 }
@@ -234,12 +229,12 @@ public static function getRootPackage()
234229 */
235230 public static function getRawData ()
236231 {
237- @\ trigger_error ('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. ' , \E_USER_DEPRECATED );
232+ @trigger_error ('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. ' , \E_USER_DEPRECATED );
238233 if (null === self ::$ installed ) {
239234 // only require the installed.php file if this file is loaded from its dumped location,
240235 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
241- if (\ substr (__DIR__ , -8 , 1 ) !== 'C ' ) {
242- self ::$ installed = ( include __DIR__ . '/installed.php ' ) ;
236+ if (substr (__DIR__ , -8 , 1 ) !== 'C ' ) {
237+ self ::$ installed = include __DIR__ . '/installed.php ' ;
243238 } else {
244239 self ::$ installed = array ();
245240 }
@@ -284,36 +279,26 @@ public static function reload($data)
284279 // all installed packages for example
285280 self ::$ installedIsLocalDir = \false;
286281 }
287- /**
288- * @return string
289- */
290- private static function getSelfDir ()
291- {
292- if (self ::$ selfDir === null ) {
293- self ::$ selfDir = \strtr (__DIR__ , '\\' , '/ ' );
294- }
295- return self ::$ selfDir ;
296- }
297282 /**
298283 * @return array[]
299284 * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
300285 */
301286 private static function getInstalled ()
302287 {
303288 if (null === self ::$ canGetVendors ) {
304- self ::$ canGetVendors = \ method_exists ('Composer \\ Autoload \ \ClassLoader ' , 'getRegisteredLoaders ' );
289+ self ::$ canGetVendors = method_exists ('Composer\Autoload\ClassLoader ' , 'getRegisteredLoaders ' );
305290 }
306291 $ installed = array ();
307292 $ copiedLocalDir = \false;
308293 if (self ::$ canGetVendors ) {
309- $ selfDir = self :: getSelfDir ( );
294+ $ selfDir = strtr ( __DIR__ , '\\' , ' / ' );
310295 foreach (ClassLoader::getRegisteredLoaders () as $ vendorDir => $ loader ) {
311- $ vendorDir = \ strtr ($ vendorDir , '\\' , '/ ' );
296+ $ vendorDir = strtr ($ vendorDir , '\\' , '/ ' );
312297 if (isset (self ::$ installedByVendor [$ vendorDir ])) {
313298 $ installed [] = self ::$ installedByVendor [$ vendorDir ];
314- } elseif (\ is_file ($ vendorDir . '/composer/installed.php ' )) {
299+ } elseif (is_file ($ vendorDir . '/composer/installed.php ' )) {
315300 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
316- $ required = ( require $ vendorDir . '/composer/installed.php ' ) ;
301+ $ required = require $ vendorDir . '/composer/installed.php ' ;
317302 self ::$ installedByVendor [$ vendorDir ] = $ required ;
318303 $ installed [] = $ required ;
319304 if (self ::$ installed === null && $ vendorDir . '/composer ' === $ selfDir ) {
@@ -329,9 +314,9 @@ private static function getInstalled()
329314 if (null === self ::$ installed ) {
330315 // only require the installed.php file if this file is loaded from its dumped location,
331316 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
332- if (\ substr (__DIR__ , -8 , 1 ) !== 'C ' ) {
317+ if (substr (__DIR__ , -8 , 1 ) !== 'C ' ) {
333318 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
334- $ required = ( require __DIR__ . '/installed.php ' ) ;
319+ $ required = require __DIR__ . '/installed.php ' ;
335320 self ::$ installed = $ required ;
336321 } else {
337322 self ::$ installed = array ();
0 commit comments