Skip to content

Commit 152d7a1

Browse files
committed
Upgrade and first fixes
1 parent 72c2cd1 commit 152d7a1

9 files changed

+19
-23
lines changed

MultisiteLanguageSwitcher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ function msls_get_post( int $id ): \lloc\Msls\MslsOptionsPost {
208208
* - is_tax
209209
*
210210
* @param int $id
211-
* @return \lloc\Msls\MslsOptionsTax
211+
* @return \lloc\Msls\OptionsTaxInterface
212212
*/
213-
function msls_get_tax( int $id ): \lloc\Msls\MslsOptionsTax {
213+
function msls_get_tax( int $id ): \lloc\Msls\OptionsTaxInterface {
214214
return \lloc\Msls\MslsOptionsTax::create( $id );
215215
}
216216

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"require-dev": {
1313
"phpunit/phpunit": "^10",
1414
"brain/monkey": "^2.6",
15-
"phpstan/phpstan": "^1.11",
16-
"szepeviktor/phpstan-wordpress": "^1.3",
15+
"phpstan/phpstan": "^2.1.0",
16+
"szepeviktor/phpstan-wordpress": "^2.0.0",
1717
"phpstan/extension-installer": "^1.3",
1818
"antecedent/patchwork": "^2.1",
1919
"squizlabs/php_codesniffer": "^3.9",
2020
"phpcompatibility/php-compatibility": "^9.3",
2121
"wp-coding-standards/wpcs": "^3.0",
2222
"smeghead/php-class-diagram": "^1.3",
23-
"phpstan/phpstan-mockery": "^1.1"
23+
"phpstan/phpstan-mockery": "^2.0.0"
2424
},
2525
"autoload": {
2626
"psr-4": {

includes/ContentImport/AttachmentPathFinder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function filter_attachment_url( $url, $attachment_id ) {
9393
protected function get_source_post( $attachment_id, $msls_imported ) {
9494
$source_post = get_blog_post( $msls_imported['blog'], $msls_imported['post'] );
9595

96-
if ( empty( $source_post ) || ! $source_post instanceof \WP_Post ) {
96+
if ( ! $source_post instanceof \WP_Post ) {
9797
delete_post_meta( $attachment_id, self::LINKED );
9898

9999
return false;

includes/ContentImport/ContentImporter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
285285
* Returning a non `null` value here will override the creation of the importers map completely
286286
* and use the one returned in the filter.
287287
*
288-
* @param null $importers
288+
* @param ?array $importers
289289
* @param ImportCoordinates $import_coordinates
290290
*/
291291
$importers = apply_filters( 'msls_content_import_importers', null, $import_coordinates );
@@ -297,7 +297,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
297297
$this->logger = $this->logger ?: new ImportLogger( $import_coordinates );
298298
$this->relations = $this->relations ?: new Relations( $import_coordinates );
299299

300-
if ( ! empty( $importers ) && is_array( $importers ) ) {
300+
if ( ! empty( $importers ) ) {
301301
$source_post_id = $import_coordinates->source_post_id;
302302
$dest_lang = $import_coordinates->dest_lang;
303303
$dest_post_id = $import_coordinates->dest_post_id;

includes/ContentImport/ImportCoordinates.php

+2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ public function validate() {
5555
if ( ! get_blog_post( $this->source_blog_id, $this->source_post_id ) ) {
5656
return false;
5757
}
58+
5859
if ( ! get_blog_post( $this->dest_blog_id, $this->dest_post_id ) ) {
5960
return false;
6061
}
62+
6163
if ( ! $this->source_post instanceof \WP_Post ) {
6264
return false;
6365
}

includes/MslsBlogCollection.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,8 @@ public function get_blogs_of_reference_user( MslsOptions $options ) {
134134
);
135135

136136
$blogs = get_blogs_of_user( $reference_user );
137-
138-
/**
139-
* @todo Check if this is still useful
140-
*/
141-
if ( is_array( $blogs ) ) {
142-
foreach ( $blogs as $key => $blog ) {
143-
$blogs[ $key ]->blog_id = $blog->userblog_id;
144-
}
137+
foreach ( $blogs as $key => $blog ) {
138+
$blogs[ $key ]->blog_id = $blog->userblog_id;
145139
}
146140

147141
return $blogs;

includes/MslsOptionsTax.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MslsOptionsTax extends MslsOptions implements OptionsTaxInterface {
1616
/**
1717
* @param int $id
1818
*
19-
* @return MslsOptionsTax
19+
* @return OptionsTaxInterface
2020
*/
2121
public static function create( $id = 0 ): OptionsTaxInterface {
2222
$id = ! empty( $id ) ? (int) $id : get_queried_object_id();

includes/MslsOptionsTaxTerm.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MslsOptionsTaxTerm extends MslsOptionsTax implements OptionsTaxInterface {
2323
/**
2424
* Check and correct URL
2525
*
26-
* @param string $url
26+
* @param mixed $url
2727
* @param MslsOptionsTaxTerm $options
2828
*
2929
* @return string

includes/MslsPostTagClassic.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ public function the_input( ?\WP_Term $tag, string $title_format, string $item_fo
108108
/**
109109
* Prints options inputs
110110
*
111-
* @param MslsBlog $blog
112-
* @param string $type
113-
* @param MslsOptionsTax $mydata
114-
* @param string $item_format
111+
* @param MslsBlog $blog
112+
* @param string $type
113+
* @param OptionsTaxInterface $mydata
114+
* @param string $item_format
115115
*/
116-
public function print_option( MslsBlog $blog, string $type, MslsOptionsTax $mydata, string $item_format ): void {
116+
public function print_option( MslsBlog $blog, string $type, OptionsTaxInterface $mydata, string $item_format ): void {
117117
switch_to_blog( $blog->userblog_id );
118118

119119
$language = $blog->get_language();

0 commit comments

Comments
 (0)