@@ -34,16 +34,22 @@ public static function analyzeComposerDependencies(string $composerJsonPath = 'c
3434 return [];
3535 }
3636
37- // Check for AWS SDK
38- if (isset ($ require ['aws/aws-sdk-php ' ])) {
37+ // Check for AWS SDK in composer.json or vendor directory
38+ $ hasAwsSdk = isset ($ require ['aws/aws-sdk-php ' ]) ||
39+ (is_dir ('vendor/aws/aws-sdk-php ' ) && file_exists ('vendor/aws/aws-sdk-php/composer.json ' ));
40+
41+ if ($ hasAwsSdk ) {
3942 $ isOptimized = self ::isAwsSdkOptimized ($ composer );
4043 if (!$ isOptimized ) {
4144 $ warnings [] = 'AWS SDK detected - optimize your deployment size: https://github.com/aws/aws-sdk-php/tree/master/src/Script/Composer ' ;
4245 }
4346 }
4447
45- // Check for Google SDK
46- if (isset ($ require ['google/apiclient ' ]) || isset ($ require ['google/cloud ' ])) {
48+ // Check for Google SDK in composer.json or vendor directory
49+ $ hasGoogleSdk = isset ($ require ['google/apiclient ' ]) ||
50+ (is_dir ('vendor/google/apiclient ' ) && file_exists ('vendor/google/apiclient/composer.json ' ));
51+
52+ if ($ hasGoogleSdk ) {
4753 $ isOptimized = self ::isGoogleSdkOptimized ($ composer );
4854 if (!$ isOptimized ) {
4955 $ warnings [] = 'Google SDK detected - optimize your deployment size: https://github.com/googleapis/google-api-php-client#cleaning-up-unused-services ' ;
@@ -68,18 +74,12 @@ private static function isAwsSdkOptimized(array $composer): bool
6874 if (is_array ($ scripts ) && isset ($ scripts ['pre-autoload-dump ' ])) {
6975 $ preAutoloadDump = (array ) $ scripts ['pre-autoload-dump ' ];
7076 foreach ($ preAutoloadDump as $ script ) {
71- if (is_string ($ script ) && str_contains ($ script , 'aws-sdk-php ' ) && str_contains ( $ script , ' remove-unused-services ' )) {
77+ if (is_string ($ script ) && str_contains ($ script , 'Aws \\ Script \\ Composer \\ Composer::removeUnusedServices ' )) {
7278 return true ;
7379 }
7480 }
7581 }
7682
77- // Check for custom AWS SDK optimizations in extra section
78- $ extra = $ composer ['extra ' ] ?? [];
79- if (is_array ($ extra ) && isset ($ extra ['aws ' ]) && is_array ($ extra ['aws ' ]) && isset ($ extra ['aws ' ]['includes ' ])) {
80- return true ;
81- }
82-
8383 return false ;
8484 }
8585
@@ -94,18 +94,12 @@ private static function isGoogleSdkOptimized(array $composer): bool
9494 if (is_array ($ scripts ) && isset ($ scripts ['pre-autoload-dump ' ])) {
9595 $ preAutoloadDump = (array ) $ scripts ['pre-autoload-dump ' ];
9696 foreach ($ preAutoloadDump as $ script ) {
97- if (is_string ($ script ) && str_contains ($ script , 'google ' ) && str_contains ( $ script , ' remove-unused-services ' )) {
97+ if (is_string ($ script ) && str_contains ($ script , 'Google \\ Task \\ Composer::cleanup ' )) {
9898 return true ;
9999 }
100100 }
101101 }
102102
103- // Check for custom Google SDK optimizations in extra section
104- $ extra = $ composer ['extra ' ] ?? [];
105- if (is_array ($ extra ) && isset ($ extra ['google ' ]) && is_array ($ extra ['google ' ]) && isset ($ extra ['google ' ]['exclude_files ' ])) {
106- return true ;
107- }
108-
109103 return false ;
110104 }
111105}
0 commit comments