@@ -85,15 +85,15 @@ public function upload_files( string $processed_site_path ) : void {
8585 ltrim ( $ cache_key , '/ ' );
8686
8787 $ mime_type = MimeTypes::GuessMimeType ( $ filename );
88- if ( " text/ " === substr ( $ mime_type , 0 , 5 ) ) {
88+ if ( ' text/ ' === substr ( $ mime_type , 0 , 5 ) ) {
8989 $ mime_type = $ mime_type . '; charset=UTF-8 ' ;
9090 }
9191
9292 $ put_data ['Key ' ] = $ s3_key ;
9393 $ put_data ['ContentType ' ] = $ mime_type ;
94- $ put_data_hash = md5 ( json_encode ( $ put_data ) );
94+ $ put_data_hash = md5 ( ( string ) json_encode ( $ put_data ) );
9595 $ put_data ['Body ' ] = file_get_contents ( $ filename );
96- $ body_hash = md5 ( $ put_data ['Body ' ] );
96+ $ body_hash = md5 ( ( string ) $ put_data ['Body ' ] );
9797 $ hash = md5 ( $ put_data_hash . $ body_hash );
9898
9999 $ is_cached = \WP2Static \DeployCache::fileisCached (
@@ -113,7 +113,7 @@ public function upload_files( string $processed_site_path ) : void {
113113
114114 if ( $ cf_max_paths >= count ( $ cf_stale_paths ) ) {
115115 $ cf_key = $ cache_key ;
116- if ( 0 === substr_compare ( $ cf_key , '/index.html ' , -11 ) ) {
116+ if ( 0 === substr_compare ( $ cf_key , '/index.html ' , -11 ) ) {
117117 $ cf_key = substr ( $ cf_key , 0 , -10 );
118118 }
119119 array_push ( $ cf_stale_paths , $ cf_key );
@@ -142,7 +142,7 @@ public function upload_files( string $processed_site_path ) : void {
142142
143143 $ put_data ['Key ' ] = $ s3_key ;
144144 $ put_data ['WebsiteRedirectLocation ' ] = $ redirect ['redirect_to ' ];
145- $ hash = md5 ( json_encode ( $ put_data ) );
145+ $ hash = md5 ( ( string ) json_encode ( $ put_data ) );
146146
147147 $ is_cached = \WP2Static \DeployCache::fileisCached (
148148 $ cache_key ,
@@ -161,7 +161,7 @@ public function upload_files( string $processed_site_path ) : void {
161161
162162 if ( $ cf_max_paths >= count ( $ cf_stale_paths ) ) {
163163 $ cf_key = $ cache_key ;
164- if ( 0 === substr_compare ( $ cf_key , '/index.html ' , -11 ) ) {
164+ if ( 0 === substr_compare ( $ cf_key , '/index.html ' , -11 ) ) {
165165 $ cf_key = substr ( $ cf_key , 0 , -10 );
166166 }
167167 array_push ( $ cf_stale_paths , $ cf_key );
@@ -170,7 +170,7 @@ public function upload_files( string $processed_site_path ) : void {
170170 }
171171
172172 $ distribution_id = Controller::getValue ( 'cfDistributionID ' );
173- $ num_stale = count ( $ cf_stale_paths );
173+ $ num_stale = count ( $ cf_stale_paths );
174174 if ( $ distribution_id && $ num_stale > 0 ) {
175175 if ( $ num_stale > $ cf_max_paths ) {
176176 self ::cloudfront_invalidate_all_items ();
@@ -207,7 +207,7 @@ public static function s3_client() : \Aws\S3\S3Client {
207207 Controller::getValue ( 's3SecretAccessKey ' )
208208 ),
209209 ];
210- } else if ( Controller::getValue ( 's3Profile ' ) ) {
210+ } elseif ( Controller::getValue ( 's3Profile ' ) ) {
211211 $ client_options ['profile ' ] = Controller::getValue ( 's3Profile ' );
212212 }
213213
@@ -241,7 +241,7 @@ public static function cloudfront_client() : \Aws\CloudFront\CloudFrontClient {
241241 'credentials ' => $ credentials ,
242242 ]
243243 );
244- } else if ( Controller::getValue ( 'cfProfile ' ) ) {
244+ } elseif ( Controller::getValue ( 'cfProfile ' ) ) {
245245 // Use the specified profile.
246246 $ client = \Aws \CloudFront \CloudFrontClient::factory (
247247 [
@@ -263,8 +263,12 @@ public static function cloudfront_client() : \Aws\CloudFront\CloudFrontClient {
263263 return $ client ;
264264 }
265265
266- public static function create_invalidation ( string $ distribution_id , array $ items )
267- : string {
266+ /**
267+ * Create invalidation in CloudFront
268+ *
269+ * @param mixed[] $items mixed array
270+ */
271+ public static function create_invalidation ( string $ distribution_id , array $ items ) : string {
268272 $ client = self ::cloudfront_client ();
269273
270274 return $ client ->createInvalidation (
@@ -289,8 +293,10 @@ public static function cloudfront_invalidate_all_items() : void {
289293 \WP2Static \WsLog::l ( 'Invalidating all CloudFront paths ' );
290294
291295 try {
292- self ::create_invalidation ( Controller::getValue ( 'cfDistributionID ' ),
293- [ '/* ' ]);
296+ self ::create_invalidation (
297+ Controller::getValue ( 'cfDistributionID ' ),
298+ [ '/* ' ]
299+ );
294300 } catch ( AwsException $ e ) {
295301 // output error message if fails
296302 error_log ( $ e ->getMessage () );
0 commit comments