@@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
98
98
{
99
99
foreach (self ::getInstalled () as $ installed ) {
100
100
if (isset ($ installed ['versions ' ][$ packageName ])) {
101
- return $ includeDevRequirements || empty ($ installed ['versions ' ][$ packageName ]['dev_requirement ' ]);
101
+ return $ includeDevRequirements || ! isset ($ installed ['versions ' ][$ packageName ]['dev_requirement ' ]) || $ installed [ ' versions ' ][ $ packageName ][ ' dev_requirement ' ] === false ;
102
102
}
103
103
}
104
104
@@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
119
119
*/
120
120
public static function satisfies (VersionParser $ parser , $ packageName , $ constraint )
121
121
{
122
- $ constraint = $ parser ->parseConstraints ($ constraint );
122
+ $ constraint = $ parser ->parseConstraints (( string ) $ constraint );
123
123
$ provided = $ parser ->parseConstraints (self ::getVersionRanges ($ packageName ));
124
124
125
125
return $ provided ->matches ($ constraint );
@@ -328,7 +328,9 @@ private static function getInstalled()
328
328
if (isset (self ::$ installedByVendor [$ vendorDir ])) {
329
329
$ installed [] = self ::$ installedByVendor [$ vendorDir ];
330
330
} elseif (is_file ($ vendorDir .'/composer/installed.php ' )) {
331
- $ installed [] = self ::$ installedByVendor [$ vendorDir ] = require $ vendorDir .'/composer/installed.php ' ;
331
+ /** @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 */
332
+ $ required = require $ vendorDir .'/composer/installed.php ' ;
333
+ $ installed [] = self ::$ installedByVendor [$ vendorDir ] = $ required ;
332
334
if (null === self ::$ installed && strtr ($ vendorDir .'/composer ' , '\\' , '/ ' ) === strtr (__DIR__ , '\\' , '/ ' )) {
333
335
self ::$ installed = $ installed [count ($ installed ) - 1 ];
334
336
}
@@ -340,12 +342,17 @@ private static function getInstalled()
340
342
// only require the installed.php file if this file is loaded from its dumped location,
341
343
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
342
344
if (substr (__DIR__ , -8 , 1 ) !== 'C ' ) {
343
- self ::$ installed = require __DIR__ . '/installed.php ' ;
345
+ /** @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 */
346
+ $ required = require __DIR__ . '/installed.php ' ;
347
+ self ::$ installed = $ required ;
344
348
} else {
345
349
self ::$ installed = array ();
346
350
}
347
351
}
348
- $ installed [] = self ::$ installed ;
352
+
353
+ if (self ::$ installed !== array ()) {
354
+ $ installed [] = self ::$ installed ;
355
+ }
349
356
350
357
return $ installed ;
351
358
}
0 commit comments