Skip to content

Commit db1b281

Browse files
tbradshakangzj
authored andcommitted
Phan: Fix PhanTypeMismatchArgument violations (#45048)
1 parent 8d8d78d commit db1b281

File tree

81 files changed

+229
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+229
-164
lines changed

projects/packages/backup-helper-script-manager/.phan/baseline.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
return [
1111
// # Issue statistics:
1212
// PhanTypeMismatchArgumentProbablyReal : 15+ occurrences
13-
// PhanTypeMismatchArgumentInternal : 3 occurrences
14-
// PhanTypeMismatchForeach : 2 occurrences
1513

1614
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
1715
'file_suppressions' => [
18-
'src/class-helper-script-manager-impl.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchForeach'],
19-
'tests/php/Throw_On_Errors_Test.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal'],
16+
'tests/php/Throw_On_Errors_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'],
2017
],
2118
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
2219
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some PhanTypeMismatchArgument violations.
4+
5+

projects/packages/backup-helper-script-manager/src/class-throw-on-errors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function () use ( $directory, $permissions, $recursive ) {
328328
*
329329
* @param string $directory Directory that will be scanned.
330330
*
331-
* @return string An array of filenames.
331+
* @return string[] An array of filenames.
332332
* @throws Exception If scandir() has thrown warnings, or has failed.
333333
*/
334334
public static function t_scandir( $directory ) {

projects/packages/boost-core/.phan/baseline.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
return [
1111
// # Issue statistics:
1212
// PhanAbstractStaticMethodCallInStatic : 3 occurrences
13-
// PhanTypeMismatchArgumentInternal : 2 occurrences
1413

1514
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
1615
'file_suppressions' => [
1716
'src/lib/class-cacheable.php' => ['PhanAbstractStaticMethodCallInStatic'],
18-
'src/lib/class-utils.php' => ['PhanTypeMismatchArgumentInternal'],
1917
],
2018
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
2119
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some PhanTypeMismatchArgument violations.
4+
5+

projects/packages/boost-core/src/lib/class-utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function standardize_error( $error ) {
3838
if ( is_object( $error ) ) {
3939
return array(
4040
'name' => 'Error',
41-
'message' => json_decode( wp_json_encode( $error ), ARRAY_A ),
41+
'message' => json_decode( wp_json_encode( $error ), true ),
4242
);
4343
}
4444

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

125125
// Check for HTTP errors.
126126
$code = wp_remote_retrieve_response_code( $response );
127-
$data = json_decode( wp_remote_retrieve_body( $response ), ARRAY_A );
127+
$data = json_decode( wp_remote_retrieve_body( $response ), true );
128128

129129
if ( 200 !== $code ) {
130130
$default_message = sprintf(

projects/packages/classic-theme-helper/.phan/baseline.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
return [
1111
// # Issue statistics:
12-
// PhanTypeMismatchArgumentInternal : 10+ occurrences
1312
// PhanUndeclaredClassMethod : 10+ occurrences
1413
// PhanTypePossiblyInvalidDimOffset : 8 occurrences
1514
// PhanTypeSuspiciousNonTraversableForeach : 6 occurrences
@@ -22,7 +21,7 @@
2221

2322
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
2423
'file_suppressions' => [
25-
'_inc/lib/tonesque.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal'],
24+
'_inc/lib/tonesque.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
2625
'src/class-featured-content.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset'],
2726
'src/class-social-links.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredTypeProperty'],
2827
'src/content-options/featured-images-fallback.php' => ['PhanTypePossiblyInvalidDimOffset'],

projects/packages/classic-theme-helper/_inc/lib/tonesque.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ public function grab_points( $type = 'index' ) {
157157
* Sample five points in the image
158158
* based on rule of thirds and center.
159159
*/
160-
$topy = round( $height / 3 );
161-
$bottomy = round( ( $height / 3 ) * 2 );
162-
$leftx = round( $width / 3 );
163-
$rightx = round( ( $width / 3 ) * 2 );
164-
$centery = round( $height / 2 );
165-
$centerx = round( $width / 2 );
160+
$topy = (int) round( $height / 3 );
161+
$bottomy = (int) round( ( $height / 3 ) * 2 );
162+
$leftx = (int) round( $width / 3 );
163+
$rightx = (int) round( ( $width / 3 ) * 2 );
164+
$centery = (int) round( $height / 2 );
165+
$centerx = (int) round( $width / 2 );
166166

167167
// Cast those colors into an array.
168168
$points = array(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some PhanTypeMismatchArgument violations.
4+
5+

projects/packages/connection/.phan/baseline.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
// PhanTypeMismatchReturn : 15+ occurrences
1515
// PhanTypeMismatchPropertyProbablyReal : 9 occurrences
1616
// PhanTypeMismatchReturnProbablyReal : 8 occurrences
17-
// PhanTypeMismatchArgumentProbablyReal : 7 occurrences
1817
// PhanTypeArraySuspiciousNullable : 5 occurrences
1918
// PhanTypeMismatchDefault : 4 occurrences
20-
// PhanTypeMismatchArgumentInternal : 3 occurrences
19+
// PhanTypeMismatchArgumentProbablyReal : 3 occurrences
2120
// PhanTypeObjectUnsetDeclaredProperty : 3 occurrences
2221
// PhanDeprecatedFunction : 2 occurrences
2322
// PhanNonClassMethodCall : 2 occurrences
@@ -36,7 +35,7 @@
3635
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
3736
'file_suppressions' => [
3837
'legacy/class-jetpack-options.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'],
39-
'legacy/class-jetpack-signature.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentInternal'],
38+
'legacy/class-jetpack-signature.php' => ['PhanPluginDuplicateConditionalNullCoalescing'],
4039
'legacy/class-jetpack-tracks-client.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchPropertyProbablyReal'],
4140
'legacy/class-jetpack-xmlrpc-server.php' => ['PhanAccessMethodInternal', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'],
4241
'src/class-error-handler.php' => ['PhanTypeMismatchReturnProbablyReal'],
@@ -49,7 +48,7 @@
4948
'src/class-rest-connector.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'],
5049
'src/class-secrets.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument'],
5150
'src/class-server-sandbox.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'],
52-
'src/class-tokens.php' => ['PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
51+
'src/class-tokens.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
5352
'src/class-tracking.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypePossiblyInvalidDimOffset'],
5453
'src/sso/class-sso.php' => ['PhanTypeMismatchArgument'],
5554
'src/sso/class-user-admin.php' => ['PhanPluginUnreachableCode', 'PhanTypeMismatchArgument'],
@@ -61,7 +60,6 @@
6160
'tests/php/REST_Authentication_Test.php' => ['PhanTypeMismatchArgument'],
6261
'tests/php/REST_Endpoints_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
6362
'tests/php/Server_Sandbox_Test.php' => ['PhanTypeArraySuspiciousNullable'],
64-
'tests/php/SignatureTest.php' => ['PhanTypeMismatchArgumentProbablyReal'],
6563
'tests/php/TokensTest.php' => ['PhanTypeObjectUnsetDeclaredProperty'],
6664
],
6765
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.

0 commit comments

Comments
 (0)