Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
return [
// # Issue statistics:
// PhanTypeMismatchArgumentProbablyReal : 15+ occurrences
// PhanTypeMismatchArgumentInternal : 3 occurrences
// PhanTypeMismatchForeach : 2 occurrences

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'src/class-helper-script-manager-impl.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchForeach'],
'tests/php/Throw_On_Errors_Test.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'tests/php/Throw_On_Errors_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function () use ( $directory, $permissions, $recursive ) {
*
* @param string $directory Directory that will be scanned.
*
* @return string An array of filenames.
* @return string[] An array of filenames.
* @throws Exception If scandir() has thrown warnings, or has failed.
*/
public static function t_scandir( $directory ) {
Expand Down
2 changes: 0 additions & 2 deletions projects/packages/boost-core/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
return [
// # Issue statistics:
// PhanAbstractStaticMethodCallInStatic : 3 occurrences
// PhanTypeMismatchArgumentInternal : 2 occurrences

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'src/lib/class-cacheable.php' => ['PhanAbstractStaticMethodCallInStatic'],
'src/lib/class-utils.php' => ['PhanTypeMismatchArgumentInternal'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


4 changes: 2 additions & 2 deletions projects/packages/boost-core/src/lib/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function standardize_error( $error ) {
if ( is_object( $error ) ) {
return array(
'name' => 'Error',
'message' => json_decode( wp_json_encode( $error ), ARRAY_A ),
'message' => json_decode( wp_json_encode( $error ), true ),
);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public static function send_wpcom_request( $method, $endpoint, $args = null, $bo

// Check for HTTP errors.
$code = wp_remote_retrieve_response_code( $response );
$data = json_decode( wp_remote_retrieve_body( $response ), ARRAY_A );
$data = json_decode( wp_remote_retrieve_body( $response ), true );

if ( 200 !== $code ) {
$default_message = sprintf(
Expand Down
3 changes: 1 addition & 2 deletions projects/packages/classic-theme-helper/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgumentInternal : 10+ occurrences
// PhanUndeclaredClassMethod : 10+ occurrences
// PhanTypePossiblyInvalidDimOffset : 8 occurrences
// PhanTypeSuspiciousNonTraversableForeach : 6 occurrences
Expand All @@ -22,7 +21,7 @@

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'_inc/lib/tonesque.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'_inc/lib/tonesque.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'src/class-featured-content.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset'],
'src/class-social-links.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredTypeProperty'],
'src/content-options/featured-images-fallback.php' => ['PhanTypePossiblyInvalidDimOffset'],
Expand Down
12 changes: 6 additions & 6 deletions projects/packages/classic-theme-helper/_inc/lib/tonesque.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ public function grab_points( $type = 'index' ) {
* Sample five points in the image
* based on rule of thirds and center.
*/
$topy = round( $height / 3 );
$bottomy = round( ( $height / 3 ) * 2 );
$leftx = round( $width / 3 );
$rightx = round( ( $width / 3 ) * 2 );
$centery = round( $height / 2 );
$centerx = round( $width / 2 );
$topy = (int) round( $height / 3 );
$bottomy = (int) round( ( $height / 3 ) * 2 );
$leftx = (int) round( $width / 3 );
$rightx = (int) round( ( $width / 3 ) * 2 );
$centery = (int) round( $height / 2 );
$centerx = (int) round( $width / 2 );

// Cast those colors into an array.
$points = array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


8 changes: 3 additions & 5 deletions projects/packages/connection/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
// PhanTypeMismatchReturn : 15+ occurrences
// PhanTypeMismatchPropertyProbablyReal : 9 occurrences
// PhanTypeMismatchReturnProbablyReal : 8 occurrences
// PhanTypeMismatchArgumentProbablyReal : 7 occurrences
// PhanTypeArraySuspiciousNullable : 5 occurrences
// PhanTypeMismatchDefault : 4 occurrences
// PhanTypeMismatchArgumentInternal : 3 occurrences
// PhanTypeMismatchArgumentProbablyReal : 3 occurrences
// PhanTypeObjectUnsetDeclaredProperty : 3 occurrences
// PhanDeprecatedFunction : 2 occurrences
// PhanNonClassMethodCall : 2 occurrences
Expand All @@ -36,7 +35,7 @@
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'legacy/class-jetpack-options.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'],
'legacy/class-jetpack-signature.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentInternal'],
'legacy/class-jetpack-signature.php' => ['PhanPluginDuplicateConditionalNullCoalescing'],
'legacy/class-jetpack-tracks-client.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchPropertyProbablyReal'],
'legacy/class-jetpack-xmlrpc-server.php' => ['PhanAccessMethodInternal', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'],
'src/class-error-handler.php' => ['PhanTypeMismatchReturnProbablyReal'],
Expand All @@ -49,7 +48,7 @@
'src/class-rest-connector.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'],
'src/class-secrets.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument'],
'src/class-server-sandbox.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'],
'src/class-tokens.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/class-tokens.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/class-tracking.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypePossiblyInvalidDimOffset'],
'src/sso/class-sso.php' => ['PhanTypeMismatchArgument'],
'src/sso/class-user-admin.php' => ['PhanPluginUnreachableCode', 'PhanTypeMismatchArgument'],
Expand All @@ -61,7 +60,6 @@
'tests/php/REST_Authentication_Test.php' => ['PhanTypeMismatchArgument'],
'tests/php/REST_Endpoints_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'tests/php/Server_Sandbox_Test.php' => ['PhanTypeArraySuspiciousNullable'],
'tests/php/SignatureTest.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'tests/php/TokensTest.php' => ['PhanTypeObjectUnsetDeclaredProperty'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Jetpack_Signature {
/**
* Constructor.
*
* @param array $access_token Access token.
* @param int $time_diff Timezone difference (in seconds).
* @param string $access_token Access token.
* @param int $time_diff Timezone difference (in seconds).
*/
public function __construct( $access_token, $time_diff = 0 ) {
$secret = explode( '.', $access_token );
Expand Down Expand Up @@ -219,7 +219,7 @@ public function sign_request( $token = '', $timestamp = 0, $nonce = '', $body_ha
return new WP_Error( 'unknown_scheme_port', "The scheme's port is unknown", compact( 'signature_details' ) );
}

if ( ! ctype_digit( "$timestamp" ) || 10 < strlen( $timestamp ) ) { // If Jetpack is around in 275 years, you can blame mdawaffe for the bug.
if ( ! ctype_digit( "$timestamp" ) || 10 < strlen( (string) $timestamp ) ) { // If Jetpack is around in 275 years, you can blame mdawaffe for the bug.
return new WP_Error( 'invalid_signature', sprintf( 'The required "%s" parameter is malformed.', 'timestamp' ), compact( 'signature_details' ) );
}

Expand Down
2 changes: 1 addition & 1 deletion projects/packages/connection/src/class-tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public function get_signed_token( $token ) {
if ( function_exists( 'wp_generate_password' ) ) {
$nonce = wp_generate_password( 10, false );
} else {
$nonce = substr( sha1( wp_rand( 0, 1000000 ) ), 0, 10 );
$nonce = substr( sha1( (string) wp_rand( 0, 1000000 ) ), 0, 10 );
}

$normalized_request_string = implode(
Expand Down
11 changes: 5 additions & 6 deletions projects/packages/forms/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 40+ occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 15+ occurrences
// PhanTypeMismatchReturnProbablyReal : 10+ occurrences
// PhanTypeMismatchArgumentInternal : 6 occurrences
// PhanTypeMismatchArgument : 45+ occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 30+ occurrences
// PhanTypeMismatchReturnProbablyReal : 7 occurrences
// PhanTypeMismatchArgumentProbablyReal : 6 occurrences
// PhanPluginDuplicateAdjacentStatement : 2 occurrences
// PhanTypeConversionFromArray : 2 occurrences
Expand All @@ -26,9 +25,9 @@

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'src/contact-form/class-admin.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn'],
'src/contact-form/class-admin.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn'],
'src/contact-form/class-contact-form-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form-plugin.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form-plugin.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form-shortcode.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'],
'src/contact-form/class-contact-form.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginRedundantAssignment', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'],
'src/dashboard/class-dashboard-view-switch.php' => ['PhanUnreferencedUseNormal'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


4 changes: 2 additions & 2 deletions projects/packages/forms/src/contact-form/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public function grunion_manage_post_row_actions( $actions ) {
$actions['untrash'] = sprintf(
'<a title="%s" href="%s">%s</a>',
esc_attr__( 'Restore this item from the Trash', 'jetpack-forms' ),
esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', rawurlencode( $post->ID ) ) ) ), 'untrash-' . $post->post_type . '_' . $post->ID ),
esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', rawurlencode( (string) $post->ID ) ) ) ), 'untrash-' . $post->post_type . '_' . $post->ID ),
esc_html__( 'Restore', 'jetpack-forms' )
);
$actions['delete'] = sprintf(
Expand All @@ -900,7 +900,7 @@ public function grunion_manage_post_row_actions( $actions ) {
$actions['spam'] = sprintf(
'<a title="%s" href="%s">%s</a>',
esc_html__( 'Mark this message as spam', 'jetpack-forms' ),
esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?post_id=' . rawurlencode( $post->ID ) . '&action=spam' ) ), 'spam-feedback_' . $post->ID ),
esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?post_id=' . rawurlencode( (string) $post->ID ) . '&action=spam' ) ), 'spam-feedback_' . $post->ID ),
esc_html__( 'Spam', 'jetpack-forms' )
);
$actions['trash'] = sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1667,12 +1667,12 @@ public function ajax_request() {
$submission_result = self::process_form_submission();

if ( ! $submission_result ) {
header( 'HTTP/1.1 500 Server Error', 500, true );
header( 'HTTP/1.1 500 Server Error', true, 500 );
echo '<div class="form-error"><ul class="form-errors"><li class="form-error-message">';
esc_html_e( 'An error occurred. Please try again later.', 'jetpack-forms' );
echo '</li></ul></div>';
} elseif ( is_wp_error( $submission_result ) ) {
header( 'HTTP/1.1 400 Bad Request', 403, true );
header( 'HTTP/1.1 400 Bad Request', true, 403 );
echo '<div class="form-error"><ul class="form-errors"><li class="form-error-message">';
echo esc_html( $submission_result->get_error_message() );
echo '</li></ul></div>';
Expand Down
5 changes: 2 additions & 3 deletions projects/packages/image-cdn/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// PhanTypePossiblyInvalidDimOffset : 10+ occurrences
// PhanPluginSimplifyExpressionBool : 6 occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 4 occurrences
// PhanTypeMismatchArgumentProbablyReal : 4 occurrences
// PhanPossiblyUndeclaredVariable : 2 occurrences
// PhanTypeMismatchArgumentProbablyReal : 2 occurrences
// PhanTypeMismatchPropertyProbablyReal : 2 occurrences
// PhanTypeMismatchReturn : 2 occurrences
// PhanNonClassMethodCall : 1 occurrence
// PhanTypeArraySuspicious : 1 occurrence
// PhanTypeMismatchArgumentInternal : 1 occurrence
// PhanTypeMismatchArgumentNullable : 1 occurrence
// PhanTypeMismatchArgumentNullableInternal : 1 occurrence
// PhanTypeMismatchReturnProbablyReal : 1 occurrence
Expand All @@ -30,7 +29,7 @@
'file_suppressions' => [
'src/class-image-cdn-core.php' => ['PhanTypeMismatchReturn'],
'src/class-image-cdn-image-sizes.php' => ['PhanPluginSimplifyExpressionBool'],
'src/class-image-cdn.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset'],
'src/class-image-cdn.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspicious', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset'],
'src/compatibility/photon.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'tests/php/Image_CDN_Core_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeObjectUnsetDeclaredProperty'],
'tests/php/Image_CDN_Test.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredStaticMethod'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


2 changes: 1 addition & 1 deletion projects/packages/image-cdn/src/class-image-cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class Image_CDN {
* @return object
*/
public static function instance() {
if ( ! is_a( self::$instance, self::class ) ) {
if ( ! self::$instance instanceof self ) {
self::$instance = new self();
self::$instance->setup();
self::$is_enabled = true;
Expand Down
7 changes: 1 addition & 6 deletions projects/packages/ip/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@
* (can be combined with --load-baseline)
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgumentInternal : 2 occurrences
// PhanTypeMismatchArgumentProbablyReal : 2 occurrences

// This baseline has no suppressions
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'src/class-utils.php' => ['PhanTypeMismatchArgumentInternal'],
'tests/php/UtilsTest.php' => ['PhanTypeMismatchArgumentProbablyReal'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some PhanTypeMismatchArgument violations.


4 changes: 2 additions & 2 deletions projects/packages/ip/src/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static function clean_ip( $ip ) {
/**
* Checks an IP to see if it is within a private range.
*
* @param int $ip IP address.
* @return bool True if IP address is private, false otherwise.
* @param string $ip IP address.
* @return bool True if IP address is private, false otherwise.
*/
public static function ip_is_private( $ip ) {
// We are dealing with ipv6, so we can simply rely on filter_var.
Expand Down
Loading
Loading