Skip to content

Commit d9563eb

Browse files
authored
Feature/phpstan upgrade (#431)
* Upgrade and issues resolved
1 parent 36f3a00 commit d9563eb

16 files changed

+53
-43
lines changed

MultisiteLanguageSwitcher.php

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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/Component/Icon/IconLabel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace lloc\Msls\Component\Icon;
44

55
use lloc\Msls\Component\Icon;
6-
use lloc\Msls\MslsPlugin;
76

87
/**
98
* Class IconLabel

includes/ContentImport/AttachmentPathFinder.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ImportCoordinates {
2626
public $dest_post_id;
2727

2828
/**
29-
* @var \WP_Post
29+
* @var ?\WP_Post
3030
*/
3131
public $source_post;
3232

@@ -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/ContentImport/Importers/Map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Map extends MslsRegistryInstance {
1616
public function make( ImportCoordinates $import_coordinates ) {
1717
$importers = array_map(
1818
function ( $factory ) use ( $import_coordinates ) {
19-
/** @var ImportersFactory $factory */
19+
/** @var ImportersBaseFactory $factory */
2020
return $factory->make( $import_coordinates );
2121
},
2222
$this->factories()

includes/MslsAdmin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ public function get_options_page_link(): string {
8686
*/
8787
public function __call( $method, $args ) {
8888
$parts = explode( '_', $method, 2 );
89-
90-
if ( is_array( $parts ) && 'rewrite' === $parts[0] ) {
89+
if ( count( $parts ) > 0 && 'rewrite' === $parts[0] ) {
9190
$this->render_rewrite( $parts[1] );
9291
return;
9392
}

includes/MslsBlogCollection.php

Lines changed: 2 additions & 8 deletions
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/MslsOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function get_available_languages(): array {
370370
/**
371371
* The 'blog'-slug-problem :/
372372
*
373-
* @param string $url
373+
* @param mixed $url
374374
* @param MslsOptions $options
375375
*
376376
* @return string

0 commit comments

Comments
 (0)