Skip to content

Commit fba102f

Browse files
committed
PHPStan fixes
1 parent 7621e69 commit fba102f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Ability_Command.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ public function execute( $args, $assoc_args ) {
298298
}
299299
}
300300

301+
/**
302+
* Existence is checked above with wp_has_ability().
303+
*
304+
* @var \WP_Ability $ability
305+
*/
301306
$ability = wp_get_ability( $ability_name );
302307

303308
$result = $ability->execute( $input );
@@ -310,10 +315,10 @@ public function execute( $args, $assoc_args ) {
310315
$format = isset( $assoc_args['format'] ) ? $assoc_args['format'] : 'json';
311316

312317
if ( 'json' === $format ) {
313-
WP_CLI::line( wp_json_encode( $result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );
318+
WP_CLI::line( (string) wp_json_encode( $result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );
314319
} elseif ( 'yaml' === $format ) {
315320
// Convert to YAML-like output
316-
foreach ( $result as $key => $value ) {
321+
foreach ( (array) $result as $key => $value ) {
317322
if ( is_array( $value ) || is_object( $value ) ) {
318323
WP_CLI::line( $key . ': ' . wp_json_encode( $value ) );
319324
} else {

0 commit comments

Comments
 (0)