@@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
9898 {
9999 foreach (self ::getInstalled () as $ installed ) {
100100 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 ;
102102 }
103103 }
104104
@@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
119119 */
120120 public static function satisfies (VersionParser $ parser , $ packageName , $ constraint )
121121 {
122- $ constraint = $ parser ->parseConstraints ($ constraint );
122+ $ constraint = $ parser ->parseConstraints (( string ) $ constraint );
123123 $ provided = $ parser ->parseConstraints (self ::getVersionRanges ($ packageName ));
124124
125125 return $ provided ->matches ($ constraint );
@@ -328,7 +328,9 @@ private static function getInstalled()
328328 if (isset (self ::$ installedByVendor [$ vendorDir ])) {
329329 $ installed [] = self ::$ installedByVendor [$ vendorDir ];
330330 } 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 ;
332334 if (null === self ::$ installed && strtr ($ vendorDir .'/composer ' , '\\' , '/ ' ) === strtr (__DIR__ , '\\' , '/ ' )) {
333335 self ::$ installed = $ installed [count ($ installed ) - 1 ];
334336 }
@@ -340,12 +342,17 @@ private static function getInstalled()
340342 // only require the installed.php file if this file is loaded from its dumped location,
341343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
342344 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 ;
344348 } else {
345349 self ::$ installed = array ();
346350 }
347351 }
348- $ installed [] = self ::$ installed ;
352+
353+ if (self ::$ installed !== array ()) {
354+ $ installed [] = self ::$ installed ;
355+ }
349356
350357 return $ installed ;
351358 }
0 commit comments