Skip to content

Commit fadfb7c

Browse files
committed
PHPStan issues addressed
1 parent 4025dba commit fadfb7c

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

includes/ContentImport/AttachmentPathFinder.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ class AttachmentPathFinder extends MslsRegistryInstance {
88

99
const LINKED = '_msls_linked';
1010

11-
public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ) {
11+
/**
12+
* @param array $sources
13+
* @param mixed $sizeArray
14+
* @param string $imageSrc
15+
* @param mixed $imageMeta
16+
* @param int $attachmentId
17+
* @return array
18+
*/
19+
public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ): array {
1220
if ( ! $msls_imported = $this->has_import_data( $attachmentId ) ) {
1321
return $sources;
1422
}
@@ -32,6 +40,10 @@ public function filter_srcset( array $sources, $sizeArray, $imageSrc, $imageMeta
3240
return $sources;
3341
}
3442

43+
/**
44+
* @param int $attachment_id
45+
* @return array|false
46+
*/
3547
protected function has_import_data( $attachment_id ) {
3648
if ( empty( $attachment_id ) ) {
3749
return false;
@@ -53,6 +65,11 @@ protected function has_import_data( $attachment_id ) {
5365
return $msls_imported;
5466
}
5567

68+
/**
69+
* @param string $url
70+
* @param int $attachment_id
71+
* @return string
72+
*/
5673
public function filter_attachment_url( $url, $attachment_id ) {
5774
if ( ! $msls_imported = $this->has_import_data( $attachment_id ) ) {
5875
return $url;
@@ -68,7 +85,7 @@ public function filter_attachment_url( $url, $attachment_id ) {
6885
}
6986

7087
/**
71-
* @param int $attachment_id
88+
* @param int $attachment_id
7289
* @param array $msls_imported
7390
*
7491
* @return \WP_Post|false
@@ -84,4 +101,4 @@ protected function get_source_post( $attachment_id, $msls_imported ) {
84101

85102
return $source_post;
86103
}
87-
}
104+
}

includes/ContentImport/ContentImporter.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function get_logger() {
6363
/**
6464
* @param \lloc\Msls\ContentImport\ImportLogger $logger
6565
*/
66-
public function set_logger( $logger ) {
66+
public function set_logger( $logger ): void {
6767
$this->logger = $logger;
6868
}
6969

@@ -77,7 +77,7 @@ public function get_relations() {
7777
/**
7878
* @param \lloc\Msls\ContentImport\Relations $relations
7979
*/
80-
public function set_relations( $relations ) {
80+
public function set_relations( $relations ): void {
8181
$this->relations = $relations;
8282
}
8383

@@ -179,6 +179,11 @@ public function parse_sources() {
179179
return array_map( 'intval', $import_data );
180180
}
181181

182+
/**
183+
* @param int $blog_id
184+
*
185+
* @return int
186+
*/
182187
protected function get_the_blog_post_ID( $blog_id ) {
183188
switch_to_blog( $blog_id );
184189

@@ -331,9 +336,9 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
331336
}
332337

333338
/**
334-
* @param array $data
339+
* @param int $blog_id
335340
* @param int $post_id
336-
*
341+
* @param array $data
337342
* @return array
338343
*/
339344
protected function update_inserted_blog_post_data( $blog_id, $post_id, array $data ) {
@@ -346,6 +351,11 @@ protected function update_inserted_blog_post_data( $blog_id, $post_id, array $da
346351
return $data;
347352
}
348353

354+
/**
355+
* @param int $dest_blog_id
356+
* @param int $post_id
357+
* @return void
358+
*/
349359
protected function redirect_to_blog_post( $dest_blog_id, $post_id ) {
350360
switch_to_blog( $dest_blog_id );
351361
$edit_post_link = html_entity_decode( get_edit_post_link( $post_id ) );

includes/ContentImport/ImportCoordinates.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ImportCoordinates {
4444
* @var array An array keeping track of which importer (slug) should be used for
4545
* a specific import type, shape [ <import-type> => <slug> ]
4646
*/
47-
public $importers = [];
47+
public $importers = array();
4848

4949
/**
5050
* Validates the coordinates.
@@ -88,11 +88,11 @@ public function get_importer_for( $importer_type ) {
8888
/**
8989
* Parses the importers from request superglobals.
9090
*/
91-
public function parse_importers_from_request() {
91+
public function parse_importers_from_request(): void {
9292
// bitmask
9393
$source = isset( $_REQUEST[ self::IMPORTERS_GLOBAL_KEY ] ) * 100
94-
+ isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10
95-
+ isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] );
94+
+ isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10
95+
+ isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] );
9696

9797
switch ( $source ) {
9898
case 100:
@@ -114,7 +114,7 @@ public function parse_importers_from_request() {
114114

115115
$importers = isset( $source[ self::IMPORTERS_GLOBAL_KEY ] ) && is_array( $source[ self::IMPORTERS_GLOBAL_KEY ] )
116116
? $source[ self::IMPORTERS_GLOBAL_KEY ]
117-
: [];
117+
: array();
118118

119119
foreach ( $importers as $importer_type => $slug ) {
120120
$this->set_importer_for( $importer_type, $slug );
@@ -127,7 +127,7 @@ public function parse_importers_from_request() {
127127
* @param string $importer_type
128128
* @param string $slug
129129
*/
130-
public function set_importer_for( $importer_type, $slug ) {
130+
public function set_importer_for( $importer_type, $slug ): void {
131131
$this->importers[ $importer_type ] = $slug;
132132
}
133133
}

0 commit comments

Comments
 (0)