Skip to content

Commit 314a634

Browse files
committed
PHPStan issues addressed
1 parent 79e0379 commit 314a634

13 files changed

+27
-72
lines changed

includes/ContentImport/ContentImporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ContentImporter extends MslsRegistryInstance {
5050
* @param \lloc\Msls\MslsMain|null $main
5151
*/
5252
public function __construct( MslsMain $main = null ) {
53-
$this->main = $main ?: MslsMain::init();
53+
$this->main = $main ?: MslsMain::create();
5454
}
5555

5656
/**

includes/MslsAdmin.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@ class MslsAdmin extends MslsMain {
2929
public const MAX_REFERENCE_USERS = 100;
3030

3131
/**
32-
* Factory
33-
*
3432
* @codeCoverageIgnore
35-
*
36-
* @return MslsAdmin
3733
*/
38-
public static function init() {
34+
public static function init(): void {
3935
$obj = MslsRegistry::get_object( __CLASS__ );
4036
if ( ! $obj ) {
4137
$obj = new static( msls_options(), msls_blog_collection() );
@@ -60,8 +56,6 @@ public static function init() {
6056
add_filter( 'msls_admin_validate', array( $obj, 'set_blog_language' ) );
6157
}
6258
}
63-
64-
return $obj;
6559
}
6660

6761
/**

includes/MslsBlogCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ public function get_blog( $language ) {
179179
*
180180
* @param string $language
181181
*
182-
* @return string|null
182+
* @return ?int
183183
*/
184-
public function get_blog_id( $language ) {
184+
public function get_blog_id( string $language ): ?int {
185185
$blog = $this->get_blog( $language );
186186
$blog_id = ! is_null( $blog ) ? $blog->userblog_id : null;
187187

includes/MslsContentFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function content_filter( string $content ) {
4343
* @return string
4444
*/
4545
public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
46-
$links_arr = MslsOutput::init()->get( 1, true, true );
46+
$links_arr = MslsOutput::create()->get( 1, true, true );
4747
$links_str = $this->format_available_languages( $links_arr );
4848

4949
/* translators: %s: list of languages */

includes/MslsCustomColumn.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
class MslsCustomColumn extends MslsMain {
1212

1313
/**
14-
* Factory
15-
*
1614
* @codeCoverageIgnore
17-
*
18-
* @return MslsCustomColumn
1915
*/
20-
public static function init() {
16+
public static function init(): void {
2117
$options = msls_options();
2218
$collection = msls_blog_collection();
2319
$obj = new static( $options, $collection );
@@ -31,8 +27,6 @@ public static function init() {
3127
add_action( 'trashed_post', array( $obj, 'delete' ) );
3228
}
3329
}
34-
35-
return $obj;
3630
}
3731

3832
/**

includes/MslsCustomColumnTaxonomy.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
class MslsCustomColumnTaxonomy extends MslsCustomColumn {
1212

1313
/**
14-
* Factory
15-
*
1614
* @codeCoverageIgnore
17-
*
18-
* @return MslsCustomColumnTaxonomy
1915
*/
20-
public static function init() {
16+
public static function init(): void {
2117
$options = msls_options();
2218
$collection = msls_blog_collection();
2319
$obj = new static( $options, $collection );
@@ -31,8 +27,6 @@ public static function init() {
3127
add_action( "delete_{$taxonomy}", array( $obj, 'delete' ) );
3228
}
3329
}
34-
35-
return $obj;
3630
}
3731

3832
/**

includes/MslsCustomFilter.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
class MslsCustomFilter extends MslsMain {
1414

1515
/**
16-
* Init
17-
*
1816
* @codeCoverageIgnore
19-
*
20-
* @return MslsCustomFilter
2117
*/
22-
public static function init() {
18+
public static function init(): void {
2319
$options = msls_options();
2420
$collection = msls_blog_collection();
2521
$obj = new static( $options, $collection );
@@ -37,8 +33,6 @@ function () {
3733
);
3834
}
3935
}
40-
41-
return $obj;
4236
}
4337

4438
/**

includes/MslsMain.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ public function __construct( MslsOptions $options, MslsBlogCollection $collectio
3838
* Factory
3939
*
4040
* @codeCoverageIgnore
41-
*
42-
* @return static
4341
*/
44-
public static function init() {
42+
public static function create() {
4543
return new static( msls_options(), msls_blog_collection() );
4644
}
4745

includes/MslsMetaBox.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,9 @@ public static function get_suggested_fields( $json, $args ) {
8989
}
9090

9191
/**
92-
* Init
93-
*
9492
* @codeCoverageIgnore
95-
*
96-
* @return MslsMetaBox
9793
*/
98-
public static function init(): MslsMetaBox {
94+
public static function init(): void {
9995
$options = msls_options();
10096
$obj = new static( $options, msls_blog_collection() );
10197

@@ -104,8 +100,6 @@ public static function init(): MslsMetaBox {
104100
add_action( 'save_post', array( $obj, 'set' ) );
105101
add_action( 'trashed_post', array( $obj, 'delete' ) );
106102
}
107-
108-
return $obj;
109103
}
110104

111105
/**

includes/MslsOutput.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@ class MslsOutput extends MslsMain {
1414
/**
1515
* Holds the format for the output
1616
*
17-
* @var array $tags
17+
* @var array<string, string>
1818
*/
19-
protected $tags;
19+
protected array $tags;
2020

2121
/**
22-
* Creates and gets the output as an array
23-
*
2422
* @param int $display
2523
* @param bool $filter
2624
* @param bool $exists
2725
*
28-
* @return array
29-
* @uses MslsLink
30-
* @uses MslsOptions
26+
* @return string[]
3127
*/
32-
public function get( $display, $filter = false, $exists = false ) {
28+
public function get( int $display, bool $filter = false, bool $exists = false ) {
3329
$arr = array();
3430

3531
$blogs = $this->collection->get_filtered( $filter );

0 commit comments

Comments
 (0)