Completed
Push — add/signature-error-reporting ( dc097f...d0d967 )
by
unknown
43:34 queued 27:42
created

jetpack/class.jetpack-json-api-log-endpoint.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
class Jetpack_JSON_API_Jetpack_Log_Endpoint extends Jetpack_JSON_API_Endpoint {
4
	// GET /sites/%s/jetpack-log
5
	protected $needed_capabilities = 'manage_options';
6
7
	protected function result() {
8
		$args = $this->input();
9
		$event = ( isset( $args['event'] ) && is_string( $args['event'] ) ) ? $code : false;
10
		$num  = ( isset( $args['num'] ) ) ? intval( $num ) : false;
11
12
		return array(
13
			'log' => Jetpack::get_log( $event, $num )
0 ignored issues
show
It seems like $num defined by isset($args['num']) ? intval($num) : false on line 10 can also be of type integer; however, Jetpack::get_log() does only seem to accept boolean, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
14
		);
15
	}
16
}
17