Skip to content

Commit 8badd97

Browse files
committed
PHPStand reported issues addressed
1 parent a02aaa8 commit 8badd97

11 files changed

+38
-41
lines changed

.distignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/build
66
/diagrams
77
/docs
8-
/githooks
98
/legacy-tests
109
/node_modules
1110
/src

MultisiteLanguageSwitcher.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ function msls_options(): \lloc\Msls\MslsOptions {
152152
return \lloc\Msls\MslsOptions::instance();
153153
}
154154

155+
/**
156+
* Gets the MslsOutput instance
157+
*
158+
* @return \lloc\Msls\MslsOutput
159+
*/
160+
function msls_output(): \lloc\Msls\MslsOutput {
161+
echo \lloc\Msls\MslsOutput::create();
162+
}
163+
155164
/**
156165
* Retrieves the MslsOptionsPost instance.
157166
*
@@ -193,9 +202,5 @@ function msls_get_query(): ?\lloc\Msls\MslsOptionsQuery {
193202
return \lloc\Msls\MslsOptionsQuery::create();
194203
}
195204

196-
function msls_output( $attr = array() ) {
197-
echo get_the_msls( $attr );
198-
}
199-
200205
lloc\Msls\MslsPlugin::init();
201206
}
File renamed without changes.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"diagram:class": "vendor/bin/php-class-diagram --php8 includes > diagrams/msls-class.puml",
4646
"diagram:package": "vendor/bin/php-class-diagram --package-diagram --php8 includes > diagrams/msls-package.puml",
4747
"githooks": [
48-
"if [ -e ./githooks/pre-commit ]; then cp ./githooks/pre-commit ./.git/hooks/; fi",
49-
"if [ -e ./.git/hooks/pre-commit ]; then chmod 0755 ./.git/hooks/pre-commit; fi"
48+
"if [ -e bin/githooks/pre-commit ]; then cp bin/githooks/pre-commit ./.git/hooks/; fi",
49+
"if [ -e .git/hooks/pre-commit ]; then chmod 0755 .git/hooks/pre-commit; fi"
5050
],
5151
"post-install-cmd": [
5252
"@githooks"

includes/MslsBlogCollection.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,35 @@ class MslsBlogCollection extends MslsRegistryInstance {
1414
*
1515
* @var int
1616
*/
17-
private $current_blog_id;
17+
private int $current_blog_id;
1818

1919
/**
2020
* True if the current blog should be in the output
2121
*
2222
* @var bool
2323
*/
24-
private $current_blog_output;
24+
private bool $current_blog_output;
2525

2626
/**
2727
* Collection of MslsBlog-objects
2828
*
2929
* @var MslsBlog[]
3030
*/
31-
private $objects = array();
31+
private array $objects = array();
3232

3333
/**
3434
* Order output by language or description
3535
*
3636
* @var string
3737
*/
38-
private $objects_order;
38+
private string $objects_order;
3939

4040
/**
4141
* Active plugins in the whole network
4242
*
43-
* @var array
43+
* @var string[]
4444
*/
45-
private $active_plugins;
46-
47-
/**
48-
* Container for hreflang-mapping
49-
*
50-
* @var array
51-
*/
52-
private $hreflangmap = array();
45+
private ?array $active_plugins = null;
5346

5447
/**
5548
* Constructor
@@ -130,7 +123,7 @@ public static function get_configured_blog_description( int $blog_id, $descripti
130123
*
131124
* @param MslsOptions $options
132125
*
133-
* @return array
126+
* @return object[]|\stdClass[]
134127
*/
135128
public function get_blogs_of_reference_user( MslsOptions $options ) {
136129
$reference_user = $options->has_value( 'reference_user' ) ? $options->reference_user : current(
@@ -254,7 +247,7 @@ public function get_object( int $blog_id ): ?MslsBlog {
254247
* @return bool
255248
*/
256249
public function is_plugin_active( $blog_id ) {
257-
if ( ! is_array( $this->active_plugins ) ) {
250+
if ( is_null( $this->active_plugins ) ) {
258251
$this->active_plugins = get_site_option( 'active_sitewide_plugins', array() );
259252
}
260253

@@ -271,7 +264,7 @@ public function is_plugin_active( $blog_id ) {
271264
/**
272265
* Gets only blogs where the plugin is active
273266
*
274-
* @return array
267+
* @return MslsBlog[]
275268
*/
276269
public function get_plugin_active_blogs() {
277270
$arr = array();
@@ -317,7 +310,7 @@ public function get_filtered( bool $filter = false ): array {
317310
* @param string $fields
318311
* @param int|string $number
319312
*
320-
* @return array
313+
* @return array<string, int>
321314
*/
322315
public function get_users( $fields = 'all', $number = '' ) {
323316
$args = array(

includes/MslsContentFilter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
6666
return ! empty( $output ) ? $pref . $output . $post : '';
6767
}
6868

69+
/**
70+
* @param string[] $links
71+
* @return string|null
72+
*/
6973
public function format_available_languages( array $links ): ?string {
7074
if ( empty( $links ) ) {
7175
return null;

includes/MslsContentTypes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ abstract class MslsContentTypes extends MslsRegistryInstance {
1414
*
1515
* @var string
1616
*/
17-
protected $request;
17+
protected string $request;
1818

1919
/**
2020
* Types
2121
*
22-
* @var array
22+
* @var string[]
2323
*/
24-
protected $types = array();
24+
protected array $types = array();
2525

2626
/**
2727
* Factory method
@@ -69,7 +69,7 @@ public function acl_request() {
6969
/**
7070
* Getter
7171
*
72-
* @return array
72+
* @return string[]
7373
*/
7474
abstract public static function get(): array;
7575

includes/MslsCustomColumn.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public static function init(): void {
3232
/**
3333
* Table header
3434
*
35-
* @param array $columns
35+
* @param string[] $columns
3636
*
37-
* @return array
37+
* @return string[]
3838
*/
39-
public function th( $columns ) {
39+
public function th( array $columns ) {
4040
$blogs = $this->collection->get();
4141
if ( $blogs ) {
4242
$html = '';

includes/MslsCustomColumnTaxonomy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function init(): void {
3636
* @param string $column_name
3737
* @param int $item_id
3838
*/
39-
public function column_default( $deprecated, $column_name, $item_id ) {
39+
public function column_default( $deprecated, $column_name, $item_id ): void {
4040
$this->td( $column_name, $item_id );
4141
}
4242

includes/MslsGetSet.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
class MslsGetSet extends MslsRegistryInstance {
1313

1414
/**
15-
* Generic container for all properties of an instance
16-
*
17-
* @var array $arr
15+
* @var array<string, mixed>
1816
*/
1917
protected $arr = array();
2018

@@ -110,9 +108,9 @@ public function is_empty() {
110108
/**
111109
* Gets the complete properties-container as an array.
112110
*
113-
* @return array
111+
* @return array<string, mixed>
114112
*/
115-
public function get_arr() {
113+
public function get_arr(): array {
116114
return $this->arr;
117115
}
118116
}

0 commit comments

Comments
 (0)