diff --git a/projects/packages/connection/.phan/baseline.php b/projects/packages/connection/.phan/baseline.php index f6be0f6da2338..666ecd0e7ea8f 100644 --- a/projects/packages/connection/.phan/baseline.php +++ b/projects/packages/connection/.phan/baseline.php @@ -15,7 +15,7 @@ // PhanDeprecatedFunction : 15+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 15+ occurrences // PhanTypeMismatchReturn : 15+ occurrences - // PhanUndeclaredClassMethod : 15+ occurrences + // PhanUndeclaredClassMethod : 10+ occurrences // PhanTypeMismatchPropertyProbablyReal : 9 occurrences // PhanNoopNew : 8 occurrences // PhanTypeMismatchReturnProbablyReal : 8 occurrences @@ -25,9 +25,7 @@ // PhanTypeMismatchDefault : 5 occurrences // PhanTypeMismatchArgumentInternal : 3 occurrences // PhanTypeMismatchArgumentNullable : 3 occurrences - // PhanTypeMismatchProperty : 3 occurrences // PhanTypeObjectUnsetDeclaredProperty : 3 occurrences - // PhanUndeclaredTypeReturnType : 3 occurrences // PhanCommentParamWithoutRealParam : 2 occurrences // PhanNonClassMethodCall : 2 occurrences // PhanPluginUnreachableCode : 2 occurrences @@ -36,18 +34,14 @@ // PhanTypeMismatchReturnNullable : 2 occurrences // PhanTypePossiblyInvalidDimOffset : 2 occurrences // PhanUndeclaredMethodInCallable : 2 occurrences - // PhanUndeclaredTypeProperty : 2 occurrences - // PhanUndeclaredTypeThrowsType : 2 occurrences - // PhanUnextractableAnnotationSuffix : 2 occurrences // PhanAccessMethodInternal : 1 occurrence // PhanImpossibleCondition : 1 occurrence // PhanImpossibleTypeComparison : 1 occurrence // PhanPluginDuplicateAdjacentStatement : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence // PhanTypeMismatchDeclaredParamNullable : 1 occurrence - // PhanTypeSuspiciousStringExpression : 1 occurrence // PhanUndeclaredClassReference : 1 occurrence - // PhanUndeclaredFunctionInCallable : 1 occurrence + // PhanUnextractableAnnotationSuffix : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -58,28 +52,25 @@ 'legacy/class-jetpack-xmlrpc-server.php' => ['PhanAccessMethodInternal', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty'], 'src/class-error-handler.php' => ['PhanTypeMismatchReturnProbablyReal'], 'src/class-heartbeat.php' => ['PhanTypeMismatchPropertyDefault'], - 'src/class-manager.php' => ['PhanImpossibleCondition', 'PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchDefault', 'PhanTypeMismatchProperty', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType'], + 'src/class-manager.php' => ['PhanImpossibleCondition', 'PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchDefault', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-nonce-handler.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchReturnNullable'], 'src/class-package-version-tracker.php' => ['PhanUndeclaredClassMethod'], 'src/class-partner-coupon.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-partner.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'src/class-plugin-storage.php' => ['PhanUndeclaredClassMethod'], 'src/class-rest-authentication.php' => ['PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchPropertyProbablyReal'], - 'src/class-rest-connector.php' => ['PhanParamTooMany', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeReturnType', 'PhanUnextractableAnnotationSuffix'], + 'src/class-rest-connector.php' => ['PhanParamTooMany', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUnextractableAnnotationSuffix'], 'src/class-secrets.php' => ['PhanCommentParamWithoutRealParam', 'PhanNonClassMethodCall', 'PhanTypeMismatchArgument'], 'src/class-server-sandbox.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], 'src/class-tokens.php' => ['PhanImpossibleTypeComparison', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-tracking.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypePossiblyInvalidDimOffset'], - 'src/class-urls.php' => ['PhanTypeSuspiciousStringExpression', 'PhanUndeclaredFunctionInCallable'], 'src/class-webhooks.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'src/class-xmlrpc-connector.php' => ['PhanUndeclaredTypeReturnType'], 'src/sso/class-helpers.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'src/sso/class-sso.php' => ['PhanNoopNew', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassMethod'], 'src/sso/class-user-admin.php' => ['PhanPluginUnreachableCode', 'PhanTypeMismatchArgument'], - 'src/webhooks/class-authorize-redirect.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredTypeProperty'], + 'src/webhooks/class-authorize-redirect.php' => ['PhanTypeMismatchArgumentNullable', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference'], 'tests/php/test-class-nonce-handler.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanTypeMismatchArgument'], - 'tests/php/test-class-plugin.php' => ['PhanUndeclaredTypeThrowsType'], - 'tests/php/test-class-webhooks.php' => ['PhanDeprecatedFunction', 'PhanUndeclaredTypeThrowsType'], + 'tests/php/test-class-webhooks.php' => ['PhanDeprecatedFunction'], 'tests/php/test-partner-coupon.php' => ['PhanDeprecatedFunction'], 'tests/php/test-rest-endpoints.php' => ['PhanNoopNew', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethodInCallable'], 'tests/php/test-tracking.php' => ['PhanDeprecatedFunction'], diff --git a/projects/packages/connection/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/connection/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/connection/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/connection/src/class-client.php b/projects/packages/connection/src/class-client.php index cc1c008a20250..0ba9c4820801a 100644 --- a/projects/packages/connection/src/class-client.php +++ b/projects/packages/connection/src/class-client.php @@ -321,9 +321,9 @@ public static function _wp_remote_request( $url, $args, $set_fallback = false ) /** * Sets the time difference for correct signature computation. * - * @param array $response Response array from `wp_remote_request`. - * @param bool $force_set whether to force setting the time difference. - * @phan-param _WP_Remote_Response_Array $response + * @param array|WP_Error $response Response array from `wp_remote_request`, or WP_Error on error. + * @param bool $force_set whether to force setting the time difference. + * @phan-param _WP_Remote_Response_Array|WP_Error $response */ public static function set_time_diff( &$response, $force_set = false ) { $code = wp_remote_retrieve_response_code( $response ); diff --git a/projects/packages/connection/src/class-manager.php b/projects/packages/connection/src/class-manager.php index e80a23b7f0013..3a2ed731ffdb5 100644 --- a/projects/packages/connection/src/class-manager.php +++ b/projects/packages/connection/src/class-manager.php @@ -16,8 +16,10 @@ use Automattic\Jetpack\Status\Host; use Automattic\Jetpack\Terms_Of_Service; use Automattic\Jetpack\Tracking; +use IXR_Error; use Jetpack_IXR_Client; use Jetpack_Options; +use Jetpack_XMLRPC_Server; use WP_Error; use WP_User; @@ -160,16 +162,16 @@ public static function configure() { * * @since 1.25.0 Deprecate $is_active param. * - * @param array $request_params incoming request parameters. - * @param bool $has_connected_owner Whether the site has a connected owner. - * @param bool $is_signed whether the signature check has been successful. - * @param \Jetpack_XMLRPC_Server $xmlrpc_server (optional) an instance of the server to use instead of instantiating a new one. + * @param array $request_params incoming request parameters. + * @param bool $has_connected_owner Whether the site has a connected owner. + * @param bool $is_signed whether the signature check has been successful. + * @param Jetpack_XMLRPC_Server $xmlrpc_server (optional) an instance of the server to use instead of instantiating a new one. */ public function setup_xmlrpc_handlers( $request_params, $has_connected_owner, $is_signed, - \Jetpack_XMLRPC_Server $xmlrpc_server = null + Jetpack_XMLRPC_Server $xmlrpc_server = null ) { add_filter( 'xmlrpc_blog_options', array( $this, 'xmlrpc_options' ), 1000, 2 ); @@ -204,7 +206,7 @@ public function setup_xmlrpc_handlers( if ( $xmlrpc_server ) { $this->xmlrpc_server = $xmlrpc_server; } else { - $this->xmlrpc_server = new \Jetpack_XMLRPC_Server(); + $this->xmlrpc_server = new Jetpack_XMLRPC_Server(); } $this->require_jetpack_authentication(); @@ -2321,7 +2323,7 @@ public function public_xmlrpc_methods( $methods ) { * Handles a getOptions XMLRPC method call. * * @param array $args method call arguments. - * @return an amended XMLRPC server options array. + * @return array|IXR_Error An amended XMLRPC server options array. */ public function jetpack_get_options( $args ) { global $wp_xmlrpc_server; diff --git a/projects/packages/connection/src/class-rest-connector.php b/projects/packages/connection/src/class-rest-connector.php index 23234483c0b6f..7bc3344536cb5 100644 --- a/projects/packages/connection/src/class-rest-connector.php +++ b/projects/packages/connection/src/class-rest-connector.php @@ -317,7 +317,7 @@ public function verify_registration( WP_REST_Request $request ) { * * @param WP_REST_Request $request The request sent to the WP REST API. * - * @return array|wp-error + * @return array|WP_Error */ public static function remote_authorize( $request ) { $xmlrpc_server = new Jetpack_XMLRPC_Server(); diff --git a/projects/packages/connection/src/class-urls.php b/projects/packages/connection/src/class-urls.php index d411d5b4c6fcb..f8c22cee789d7 100644 --- a/projects/packages/connection/src/class-urls.php +++ b/projects/packages/connection/src/class-urls.php @@ -82,8 +82,8 @@ public static function normalize_www_in_url( $option, $url_function ) { /** * Return URL with a normalized protocol. * - * @param callable $callable Function to retrieve URL option. - * @param string $new_value URL Protocol to set URLs to. + * @param string $callable Function name that was used to retrieve URL option. + * @param string $new_value URL Protocol to set URLs to. * @return string Normalized URL. */ public static function get_protocol_normalized_url( $callable, $new_value ) { diff --git a/projects/packages/connection/src/class-xmlrpc-connector.php b/projects/packages/connection/src/class-xmlrpc-connector.php index c3d786d88805f..a5693cf279c29 100644 --- a/projects/packages/connection/src/class-xmlrpc-connector.php +++ b/projects/packages/connection/src/class-xmlrpc-connector.php @@ -7,6 +7,8 @@ namespace Automattic\Jetpack\Connection; +use IXR_Error; + /** * Registers the XML-RPC methods for Connections. */ @@ -69,10 +71,10 @@ private function output( $data ) { $code = -10520; } - if ( ! class_exists( \IXR_Error::class ) ) { + if ( ! class_exists( IXR_Error::class ) ) { require_once ABSPATH . WPINC . '/class-IXR.php'; } - return new \IXR_Error( + return new IXR_Error( $code, sprintf( 'Jetpack: [%s] %s', $data->get_error_code(), $data->get_error_message() ) ); diff --git a/projects/packages/connection/src/webhooks/class-authorize-redirect.php b/projects/packages/connection/src/webhooks/class-authorize-redirect.php index 9d3ed145bc41e..37fd65cd681ed 100644 --- a/projects/packages/connection/src/webhooks/class-authorize-redirect.php +++ b/projects/packages/connection/src/webhooks/class-authorize-redirect.php @@ -21,7 +21,7 @@ class Authorize_Redirect { /** * The Connection Manager object. * - * @var Manager + * @var \Automattic\Jetpack\Connection\Manager */ private $connection; diff --git a/projects/packages/connection/tests/php/test-class-plugin.php b/projects/packages/connection/tests/php/test-class-plugin.php index 208a7a3b186b4..5a28461dff61e 100644 --- a/projects/packages/connection/tests/php/test-class-plugin.php +++ b/projects/packages/connection/tests/php/test-class-plugin.php @@ -34,7 +34,6 @@ class Test_Plugin extends TestCase { * Initialization of the test class * * @before - * @throws MockEnabledException PHPUnit wasn't able to enable mock functions ¯\_(⊙︿⊙)_/¯. */ protected function set_up() { Plugin_Storage::configure(); diff --git a/projects/packages/connection/tests/php/test-class-webhooks.php b/projects/packages/connection/tests/php/test-class-webhooks.php index b62f13ae08df2..86b05fab21a23 100644 --- a/projects/packages/connection/tests/php/test-class-webhooks.php +++ b/projects/packages/connection/tests/php/test-class-webhooks.php @@ -33,8 +33,6 @@ class Test_Webhooks extends TestCase { /** * Setting up the testing environment. * - * @throws \phpmock\MockEnabledException The mock exception. - * * @before */ public function set_up() { diff --git a/projects/packages/forms/.phan/baseline.php b/projects/packages/forms/.phan/baseline.php index 08fca267347a7..0a831866b5a59 100644 --- a/projects/packages/forms/.phan/baseline.php +++ b/projects/packages/forms/.phan/baseline.php @@ -9,16 +9,15 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 30+ occurrences - // PhanUndeclaredClassMethod : 30+ occurrences + // PhanTypeMismatchArgument : 20+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 10+ occurrences + // PhanUndeclaredMethod : 10+ occurrences // PhanTypeMismatchReturnProbablyReal : 9 occurrences // PhanTypeMismatchArgumentInternal : 7 occurrences - // PhanUndeclaredClassProperty : 7 occurrences + // PhanUndeclaredClassMethod : 7 occurrences // PhanTypeMismatchArgumentProbablyReal : 6 occurrences // PhanDeprecatedFunction : 5 occurrences // PhanRedundantCondition : 4 occurrences - // PhanUndeclaredTypeParameter : 4 occurrences // PhanTypeMismatchReturn : 3 occurrences // PhanTypePossiblyInvalidDimOffset : 3 occurrences // PhanUnextractableAnnotationElementName : 3 occurrences @@ -26,19 +25,15 @@ // PhanTypeConversionFromArray : 2 occurrences // PhanTypeMismatchArgumentNullableInternal : 2 occurrences // PhanUndeclaredFunction : 2 occurrences - // PhanUndeclaredTypeReturnType : 2 occurrences // PhanParamTooMany : 1 occurrence // PhanPluginDuplicateAdjacentStatement : 1 occurrence // PhanPluginMixedKeyNoKey : 1 occurrence // PhanPossiblyNullTypeMismatchProperty : 1 occurrence // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeArraySuspiciousNullable : 1 occurrence - // PhanTypeMismatchProperty : 1 occurrence - // PhanTypeMismatchPropertyProbablyReal : 1 occurrence // PhanTypeMismatchReturnNullable : 1 occurrence // PhanUndeclaredConstant : 1 occurrence // PhanUndeclaredProperty : 1 occurrence - // PhanUndeclaredTypeProperty : 1 occurrence // PhanUnreferencedUseNormal : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions @@ -46,15 +41,15 @@ 'src/blocks/contact-form/class-contact-form-block.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredFunction'], 'src/class-wpcom-rest-api-v2-endpoint-forms.php' => ['PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredFunction'], 'src/contact-form/class-admin.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanRedundantCondition', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod'], - 'src/contact-form/class-contact-form-field.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty'], + 'src/contact-form/class-contact-form-field.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyNullTypeMismatchProperty', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty'], 'src/contact-form/class-contact-form-plugin.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginRedundantAssignment', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod'], 'src/contact-form/class-contact-form-shortcode.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], - 'src/contact-form/class-contact-form.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginRedundantAssignment', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassProperty', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeProperty', 'PhanUnextractableAnnotationElementName'], + 'src/contact-form/class-contact-form.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginRedundantAssignment', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUnextractableAnnotationElementName'], 'src/dashboard/class-dashboard-view-switch.php' => ['PhanUnreferencedUseNormal'], 'src/dashboard/class-dashboard.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredConstant'], 'src/service/class-google-drive.php' => ['PhanTypeMismatchReturnProbablyReal'], 'tests/php/contact-form/test-class.contact-form-plugin.php' => ['PhanPluginMixedKeyNoKey'], - 'tests/php/contact-form/test-class.contact-form.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgument', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassProperty', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeReturnType'], + 'tests/php/contact-form/test-class.contact-form.php' => ['PhanDeprecatedFunction', 'PhanUndeclaredMethod'], ], // '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) diff --git a/projects/packages/forms/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/forms/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/forms/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/forms/src/contact-form/class-contact-form-field.php b/projects/packages/forms/src/contact-form/class-contact-form-field.php index 8bd6fdf707f74..7182e2550adaf 100644 --- a/projects/packages/forms/src/contact-form/class-contact-form-field.php +++ b/projects/packages/forms/src/contact-form/class-contact-form-field.php @@ -33,7 +33,7 @@ class Contact_Form_Field extends Contact_Form_Shortcode { /** * Default or POSTed value. * - * @var string + * @var string|string[] */ public $value; diff --git a/projects/packages/forms/src/contact-form/class-contact-form.php b/projects/packages/forms/src/contact-form/class-contact-form.php index 690f818ebe3a7..998ad602af831 100644 --- a/projects/packages/forms/src/contact-form/class-contact-form.php +++ b/projects/packages/forms/src/contact-form/class-contact-form.php @@ -8,6 +8,7 @@ namespace Automattic\Jetpack\Forms\ContactForm; use Automattic\Jetpack\Sync\Settings; +use PHPMailer\PHPMailer\PHPMailer; use WP_Error; /** @@ -49,7 +50,7 @@ class Contact_Form extends Contact_Form_Shortcode { /** * Form we are currently looking at. If processed, will become $last * - * @var Whatever + * @var Contact_Form */ public static $current_form; diff --git a/projects/packages/forms/tests/php/contact-form/test-class.contact-form.php b/projects/packages/forms/tests/php/contact-form/test-class.contact-form.php index 6d109dcca6bdb..124867d89a820 100644 --- a/projects/packages/forms/tests/php/contact-form/test-class.contact-form.php +++ b/projects/packages/forms/tests/php/contact-form/test-class.contact-form.php @@ -7,6 +7,8 @@ namespace Automattic\Jetpack\Forms\ContactForm; +use DOMDocument; +use DOMElement; use WorDBless\BaseTestCase; use WorDBless\Posts; @@ -928,7 +930,7 @@ public function render_field( $attributes ) { * @return DOMElement The first div element. */ public function getCommonDiv( $html ) { - $doc = new \DOMDocument(); + $doc = new DOMDocument(); $doc->loadHTML( $html ); return $this->getFirstElement( $doc, 'div' ); } @@ -936,15 +938,16 @@ public function getCommonDiv( $html ) { /** * Gets the first element in the given DOMDocument object. * - * @param DOMDocument $dom The DOMDocument object. - * @param string $tag The tag name. - * @param int $index The index. + * @param DOMDocument|DOMElement $dom The DOMDocument object. + * @param string $tag The tag name. + * @param int $index The index. * - * @return DOMElement The first element with the given tag. + * @return DOMElement|null The first element with the given tag. */ public function getFirstElement( $dom, $tag, $index = 0 ) { $elements = $dom->getElementsByTagName( $tag ); - return $elements->item( $index ); + $element = $elements->item( $index ); + return $element instanceof DOMElement ? $element : null; } /** @@ -981,7 +984,7 @@ public function assertFieldLabel( $wrapper_div, $attributes, $tag_name = 'label' $expected = 'date' === $type ? $attributes['label'] . ' ' . $attributes['format'] : $attributes['label']; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $this->assertEquals( $expected, trim( $label->nodeValue ), 'Label is not what we expect it to be...' ); + $this->assertEquals( $expected, trim( (string) $label->nodeValue ), 'Label is not what we expect it to be...' ); } /** diff --git a/projects/packages/identity-crisis/.phan/baseline.php b/projects/packages/identity-crisis/.phan/baseline.php index 3449c099c6a5f..ce89b5f571596 100644 --- a/projects/packages/identity-crisis/.phan/baseline.php +++ b/projects/packages/identity-crisis/.phan/baseline.php @@ -12,8 +12,6 @@ // PhanDeprecatedFunction : 20+ occurrences // PhanTypeMismatchArgument : 5 occurrences // PhanUndeclaredClassMethod : 3 occurrences - // PhanTypeMismatchReturnProbablyReal : 2 occurrences - // PhanUndeclaredTypeReturnType : 2 occurrences // PhanNoopNew : 1 occurrence // PhanParamTooMany : 1 occurrence // PhanPluginRedundantAssignment : 1 occurrence @@ -28,7 +26,7 @@ 'src/class-identity-crisis.php' => ['PhanDeprecatedFunction', 'PhanPluginRedundantAssignment', 'PhanRedundantCondition'], 'src/class-rest-endpoints.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'src/class-url-secret.php' => ['PhanTypeMismatchProperty', 'PhanTypeMismatchReturnNullable', 'PhanUndeclaredClassMethod'], - 'tests/php/test-identity-crisis.php' => ['PhanParamTooMany', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredTypeReturnType'], + 'tests/php/test-identity-crisis.php' => ['PhanParamTooMany', 'PhanTypeMismatchArgument'], 'tests/php/test-rest-endpoints.php' => ['PhanNoopNew'], 'tests/php/test-url-secret.php' => ['PhanTypeMismatchArgumentInternal'], ], diff --git a/projects/packages/identity-crisis/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/identity-crisis/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/identity-crisis/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/identity-crisis/package.json b/projects/packages/identity-crisis/package.json index c4afe57c47837..4858a0c0feee3 100644 --- a/projects/packages/identity-crisis/package.json +++ b/projects/packages/identity-crisis/package.json @@ -1,6 +1,6 @@ { "name": "jetpack-identity-crisis", - "version": "0.18.4", + "version": "0.18.5-alpha", "description": "Jetpack Identity Crisis", "main": "_inc/admin.jsx", "repository": { diff --git a/projects/packages/identity-crisis/src/class-identity-crisis.php b/projects/packages/identity-crisis/src/class-identity-crisis.php index 5ec73ee3e1eaa..7ff7304fca953 100644 --- a/projects/packages/identity-crisis/src/class-identity-crisis.php +++ b/projects/packages/identity-crisis/src/class-identity-crisis.php @@ -26,7 +26,7 @@ class Identity_Crisis { /** * Package Version */ - const PACKAGE_VERSION = '0.18.4'; + const PACKAGE_VERSION = '0.18.5-alpha'; /** * Package Slug diff --git a/projects/packages/identity-crisis/tests/php/test-identity-crisis.php b/projects/packages/identity-crisis/tests/php/test-identity-crisis.php index af434aaa3220e..e935e4815b5d4 100644 --- a/projects/packages/identity-crisis/tests/php/test-identity-crisis.php +++ b/projects/packages/identity-crisis/tests/php/test-identity-crisis.php @@ -564,7 +564,7 @@ public function test_check_response_for_idc_with_error_code( $input, $option_upd /** * Data provider for test_check_response_for_idc_with_error_code * - * @return The test data with the structure: + * @return array[] The test data with the structure: * 'input' => The input for the check_response_for_idc method. * 'option_updated' => Whether the check_response_for_idc method should update * the sync_error_idc option. @@ -668,7 +668,7 @@ public function test_check_http_response_for_idc_detected_idc_detected( $input ) /** * Data provider for test_check_http_response_for_idc_detected_idc_detected. * - * @return The test data with the structure: + * @return array[] The test data with the structure: * 'input' => The input for the check_response_for_idc method. * 'option_updated' => Whether the check_response_for_idc method should update * the sync_error_idc option. diff --git a/projects/packages/image-cdn/.phan/baseline.php b/projects/packages/image-cdn/.phan/baseline.php index bff5b4f2d3265..f3392c18e8bba 100644 --- a/projects/packages/image-cdn/.phan/baseline.php +++ b/projects/packages/image-cdn/.phan/baseline.php @@ -15,27 +15,25 @@ // PhanPluginDuplicateConditionalNullCoalescing : 4 occurrences // PhanUndeclaredFunctionInCallable : 4 occurrences // PhanPossiblyUndeclaredVariable : 3 occurrences - // PhanUndeclaredClassMethod : 3 occurrences // PhanTypeMismatchArgumentProbablyReal : 2 occurrences // PhanTypeMismatchPropertyProbablyReal : 2 occurrences // PhanTypeMismatchReturn : 2 occurrences + // PhanUndeclaredClassMethod : 2 occurrences // PhanNonClassMethodCall : 1 occurrence // PhanTypeArraySuspicious : 1 occurrence // PhanTypeMismatchArgumentInternal : 1 occurrence // PhanTypeMismatchArgumentNullable : 1 occurrence // PhanTypeMismatchArgumentNullableInternal : 1 occurrence - // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMismatchReturnProbablyReal : 1 occurrence // PhanTypeObjectUnsetDeclaredProperty : 1 occurrence // PhanUndeclaredClassInCallable : 1 occurrence // PhanUndeclaredMethod : 1 occurrence // PhanUndeclaredStaticMethod : 1 occurrence - // PhanUndeclaredTypeProperty : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'src/class-image-cdn-core.php' => ['PhanTypeMismatchReturn'], - 'src/class-image-cdn-image-sizes.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassInCallable', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty'], + 'src/class-image-cdn-image-sizes.php' => ['PhanPluginSimplifyExpressionBool', 'PhanUndeclaredClassInCallable'], 'src/class-image-cdn.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredClassMethod'], 'src/compatibility/photon.php' => ['PhanParamTooMany', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredFunctionInCallable'], 'tests/php/test_class.image_cdn.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanUndeclaredStaticMethod'], diff --git a/projects/packages/image-cdn/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/image-cdn/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/image-cdn/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/image-cdn/package.json b/projects/packages/image-cdn/package.json index 4f8fcb1226ed1..8548562808605 100644 --- a/projects/packages/image-cdn/package.json +++ b/projects/packages/image-cdn/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-image-cdn", - "version": "0.3.6", + "version": "0.3.7-alpha", "description": "Serve images through Jetpack's powerful CDN", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/image-cdn/#readme", "bugs": { diff --git a/projects/packages/image-cdn/src/class-image-cdn-image-sizes.php b/projects/packages/image-cdn/src/class-image-cdn-image-sizes.php index f9e122895a08e..bd7458d8bc472 100644 --- a/projects/packages/image-cdn/src/class-image-cdn-image-sizes.php +++ b/projects/packages/image-cdn/src/class-image-cdn-image-sizes.php @@ -24,7 +24,7 @@ class Image_CDN_Image_Sizes { /** * Image to be resized. * - * @var Image + * @var Image_CDN_Image */ public $image; diff --git a/projects/packages/image-cdn/src/class-image-cdn.php b/projects/packages/image-cdn/src/class-image-cdn.php index aacce0d6d855a..3efae89543fb0 100644 --- a/projects/packages/image-cdn/src/class-image-cdn.php +++ b/projects/packages/image-cdn/src/class-image-cdn.php @@ -14,7 +14,7 @@ */ final class Image_CDN { - const PACKAGE_VERSION = '0.3.6'; + const PACKAGE_VERSION = '0.3.7-alpha'; /** * Singleton. diff --git a/projects/packages/import/.phan/baseline.php b/projects/packages/import/.phan/baseline.php index f2813c410bec3..9f5227f9f13a5 100644 --- a/projects/packages/import/.phan/baseline.php +++ b/projects/packages/import/.phan/baseline.php @@ -20,11 +20,10 @@ // PhanTraitParentReference : 1 occurrence // PhanUndeclaredClassMethod : 1 occurrence // PhanUndeclaredMethod : 1 occurrence - // PhanUndeclaredTypeReturnType : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/endpoints/class-attachment.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchReturn', 'PhanUndeclaredTypeReturnType'], + 'src/endpoints/class-attachment.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchReturn'], 'src/endpoints/class-category.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'src/endpoints/class-end.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchReturnProbablyReal'], 'src/endpoints/class-global-style.php' => ['PhanTypeMismatchReturn'], diff --git a/projects/packages/import/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/import/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/import/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/import/package.json b/projects/packages/import/package.json index 2f58225fbd4fe..a1277bc134e57 100644 --- a/projects/packages/import/package.json +++ b/projects/packages/import/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-import", - "version": "0.8.3", + "version": "0.8.4-alpha", "description": "Set of REST API routes used in WPCOM Unified Importer.", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/import/#readme", "bugs": { diff --git a/projects/packages/import/src/class-main.php b/projects/packages/import/src/class-main.php index d3b39531e073b..94e7530a12d67 100644 --- a/projects/packages/import/src/class-main.php +++ b/projects/packages/import/src/class-main.php @@ -20,7 +20,7 @@ class Main { * * @var string */ - const PACKAGE_VERSION = '0.8.3'; + const PACKAGE_VERSION = '0.8.4-alpha'; /** * A list of all the routes. diff --git a/projects/packages/import/src/endpoints/class-attachment.php b/projects/packages/import/src/endpoints/class-attachment.php index 51dcccc3c43fc..cbdf800eac8a8 100644 --- a/projects/packages/import/src/endpoints/class-attachment.php +++ b/projects/packages/import/src/endpoints/class-attachment.php @@ -211,7 +211,7 @@ static function ( $data ) use ( $request ) { * Prepares a single attachment for create or update. This function overrides the parent function * * @param WP_REST_Request $request Request object. - * @return stdClass|WP_Error Post object. + * @return \stdClass|WP_Error Post object. */ protected function prepare_item_for_database( $request ) { $prepared_attachment = parent::prepare_item_for_database( $request ); diff --git a/projects/packages/jetpack-mu-wpcom/.phan/baseline.php b/projects/packages/jetpack-mu-wpcom/.phan/baseline.php index 0ca486187e701..6e9c95277d046 100644 --- a/projects/packages/jetpack-mu-wpcom/.phan/baseline.php +++ b/projects/packages/jetpack-mu-wpcom/.phan/baseline.php @@ -9,20 +9,18 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgumentProbablyReal : 50+ occurrences - // PhanTypeMismatchArgument : 30+ occurrences - // PhanTypeArraySuspicious : 25+ occurrences - // PhanUndeclaredTypeParameter : 15+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 30+ occurrences + // PhanTypeMismatchArgument : 15+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 8 occurrences - // PhanTypeMismatchReturnProbablyReal : 7 occurrences - // PhanUndeclaredTypeReturnType : 6 occurrences - // PhanTypeMismatchReturn : 5 occurrences + // PhanTypeMismatchReturn : 6 occurrences + // PhanTypeMismatchReturnProbablyReal : 4 occurrences // PhanUndeclaredClassMethod : 4 occurrences // PhanNoopNew : 3 occurrences + // PhanTypePossiblyInvalidDimOffset : 3 occurrences // PhanUndeclaredFunction : 3 occurrences - // PhanUndeclaredTypeProperty : 3 occurrences // PhanEmptyFQSENInCallable : 2 occurrences // PhanParamTooMany : 2 occurrences + // PhanTypeArraySuspicious : 2 occurrences // PhanTypeArraySuspiciousNullable : 2 occurrences // PhanTypeMismatchArgumentInternal : 2 occurrences // PhanTypeMismatchDefault : 2 occurrences @@ -37,7 +35,6 @@ // PhanRedundantCondition : 1 occurrence // PhanTypeComparisonToArray : 1 occurrence // PhanTypeMismatchDimFetch : 1 occurrence - // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMismatchReturnNullable : 1 occurrence // PhanTypeNonVarPassByRef : 1 occurrence // PhanTypeVoidArgument : 1 occurrence @@ -51,27 +48,26 @@ 'src/features/100-year-plan/enhanced-ownership.php' => ['PhanEmptyFQSENInCallable'], 'src/features/100-year-plan/locked-mode.php' => ['PhanEmptyFQSENInCallable'], 'src/features/admin-color-schemes/admin-color-schemes.php' => ['PhanUndeclaredConstant'], - 'src/features/block-patterns/block-patterns.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredTypeParameter'], 'src/features/block-patterns/class-wpcom-block-patterns-utils.php' => ['PhanTypeMismatchReturnNullable'], 'src/features/cloudflare-analytics/cloudflare-analytics.php' => ['PhanUndeclaredClassMethod'], 'src/features/coming-soon/coming-soon.php' => ['PhanTypeArraySuspicious', 'PhanTypeMismatchArgumentInternal', 'PhanUndeclaredFunction', 'PhanUndeclaredFunctionInCallable'], 'src/features/coming-soon/fallback-coming-soon-page.php' => ['PhanTypeMismatchArgument', 'PhanTypeVoidArgument'], 'src/features/error-reporting/error-reporting.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], - 'src/features/launchpad/class-launchpad-task-lists.php' => ['PhanNoopArrayAccess', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType'], - 'src/features/launchpad/launchpad-task-definitions.php' => ['PhanRedundantCondition', 'PhanTypeArraySuspiciousNullable', 'PhanTypeComparisonToArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeMissingReturn'], - 'src/features/launchpad/launchpad.php' => ['PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeReturnType'], + 'src/features/launchpad/class-launchpad-task-lists.php' => ['PhanNoopArrayAccess', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], + 'src/features/launchpad/launchpad-task-definitions.php' => ['PhanRedundantCondition', 'PhanTypeArraySuspiciousNullable', 'PhanTypeComparisonToArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeMissingReturn', 'PhanTypePossiblyInvalidDimOffset'], + 'src/features/launchpad/launchpad.php' => ['PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod'], 'src/features/marketplace-products-updater/class-marketplace-products-updater.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn', 'PhanUnextractableAnnotationSuffix'], 'src/features/media/heif-support.php' => ['PhanPluginSimplifyExpressionBool'], - 'src/features/verbum-comments/class-verbum-comments.php' => ['PhanImpossibleTypeComparison', 'PhanNoopNew', 'PhanParamTooMany', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanUndeclaredFunction', 'PhanUndeclaredTypeReturnType'], + 'src/features/verbum-comments/class-verbum-comments.php' => ['PhanImpossibleTypeComparison', 'PhanNoopNew', 'PhanParamTooMany', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredFunction'], 'src/features/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-launchpad.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/features/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-site-migration-migrate-guru-key.php' => ['PhanUndeclaredClassMethod'], 'src/features/wpcom-site-menu/wpcom-site-menu.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassInCallable', 'PhanUndeclaredFunctionInCallable'], 'tests/lib/functions-wordpress.php' => ['PhanRedefineFunction'], - 'tests/php/features/block-patterns/class-wpcom-block-patterns-from-api-test.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'], + 'tests/php/features/block-patterns/class-wpcom-block-patterns-from-api-test.php' => ['PhanDeprecatedFunction'], 'tests/php/features/coming-soon/class-coming-soon-test.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/features/launchpad/class-launchpad-jetpack-connection-client-mock.php' => ['PhanTypeMissingReturn'], - 'tests/php/features/launchpad/class-launchpad-task-list-validation-test.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument'], - 'tests/php/features/launchpad/class-launchpad-task-lists-test.php' => ['PhanTypeArraySuspicious', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeNonVarPassByRef'], + 'tests/php/features/launchpad/class-launchpad-task-list-validation-test.php' => ['PhanNonClassMethodCall'], + 'tests/php/features/launchpad/class-launchpad-task-lists-test.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeNonVarPassByRef'], 'tests/php/features/launchpad/class-launchpad-wpcom-requests-test.php' => ['PhanTypeMismatchArgument'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/jetpack-mu-wpcom/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/jetpack-mu-wpcom/src/features/block-patterns/block-patterns.php b/projects/packages/jetpack-mu-wpcom/src/features/block-patterns/block-patterns.php index eed97189217a6..b531d339193a3 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/block-patterns/block-patterns.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/block-patterns/block-patterns.php @@ -32,7 +32,7 @@ function wpcom_unregister_jetpack_patterns() { * Return a function that loads and register block patterns from the API. This * function can be registered to the `rest_dispatch_request` filter. * - * @param Function $register_patterns_func A function that when called will + * @param callable $register_patterns_func A function that when called will * register the relevant block patterns in the registry. */ function register_patterns_on_api_request( $register_patterns_func ) { diff --git a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php index 3a9c09ed2c28f..e66330395e9a9 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php @@ -6,6 +6,12 @@ * @since 1.5.0 */ +// Type aliases used in a bunch of places in this file. Unfortunately Phan doesn't have a way to set these more globally than copy-pasting them into each file needing them. +<<task_list_registry; @@ -318,7 +324,7 @@ public function get_task( $id ) { /** * Get the required task ids for a given task list. * - * @param array $task_list_id Task list. + * @param string $task_list_id Task list ID. * @return array Required task ids. */ public function get_required_task_ids( $task_list_id ) { @@ -333,7 +339,7 @@ public function get_required_task_ids( $task_list_id ) { * Check if the task list requires the last task to be completed in order to consider * the task list complete. * - * @param array $task_list_id Task list id. + * @param string $task_list_id Task list id. * @return bool True if the last task must be completed, false if not. */ public function get_require_last_task_completion( $task_list_id ) { @@ -358,7 +364,7 @@ public function is_task_list_completed( $task_list_id ) { /** * Get all registered Launchpad Tasks. * - * @return array All registered Launchpad Tasks. + * @return Task[] All registered Launchpad Tasks. */ public function get_all_tasks() { return $this->task_registry; @@ -455,10 +461,10 @@ private function build_task( $task, $launchpad_context = null ) { /** * Given a task or task list definition and a possible callback, call it and return the value. * - * @param array $item The task or task list definition. - * @param string $callback The callback to attempt to call. - * @param mixed $default The default value, passed to the callback if it exists. - * @param array $data Any additional data specific to the callback. + * @param Task|Task_List $item The task or task list definition. + * @param string $callback The callback to attempt to call. + * @param mixed $default The default value, passed to the callback if it exists. + * @param array $data Any additional data specific to the callback. * @return mixed The value returned by the callback, or the default value. */ private function load_value_from_callback( $item, $callback, $default = '', $data = array() ) { @@ -537,7 +543,7 @@ private function load_repetition_count( $task ) { /** * Helper function to load the Calypso path for a task. * - * @param array $task A task definition. + * @param Task $task A task definition. * @param string|null $launchpad_context Optional. Screen where Launchpad is loading. * @return string|null */ @@ -598,7 +604,7 @@ private function is_valid_admin_url_or_absolute_path( $input ) { /** * Checks if a task is disabled * - * @param array $task Task definition. + * @param Task $task Task definition. * @return boolean */ public function is_task_disabled( $task ) { @@ -720,7 +726,7 @@ public static function validate_task_list( $task_list ) { * Get currently active tasks. * * @param string $task_list_id Optional. Will default to `site_intent` option. - * @return array Array of active tasks. + * @return Task[] Array of active tasks. */ private function get_active_tasks( $task_list_id = null ) { $task_list_id = $task_list_id ? $task_list_id : get_option( 'site_intent' ); @@ -740,7 +746,7 @@ private function get_active_tasks( $task_list_id = null ) { * Gets a list of completed tasks. * * @param string $task_list_id Optional. Will default to `site_intent` option. - * @return array Array of completed tasks. + * @return Task[] Array of completed tasks. */ private function get_completed_tasks( $task_list_id = null ) { $task_list_id = $task_list_id ? $task_list_id : get_option( 'site_intent' ); diff --git a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php index d295e940e9d23..5325d9e7ebcd2 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php @@ -5,6 +5,11 @@ * @package automattic/jetpack-mu-wpcom */ +// Type aliases used in a bunch of places in this file. Unfortunately Phan doesn't have a way to set these more globally than copy-pasting them into each file needing them. +<< [ 'src/class-activitylog.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'src/class-initializer.php' => ['PhanImpossibleCondition', 'PhanNoopNew', 'PhanParamTooMany', 'PhanRedundantCondition', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassProperty', 'PhanUndeclaredTypeProperty'], + 'src/class-initializer.php' => ['PhanImpossibleCondition', 'PhanNoopNew', 'PhanParamTooMany', 'PhanRedundantCondition', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod'], 'src/class-jetpack-manage.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'src/class-products.php' => ['PhanNonClassMethodCall'], 'src/class-rest-product-data.php' => ['PhanParamTooMany', 'PhanTypeMismatchReturn'], @@ -69,7 +65,7 @@ 'tests/php/test-hybrid-product.php' => ['PhanTypeMismatchArgumentNullable'], 'tests/php/test-module-product.php' => ['PhanUndeclaredClassStaticProperty', 'PhanUndeclaredConstant'], 'tests/php/test-product-multiple-filenames.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchPropertyDefault'], - 'tests/php/test-products.php' => ['PhanNonClassMethodCall', 'PhanTypeArraySuspicious', 'PhanUndeclaredTypeParameter'], + 'tests/php/test-products.php' => ['PhanNonClassMethodCall'], 'tests/php/test-search-product.php' => ['PhanTypeMismatchArgumentNullable'], 'tests/php/test-social-product.php' => ['PhanTypeMismatchArgumentNullable'], 'tests/php/test-videopress-product.php' => ['PhanTypeMismatchArgumentNullable'], diff --git a/projects/packages/my-jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/my-jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index 66d83ebf26ecf..939b60561f6ae 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-my-jetpack", - "version": "4.22.2", + "version": "4.22.3-alpha", "description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme", "bugs": { diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index e16231e7893a2..5005a9c216822 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -37,7 +37,7 @@ class Initializer { * * @var string */ - const PACKAGE_VERSION = '4.22.2'; + const PACKAGE_VERSION = '4.22.3-alpha'; /** * HTML container ID for the IDC screen on My Jetpack page. @@ -62,7 +62,7 @@ class Initializer { /** * Holds info/data about the site (from the /sites/%d endpoint) * - * @var stdClass Object + * @var object */ public static $site_info; @@ -509,7 +509,7 @@ public static function get_site() { /** * Populates the self::$site_info var with site data from the /sites/%d endpoint * - * @return Object|WP_Error + * @return object|WP_Error */ public static function get_site_info() { static $site_info = null; diff --git a/projects/packages/my-jetpack/tests/php/test-products.php b/projects/packages/my-jetpack/tests/php/test-products.php index 0626b00ae99da..f6de89a789468 100644 --- a/projects/packages/my-jetpack/tests/php/test-products.php +++ b/projects/packages/my-jetpack/tests/php/test-products.php @@ -28,7 +28,7 @@ public function tear_down() { /** * Filter that returns a non existent class * - * @param arrray $classes The Products classes. + * @param array $classes The Products classes. * @return array */ public function return_non_existent_class( $classes ) { @@ -39,7 +39,7 @@ public function return_non_existent_class( $classes ) { /** * Filter that returns an invalid class * - * @param arrray $classes The Products classes. + * @param array $classes The Products classes. * @return array */ public function return_invalid_class( $classes ) { @@ -50,7 +50,7 @@ public function return_invalid_class( $classes ) { /** * Filter that returns a valid class * - * @param arrray $classes The Products classes. + * @param array $classes The Products classes. * @return array */ public function return_valid_class( $classes ) { diff --git a/projects/packages/publicize/.phan/baseline.php b/projects/packages/publicize/.phan/baseline.php index b1570586c596e..98a7e91c0bf6c 100644 --- a/projects/packages/publicize/.phan/baseline.php +++ b/projects/packages/publicize/.phan/baseline.php @@ -9,22 +9,18 @@ */ return [ // # Issue statistics: - // PhanUndeclaredClassMethod : 20+ occurrences // PhanTypeMismatchArgument : 15+ occurrences // PhanTypeMismatchArgumentProbablyReal : 10+ occurrences // PhanDeprecatedFunction : 9 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 7 occurrences - // PhanTypeMismatchProperty : 6 occurrences // PhanUndeclaredStaticMethod : 6 occurrences + // PhanUndeclaredClassMethod : 5 occurrences // PhanTypeMismatchArgumentNullable : 3 occurrences - // PhanUndeclaredTypeProperty : 3 occurrences // PhanPluginMixedKeyNoKey : 2 occurrences // PhanPossiblyUndeclaredVariable : 2 occurrences - // PhanTypeMismatchReturn : 2 occurrences // PhanTypeMismatchReturnProbablyReal : 2 occurrences // PhanTypeMissingReturn : 2 occurrences // PhanUndeclaredFunction : 2 occurrences - // PhanUndeclaredTypeReturnType : 2 occurrences // PhanImpossibleCondition : 1 occurrence // PhanParamSignatureMismatch : 1 occurrence // PhanPluginDuplicateExpressionAssignmentOperation : 1 occurrence @@ -33,14 +29,15 @@ // PhanTypeMismatchArgumentNullableInternal : 1 occurrence // PhanTypeMismatchDefault : 1 occurrence // PhanTypeMismatchDimFetch : 1 occurrence + // PhanTypeMismatchReturn : 1 occurrence // PhanUndeclaredMethod : 1 occurrence // PhanUnextractableAnnotationSuffix : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'src/auto-conversion-settings/class-rest-settings-controller.php' => ['PhanPluginMixedKeyNoKey'], - 'src/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturn', 'PhanUndeclaredTypeReturnType'], - 'src/class-keyring-helper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanUndeclaredTypeReturnType'], + 'src/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], + 'src/class-keyring-helper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault'], 'src/class-publicize-base.php' => ['PhanImpossibleCondition', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredFunction'], 'src/class-publicize-setup.php' => ['PhanTypeMismatchArgument', 'PhanUnextractableAnnotationSuffix'], 'src/class-publicize-ui.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod'], @@ -50,9 +47,8 @@ 'src/social-image-generator/class-rest-settings-controller.php' => ['PhanPluginMixedKeyNoKey'], 'src/social-image-generator/class-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/social-image-generator/class-setup.php' => ['PhanTypeMismatchArgumentNullable'], - 'tests/php/jetpack-social-settings/test-auto-conversion.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty'], - 'tests/php/jetpack-social-settings/test-jetpack-social-settings.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty'], - 'tests/php/jetpack-social-settings/test-social-image-generator-settings.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty'], + 'tests/php/jetpack-social-settings/test-auto-conversion.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing'], + 'tests/php/jetpack-social-settings/test-jetpack-social-settings.php' => ['PhanDeprecatedFunction'], 'tests/php/test-connections-post-field.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgument'], 'tests/php/test-publicize-og-optimization.php' => ['PhanDeprecatedFunction'], 'tests/php/test-social-image-generator/test-post-settings.php' => ['PhanDeprecatedFunction'], diff --git a/projects/packages/publicize/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/publicize/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/publicize/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/publicize/package.json b/projects/packages/publicize/package.json index 84ae1d4ca6f2d..0ff7503bf815e 100644 --- a/projects/packages/publicize/package.json +++ b/projects/packages/publicize/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-publicize", - "version": "0.42.12", + "version": "0.42.13-alpha", "description": "Publicize makes it easy to share your site’s posts on several social media networks automatically when you publish a new post.", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/publicize/#readme", "bugs": { diff --git a/projects/packages/publicize/src/class-connections-post-field.php b/projects/packages/publicize/src/class-connections-post-field.php index aa0660b234397..76254fcc7314a 100644 --- a/projects/packages/publicize/src/class-connections-post-field.php +++ b/projects/packages/publicize/src/class-connections-post-field.php @@ -223,7 +223,7 @@ public function get( $post_array, $field_name, $request, $object_type ) { // php * @param object $post Post data to insert/update. * @param WP_REST_Request $request API request. * - * @return Filtered $post + * @return object|WP_Error Filtered $post */ public function rest_pre_insert( $post, $request ) { $request_connections = ! empty( $request['jetpack_publicize_connections'] ) ? $request['jetpack_publicize_connections'] : array(); diff --git a/projects/packages/publicize/src/class-keyring-helper.php b/projects/packages/publicize/src/class-keyring-helper.php index a2f468bcfcfe5..31046b00e5031 100644 --- a/projects/packages/publicize/src/class-keyring-helper.php +++ b/projects/packages/publicize/src/class-keyring-helper.php @@ -104,7 +104,7 @@ public static function register_sharing_page() { * @param string $service Shortname of a specific service. * @param array $params Parameters to append to an API connection URL. * - * @return URL to specific public-api process + * @return string URL to specific public-api process */ private static function api_url( $service = false, $params = array() ) { /** diff --git a/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php b/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php index 533f01732ecaf..67dcffaf3609c 100644 --- a/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php +++ b/projects/packages/publicize/tests/php/jetpack-social-settings/test-auto-conversion.php @@ -20,7 +20,7 @@ class Auto_Conversion_Test extends BaseTestCase { /** * Instance of the Settings class. * - * @var Settings $settings + * @var SocialSettings $settings */ protected $settings; diff --git a/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php b/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php index 678c120d7e226..c3bbd5789382e 100644 --- a/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php +++ b/projects/packages/publicize/tests/php/jetpack-social-settings/test-jetpack-social-settings.php @@ -21,7 +21,7 @@ class Jetpack_Social_Settings_Test extends BaseTestCase { /** * Instance of the Settings class. * - * @var Settings $settings + * @var SocialSettings $settings */ protected $settings; diff --git a/projects/packages/publicize/tests/php/jetpack-social-settings/test-social-image-generator-settings.php b/projects/packages/publicize/tests/php/jetpack-social-settings/test-social-image-generator-settings.php index 7e8817be44ae7..05828ce93fef0 100644 --- a/projects/packages/publicize/tests/php/jetpack-social-settings/test-social-image-generator-settings.php +++ b/projects/packages/publicize/tests/php/jetpack-social-settings/test-social-image-generator-settings.php @@ -22,7 +22,7 @@ class Social_Image_Generator_Settings_Test extends BaseTestCase { /** * Instance of the Settings class. * - * @var Settings $settings + * @var SocialSettings $settings */ protected $settings; diff --git a/projects/packages/search/.phan/baseline.php b/projects/packages/search/.phan/baseline.php index c345a7db8bc78..bd4e989ee3ae1 100644 --- a/projects/packages/search/.phan/baseline.php +++ b/projects/packages/search/.phan/baseline.php @@ -12,23 +12,20 @@ // PhanUnextractableAnnotation : 45+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 10+ occurrences // PhanTypeMismatchReturnProbablyReal : 9 occurrences - // PhanUndeclaredClassMethod : 8 occurrences // PhanTypeMismatchArgument : 7 occurrences // PhanTypeMismatchArgumentProbablyReal : 7 occurrences - // PhanUndeclaredTypeProperty : 7 occurrences // PhanRedundantCondition : 6 occurrences - // PhanTypeMismatchProperty : 6 occurrences // PhanUndeclaredProperty : 6 occurrences // PhanTypeMismatchReturn : 5 occurrences // PhanDeprecatedFunction : 4 occurrences // PhanImpossibleCondition : 4 occurrences + // PhanTypeMismatchProperty : 4 occurrences + // PhanUndeclaredClassMethod : 4 occurrences // PhanPluginMixedKeyNoKey : 3 occurrences // PhanTypeSuspiciousEcho : 3 occurrences // PhanNoopNew : 2 occurrences // PhanTypePossiblyInvalidDimOffset : 2 occurrences - // PhanUndeclaredClassProperty : 2 occurrences // PhanUndeclaredFunctionInCallable : 2 occurrences - // PhanUndeclaredTypeParameter : 2 occurrences // PhanDeprecatedPartiallySupportedCallable : 1 occurrence // PhanPluginRedundantAssignment : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence @@ -39,17 +36,18 @@ // PhanTypeMismatchDefault : 1 occurrence // PhanTypeMismatchDimAssignment : 1 occurrence // PhanUndeclaredClassReference : 1 occurrence + // PhanUndeclaredTypeProperty : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'compatibility/jetpack.php' => ['PhanUndeclaredClassMethod'], 'src/class-cli.php' => ['PhanTypeMismatchArgument'], - 'src/class-helper.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanImpossibleCondition', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredTypeParameter'], + 'src/class-helper.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanImpossibleCondition', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference'], 'src/class-options.php' => ['PhanPluginSimplifyExpressionBool'], 'src/class-plan.php' => ['PhanDeprecatedFunction', 'PhanUnextractableAnnotation'], 'src/class-rest-controller.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-template-tags.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'src/classic-search/class-classic-search.php' => ['PhanImpossibleCondition', 'PhanPluginRedundantAssignment', 'PhanRedundantCondition', 'PhanTypeComparisonToArray', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassProperty'], + 'src/classic-search/class-classic-search.php' => ['PhanImpossibleCondition', 'PhanPluginRedundantAssignment', 'PhanRedundantCondition', 'PhanTypeComparisonToArray', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'src/customizer/customize-controls/class-excluded-post-types-control.php' => ['PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal'], 'src/dashboard/class-dashboard.php' => ['PhanUnextractableAnnotation'], 'src/dashboard/class-initial-state.php' => ['PhanTypeMismatchArgument'], @@ -59,7 +57,7 @@ 'src/wpes/class-query-builder.php' => ['PhanImpossibleCondition', 'PhanRedundantCondition', 'PhanTypeMismatchDimAssignment', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], 'src/wpes/class-query-parser.php' => ['PhanUndeclaredProperty'], 'tests/php/test-get-ios-version.php' => ['PhanUndeclaredFunctionInCallable'], - 'tests/php/test-helpers.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredTypeProperty', 'PhanUnextractableAnnotation'], + 'tests/php/test-helpers.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument', 'PhanTypePossiblyInvalidDimOffset', 'PhanUnextractableAnnotation'], 'tests/php/test-plan.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/search/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/search/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/search/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/search/package.json b/projects/packages/search/package.json index 2ad4e8f1e2f38..083c22ac879c0 100644 --- a/projects/packages/search/package.json +++ b/projects/packages/search/package.json @@ -1,6 +1,6 @@ { "name": "jetpack-search", - "version": "0.44.3", + "version": "0.44.4-alpha", "description": "Package for Jetpack Search products", "main": "main.js", "directories": { diff --git a/projects/packages/search/src/class-helper.php b/projects/packages/search/src/class-helper.php index f7864e523fe42..7661633a4ead5 100644 --- a/projects/packages/search/src/class-helper.php +++ b/projects/packages/search/src/class-helper.php @@ -754,7 +754,7 @@ public static function generate_post_type_customizer_ids() { * * @since 8.9.0 * - * @param any $value from the customizer form. + * @param mixed $value from the customizer form. * @return string either '0' or '1'. */ public static function sanitize_checkbox_value( $value ) { @@ -766,7 +766,7 @@ public static function sanitize_checkbox_value( $value ) { * * @since 8.9.0 * - * @param any $value from the database. + * @param mixed $value from the database. * @return boolean */ public static function sanitize_checkbox_value_for_js( $value ) { diff --git a/projects/packages/search/src/class-package.php b/projects/packages/search/src/class-package.php index 01dac928bec54..453f93acc1a7f 100644 --- a/projects/packages/search/src/class-package.php +++ b/projects/packages/search/src/class-package.php @@ -11,7 +11,7 @@ * Search package general information */ class Package { - const VERSION = '0.44.3'; + const VERSION = '0.44.4-alpha'; const SLUG = 'search'; /** diff --git a/projects/packages/search/tests/php/test-helpers.php b/projects/packages/search/tests/php/test-helpers.php index 020237a310459..239ef24130dcc 100644 --- a/projects/packages/search/tests/php/test-helpers.php +++ b/projects/packages/search/tests/php/test-helpers.php @@ -22,37 +22,37 @@ class Test_Helpers extends TestCase { /** * Request URI * - * @var any + * @var string */ protected $request_uri; /** * $_GET. * - * @var any + * @var array */ protected $get; /** * $_POST. * - * @var any + * @var array */ protected $post; /** * Registered widgets.. * - * @var any + * @var array */ protected $registered_widgets; /** * Query * - * @var any + * @var mixed */ protected $query; /** * Post Types * - * @var any + * @var mixed */ protected $post_types; diff --git a/projects/packages/stats/.phan/baseline.php b/projects/packages/stats/.phan/baseline.php index d4f5afd08e69d..1260cf08d8882 100644 --- a/projects/packages/stats/.phan/baseline.php +++ b/projects/packages/stats/.phan/baseline.php @@ -9,15 +9,12 @@ */ return [ // # Issue statistics: - // PhanUndeclaredClassMethod : 55+ occurrences // PhanParamTooMany : 7 occurrences // PhanUnextractableAnnotationSuffix : 5 occurrences // PhanTypeVoidAssignment : 4 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 2 occurrences // PhanDeprecatedFunction : 1 occurrence - // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence - // PhanUndeclaredTypeProperty : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -26,7 +23,7 @@ 'src/class-wpcom-stats.php' => ['PhanTypeMismatchReturn', 'PhanUnextractableAnnotationSuffix'], 'tests/php/test-main.php' => ['PhanParamTooMany', 'PhanTypeVoidAssignment'], 'tests/php/test-options.php' => ['PhanTypeVoidAssignment'], - 'tests/php/test-wpcom-stats.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty'], + 'tests/php/test-wpcom-stats.php' => ['PhanDeprecatedFunction'], 'tests/php/test-xmlrpc-provider.php' => ['PhanParamTooMany', 'PhanTypeVoidAssignment'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/stats/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/stats/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/stats/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/stats/src/class-package-version.php b/projects/packages/stats/src/class-package-version.php index d91499ada4344..9700c9bd3896c 100644 --- a/projects/packages/stats/src/class-package-version.php +++ b/projects/packages/stats/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '0.12.3'; + const PACKAGE_VERSION = '0.12.4-alpha'; const PACKAGE_SLUG = 'stats'; diff --git a/projects/packages/stats/tests/php/test-wpcom-stats.php b/projects/packages/stats/tests/php/test-wpcom-stats.php index 4ba126a3ae915..03eedaad2340a 100644 --- a/projects/packages/stats/tests/php/test-wpcom-stats.php +++ b/projects/packages/stats/tests/php/test-wpcom-stats.php @@ -18,7 +18,7 @@ class Test_WPCOM_Stats extends StatsBaseTestCase { /** * Mocked WPCOM_Stats. * - * @var Mock_WPCOM_Stats + * @var WPCOM_Stats&\PHPUnit\Framework\MockObject\MockObject */ protected $wpcom_stats; diff --git a/projects/packages/sync/.phan/baseline.php b/projects/packages/sync/.phan/baseline.php index 3ec2ca5c211de..a91820daeddd4 100644 --- a/projects/packages/sync/.phan/baseline.php +++ b/projects/packages/sync/.phan/baseline.php @@ -20,13 +20,11 @@ // PhanPluginSimplifyExpressionBool : 9 occurrences // PhanPossiblyUndeclaredVariable : 8 occurrences // PhanPluginDuplicateSwitchCaseLooseEquality : 6 occurrences - // PhanUndeclaredClassMethod : 6 occurrences + // PhanNonClassMethodCall : 5 occurrences // PhanRedundantCondition : 4 occurrences // PhanTypeExpectedObjectPropAccess : 4 occurrences // PhanTypeMismatchArgumentInternal : 4 occurrences - // PhanUndeclaredClassProperty : 4 occurrences - // PhanUndeclaredTypeReturnType : 4 occurrences - // PhanNonClassMethodCall : 3 occurrences + // PhanUndeclaredClassMethod : 4 occurrences // PhanTypeArraySuspicious : 3 occurrences // PhanTypeArraySuspiciousNullable : 3 occurrences // PhanAccessMethodInternal : 2 occurrences @@ -52,25 +50,23 @@ // PhanUndeclaredFunction : 1 occurrence // PhanUndeclaredMethodInCallable : 1 occurrence // PhanUndeclaredStaticMethod : 1 occurrence - // PhanUndeclaredTypeParameter : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'src/class-actions.php' => ['PhanPluginSimplifyExpressionBool', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod'], 'src/class-data-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-dedicated-sender.php' => ['PhanTypeInvalidLeftOperandOfNumericOp'], - 'src/class-functions.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeParameter'], - 'src/class-json-deflate-array-codec.php' => ['PhanTypeMismatchArgument'], + 'src/class-functions.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredClassMethod'], 'src/class-listener.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-lock.php' => ['PhanTypeMismatchReturn'], 'src/class-modules.php' => ['PhanUndeclaredMethodInCallable'], - 'src/class-queue.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredClassProperty'], + 'src/class-queue.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal'], 'src/class-replicastore.php' => ['PhanAccessMethodInternal', 'PhanParamSignatureMismatch', 'PhanPluginDuplicateSwitchCaseLooseEquality', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredStaticMethod'], 'src/class-rest-endpoints.php' => ['PhanParamTooMany', 'PhanParamTooManyCallable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredMethod'], 'src/class-rest-sender.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal'], - 'src/class-sender.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeReturnType'], + 'src/class-sender.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethod'], 'src/class-server.php' => ['PhanTypeMismatchDeclaredParam', 'PhanTypeMismatchReturnProbablyReal'], - 'src/class-settings.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassMethod'], + 'src/class-settings.php' => ['PhanNonClassMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'src/class-utils.php' => ['PhanTypeExpectedObjectPropAccess'], 'src/modules/class-callables.php' => ['PhanParamSignatureMismatch', 'PhanParamTooMany', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethod'], 'src/modules/class-comments.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethod'], @@ -94,7 +90,6 @@ 'src/modules/class-woocommerce.php' => ['PhanTypeMismatchReturnProbablyReal'], 'src/replicastore/class-table-checksum-usermeta.php' => ['PhanUndeclaredMethod'], 'src/replicastore/class-table-checksum.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchPropertyProbablyReal'], - 'src/sync-queue/class-queue-storage-table.php' => ['PhanUndeclaredClassProperty', 'PhanUndeclaredTypeReturnType'], 'tests/php/test-actions.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/test-dedicated-sender.php' => ['PhanDeprecatedFunction', 'PhanUndeclaredProperty'], 'tests/php/test-rest-endpoints.php' => ['PhanNoopNew', 'PhanTypeMismatchReturn'], diff --git a/projects/packages/sync/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/sync/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/sync/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/sync/src/class-functions.php b/projects/packages/sync/src/class-functions.php index 3da795c6ed64a..3e2e5a5e62659 100644 --- a/projects/packages/sync/src/class-functions.php +++ b/projects/packages/sync/src/class-functions.php @@ -402,8 +402,8 @@ public static function main_network_site_wpcom_id() { * * @deprecated 1.23.1 * - * @param callable $callable Function to retrieve URL option. - * @param string $new_value URL Protocol to set URLs to. + * @param string $callable Function name that was used to retrieve URL option. + * @param string $new_value URL Protocol to set URLs to. * @return string Normalized URL. */ public static function get_protocol_normalized_url( $callable, $new_value ) { @@ -596,8 +596,8 @@ public static function get_is_fse_theme() { * * @since 1.21.0 * - * @param array|obj $any Source data to be cleaned up. - * @param array $seen_nodes Built array of nodes. + * @param mixed $any Source data to be cleaned up. + * @param array $seen_nodes Built array of nodes. * * @return array */ diff --git a/projects/packages/sync/src/class-json-deflate-array-codec.php b/projects/packages/sync/src/class-json-deflate-array-codec.php index 6711ced82b119..a2f443affdc50 100644 --- a/projects/packages/sync/src/class-json-deflate-array-codec.php +++ b/projects/packages/sync/src/class-json-deflate-array-codec.php @@ -52,7 +52,7 @@ public function decode( $input ) { * * @see https://gist.github.com/muhqu/820694 * - * @param string $any Value to serialize and wrap. + * @param mixed $any Value to serialize and wrap. * * @return false|string */ diff --git a/projects/packages/sync/src/class-package-version.php b/projects/packages/sync/src/class-package-version.php index f8e05beb91fdd..b34ede89213a6 100644 --- a/projects/packages/sync/src/class-package-version.php +++ b/projects/packages/sync/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '2.13.1'; + const PACKAGE_VERSION = '2.13.2-alpha'; const PACKAGE_SLUG = 'sync'; diff --git a/projects/packages/sync/src/class-sender.php b/projects/packages/sync/src/class-sender.php index 83741d04c4a3d..f27301f6a99f9 100644 --- a/projects/packages/sync/src/class-sender.php +++ b/projects/packages/sync/src/class-sender.php @@ -702,7 +702,7 @@ public function do_sync_for_queue( $queue ) { * @param string $action_name The action. * @param array $data The data associated with the action. * - * @return Items processed. TODO: this doesn't make much sense anymore, it should probably be just a bool. + * @return array Items processed. TODO: this doesn't make much sense anymore, it should probably be just a bool. */ public function send_action( $action_name, $data = null ) { if ( ! Settings::is_sender_enabled( 'full_sync' ) ) { diff --git a/projects/packages/sync/src/sync-queue/class-queue-storage-options.php b/projects/packages/sync/src/sync-queue/class-queue-storage-options.php index 73421389a37f7..865d6b3b190da 100644 --- a/projects/packages/sync/src/sync-queue/class-queue-storage-options.php +++ b/projects/packages/sync/src/sync-queue/class-queue-storage-options.php @@ -242,7 +242,7 @@ public function add_all( $items, $id_prefix ) { * * @param int $max_count How many items to fetch from the queue. * - * @return \stdClass[]|null + * @return object[]|null */ public function get_items_ids_with_size( $max_count ) { global $wpdb; diff --git a/projects/packages/sync/src/sync-queue/class-queue-storage-table.php b/projects/packages/sync/src/sync-queue/class-queue-storage-table.php index 09089f6532338..998bd0d1ddf84 100644 --- a/projects/packages/sync/src/sync-queue/class-queue-storage-table.php +++ b/projects/packages/sync/src/sync-queue/class-queue-storage-table.php @@ -222,7 +222,7 @@ public function insert_item( $item_id, $item ) { * @param int|null $item_count How many items to fetch from the queue. * The parameter is null-able, if no limit on the amount of items. * - * @return array|object|stdClass[]|null + * @return object[]|null */ public function fetch_items( $item_count ) { global $wpdb; @@ -278,7 +278,7 @@ public function fetch_items( $item_count ) { * * @param array $items_ids Items IDs to fetch from the queue. * - * @return array|object|stdClass[]|null + * @return object[]|null */ public function fetch_items_by_ids( $items_ids ) { global $wpdb; @@ -432,7 +432,7 @@ public function add_all( $items, $id_prefix ) { * * @param int $max_count How many items to fetch from the queue. * - * @return array|object|stdClass[]|null + * @return object[]|null */ public function get_items_ids_with_size( $max_count ) { global $wpdb; diff --git a/projects/packages/videopress/.phan/baseline.php b/projects/packages/videopress/.phan/baseline.php index 8767f65c19465..0cc5e97c52afd 100644 --- a/projects/packages/videopress/.phan/baseline.php +++ b/projects/packages/videopress/.phan/baseline.php @@ -11,9 +11,9 @@ // # Issue statistics: // PhanPluginDuplicateConditionalNullCoalescing : 20+ occurrences // PhanUndeclaredClassMethod : 10+ occurrences - // PhanTypeMismatchReturn : 8 occurrences // PhanUndeclaredProperty : 8 occurrences // PhanTypeMismatchArgumentProbablyReal : 7 occurrences + // PhanTypeMismatchReturn : 7 occurrences // PhanTypeArraySuspicious : 6 occurrences // PhanTypeMismatchReturnProbablyReal : 6 occurrences // PhanUnextractableAnnotation : 5 occurrences @@ -24,12 +24,11 @@ // PhanUndeclaredFunction : 4 occurrences // PhanNoopNew : 3 occurrences // PhanParamTooMany : 3 occurrences - // PhanUndeclaredMethod : 3 occurrences // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeInvalidDimOffset : 2 occurrences - // PhanUndeclaredClassConstant : 2 occurrences // PhanUndeclaredConstant : 2 occurrences // PhanUndeclaredExtendedClass : 2 occurrences + // PhanUndeclaredMethod : 2 occurrences // PhanUndeclaredMethodInCallable : 2 occurrences // PhanUndeclaredTypeThrowsType : 2 occurrences // PhanAccessMethodInternal : 1 occurrence @@ -38,23 +37,21 @@ // PhanRedundantCondition : 1 occurrence // PhanTypeMismatchArgumentInternal : 1 occurrence // PhanTypeMismatchArgumentNullableInternal : 1 occurrence - // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMismatchReturnNullable : 1 occurrence // PhanUndeclaredClass : 1 occurrence + // PhanUndeclaredClassConstant : 1 occurrence // PhanUndeclaredClassReference : 1 occurrence - // PhanUndeclaredTypeProperty : 1 occurrence - // PhanUndeclaredTypeReturnType : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/class-access-control.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassConstant', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredConstant', 'PhanUndeclaredFunction'], + 'src/class-access-control.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanUndeclaredClassConstant', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredConstant', 'PhanUndeclaredFunction'], 'src/class-admin-ui.php' => ['PhanUndeclaredClassMethod'], 'src/class-attachment-handler.php' => ['PhanNonClassMethodCall', 'PhanTypeArraySuspicious'], 'src/class-block-editor-content.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-block-editor-extensions.php' => ['PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-data.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchReturn'], 'src/class-divi.php' => ['PhanUndeclaredProperty'], - 'src/class-initializer.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredMethod'], + 'src/class-initializer.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentNullableInternal'], 'src/class-jwt-token-bridge.php' => ['PhanTypeMismatchReturn'], 'src/class-plan.php' => ['PhanTypeMismatchReturnProbablyReal', 'PhanUnextractableAnnotation'], 'src/class-stats.php' => ['PhanTypeArraySuspiciousNullable'], @@ -69,7 +66,7 @@ 'src/class-xmlrpc.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/tus/class-transient-store.php' => ['PhanParamTooMany'], 'src/tus/class-tus-abstract-cache.php' => ['PhanTypeMismatchArgumentInternal'], - 'src/tus/class-tus-client.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanUndeclaredClassConstant', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType'], + 'src/tus/class-tus-client.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument'], 'src/tus/class-tus-file.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeThrowsType'], 'src/utility-functions.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginUnreachableCode', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredConstant'], 'src/videopress-divi/class-videopress-divi-extension.php' => ['PhanCommentOverrideOnNonOverrideMethod', 'PhanUndeclaredClass', 'PhanUndeclaredClassMethod', 'PhanUndeclaredExtendedClass', 'PhanUndeclaredMethod', 'PhanUndeclaredMethodInCallable', 'PhanUndeclaredProperty'], diff --git a/projects/packages/videopress/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/videopress/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/videopress/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/videopress/package.json b/projects/packages/videopress/package.json index d9b12a9f6f421..ffc6cdd0b757c 100644 --- a/projects/packages/videopress/package.json +++ b/projects/packages/videopress/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-videopress", - "version": "0.23.17", + "version": "0.23.18-alpha", "description": "VideoPress package", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/videopress/#readme", "bugs": { diff --git a/projects/packages/videopress/src/class-access-control.php b/projects/packages/videopress/src/class-access-control.php index fbe2a231e9a84..328f83ce08e4f 100644 --- a/projects/packages/videopress/src/class-access-control.php +++ b/projects/packages/videopress/src/class-access-control.php @@ -61,7 +61,7 @@ public function get_subscription_plan_id( $guid ) { /** * Get the singleton instance. * - * @return AJAX + * @return self */ public static function instance() { if ( null === self::$instance ) { diff --git a/projects/packages/videopress/src/class-package-version.php b/projects/packages/videopress/src/class-package-version.php index f73e5fa29e2f9..276ae07894840 100644 --- a/projects/packages/videopress/src/class-package-version.php +++ b/projects/packages/videopress/src/class-package-version.php @@ -11,7 +11,7 @@ * The Package_Version class. */ class Package_Version { - const PACKAGE_VERSION = '0.23.17'; + const PACKAGE_VERSION = '0.23.18-alpha'; const PACKAGE_SLUG = 'videopress'; diff --git a/projects/packages/videopress/src/tus/class-tus-client.php b/projects/packages/videopress/src/tus/class-tus-client.php index 5bf56a6a33971..df3d412cd6c81 100644 --- a/projects/packages/videopress/src/tus/class-tus-client.php +++ b/projects/packages/videopress/src/tus/class-tus-client.php @@ -43,7 +43,7 @@ class Tus_Client { /** @const string Base API Uri */ const BASE_API_URL = 'https://public-api.wordpress.com/rest/v1.1/video-uploads/%d'; - /** @var Cacheable */ + /** @var Tus_Abstract_Cache */ protected $cache; /** @var string */ @@ -121,7 +121,7 @@ public function __construct( $key, $upload_token, $blog_id ) { /** * Get cache. * - * @return Cacheable + * @return Tus_Abstract_Cache */ public function get_cache() { return $this->cache; diff --git a/projects/packages/waf/.phan/baseline.php b/projects/packages/waf/.phan/baseline.php index a756f862eb525..e3d8fdd992ce5 100644 --- a/projects/packages/waf/.phan/baseline.php +++ b/projects/packages/waf/.phan/baseline.php @@ -39,13 +39,12 @@ // PhanTypeMismatchArgumentNullableInternal : 1 occurrence // PhanTypeMismatchProperty : 1 occurrence // PhanUndeclaredFunctionInCallable : 1 occurrence - // PhanUndeclaredTypeThrowsType : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'cli.php' => ['PhanUndeclaredFunctionInCallable'], 'src/brute-force-protection/class-blocked-login-page.php' => ['PhanNonClassMethodCall', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault'], - 'src/brute-force-protection/class-math-fallback.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredTypeThrowsType'], + 'src/brute-force-protection/class-math-fallback.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal'], 'src/brute-force-protection/class-shared-functions.php' => ['PhanTypeComparisonToArray', 'PhanTypeMismatchReturnProbablyReal', 'PhanUnextractableAnnotationSuffix'], 'src/class-brute-force-protection.php' => ['PhanNoopNew', 'PhanStaticCallToNonStatic', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanUnextractableAnnotationSuffix'], 'src/class-compatibility.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal'], diff --git a/projects/packages/waf/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/waf/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/waf/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/waf/src/brute-force-protection/class-math-fallback.php b/projects/packages/waf/src/brute-force-protection/class-math-fallback.php index 8bfdc377f8e64..2ef3454ab8537 100644 --- a/projects/packages/waf/src/brute-force-protection/class-math-fallback.php +++ b/projects/packages/waf/src/brute-force-protection/class-math-fallback.php @@ -44,9 +44,7 @@ private static function time_window() { /** * Verifies that a user answered the math problem correctly while logging in. * - * @return bool Returns true if the math is correct - * @throws Error If insuffient $_POST variables are present. - * @throws Error Message if the math is wrong. + * @return bool Returns true if the math is correct. Exits if not. */ public static function math_authenticate() { if ( isset( $_COOKIE['jpp_math_pass'] ) ) { @@ -90,6 +88,7 @@ public static function math_authenticate() { * Creates an interim page to collect answers to a math captcha * * @param string $error - the error message. + * @return never */ public static function generate_math_page( $error = false ) { ob_start(); diff --git a/projects/packages/wp-js-data-sync/.phan/baseline.php b/projects/packages/wp-js-data-sync/.phan/baseline.php index e35cb8f6e021d..e6476f7f100f0 100644 --- a/projects/packages/wp-js-data-sync/.phan/baseline.php +++ b/projects/packages/wp-js-data-sync/.phan/baseline.php @@ -10,24 +10,22 @@ return [ // # Issue statistics: // PhanNonClassMethodCall : 10+ occurrences - // PhanUndeclaredClassMethod : 8 occurrences // PhanCommentParamWithoutRealParam : 6 occurrences - // PhanTypeMismatchArgument : 4 occurrences + // PhanParamTooFew : 6 occurrences // PhanUndeclaredMethod : 4 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 2 occurrences // PhanTypeMismatchArgumentProbablyReal : 2 occurrences // PhanTypeMismatchReturn : 2 occurrences - // PhanUndeclaredTypeParameter : 2 occurrences // PhanUnreferencedUseNormal : 2 occurrences // PhanImpossibleCondition : 1 occurrence // PhanImpossibleTypeComparison : 1 occurrence - // PhanParamTooFew : 1 occurrence // PhanParamTooMany : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence // PhanRedundantCondition : 1 occurrence // PhanTypeMismatchArgumentNullable : 1 occurrence // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMissingReturn : 1 occurrence + // PhanUndeclaredTypeParameter : 1 occurrence // PhanUnextractableAnnotation : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions @@ -43,7 +41,7 @@ 'src/schema/types/class-type-assoc-array.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn'], 'src/schema/types/class-type-string.php' => ['PhanImpossibleTypeComparison'], 'tests/php/schema/integration/test-integration-fallback-values.php' => ['PhanNonClassMethodCall'], - 'tests/php/schema/integration/test-integration-parsing-errors.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeParameter'], + 'tests/php/schema/integration/test-integration-parsing-errors.php' => ['PhanNonClassMethodCall', 'PhanParamTooFew', 'PhanTypeMismatchReturn'], 'tests/php/schema/type/test-type-assoc-array.php' => ['PhanTypeMismatchArgumentProbablyReal'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/wp-js-data-sync/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/packages/wp-js-data-sync/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/packages/wp-js-data-sync/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/packages/wp-js-data-sync/package.json b/projects/packages/wp-js-data-sync/package.json index ecae095440425..fe405c31d93ea 100644 --- a/projects/packages/wp-js-data-sync/package.json +++ b/projects/packages/wp-js-data-sync/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-wp-js-data-sync", - "version": "0.4.4", + "version": "0.4.5-alpha", "description": "A package to setup REST API and script localization to pass data to a JavaScript client.", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/wp-js-data-sync/#readme", "bugs": { diff --git a/projects/packages/wp-js-data-sync/src/class-data-sync.php b/projects/packages/wp-js-data-sync/src/class-data-sync.php index b1da29452d7eb..71bfa8e72da2a 100644 --- a/projects/packages/wp-js-data-sync/src/class-data-sync.php +++ b/projects/packages/wp-js-data-sync/src/class-data-sync.php @@ -69,7 +69,7 @@ final class Data_Sync { - const PACKAGE_VERSION = '0.4.4'; + const PACKAGE_VERSION = '0.4.5-alpha'; /** * @var Registry diff --git a/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php b/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php index 5cc904fc41f42..2be37edcb33c2 100755 --- a/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php +++ b/projects/packages/wp-js-data-sync/tests/php/schema/integration/test-integration-parsing-errors.php @@ -1,5 +1,6 @@ ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious'], 'app/features/setup-prompt/Setup_Prompt.php' => ['PhanTypeMissingReturn'], 'app/lib/Environment_Change_Detector.php' => ['PhanCommentParamOutOfOrder'], - 'app/lib/Status.php' => ['PhanTypeArraySuspiciousNullable', 'PhanUndeclaredMethodInCallable'], + 'app/lib/Status.php' => ['PhanTypeArraySuspiciousNullable'], 'app/lib/Super_Cache_Info.php' => ['PhanUndeclaredFunction'], 'app/lib/class-cli.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanUndeclaredConstantOfClass'], - 'app/lib/class-minify.php' => ['PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredMethod'], 'app/lib/class-viewport.php' => ['PhanTypeMismatchArgument'], 'app/lib/critical-css/Critical_CSS_State.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable'], 'app/lib/critical-css/Regenerate.php' => ['PhanParamTooMany'], diff --git a/projects/plugins/boost/app/lib/Setup.php b/projects/plugins/boost/app/lib/Setup.php index 28b378526872d..f89fdf0eefd49 100644 --- a/projects/plugins/boost/app/lib/Setup.php +++ b/projects/plugins/boost/app/lib/Setup.php @@ -36,9 +36,15 @@ public static function get_instances() { return self::$instances; } + /** + * @template T + * @param class-string $class_name + * @return T|null + */ public static function get_instance_of( $class_name ) { foreach ( self::get_instances() as $instance ) { if ( $instance instanceof $class_name ) { + // @phan-suppress-next-line PhanTypeMismatchReturn -- Phan isn't inferring the type correctly from the `instanceof $class_name` like it's supposed to. return $instance; } } diff --git a/projects/plugins/boost/app/lib/class-minify.php b/projects/plugins/boost/app/lib/class-minify.php index 736c422694625..072d19e753203 100644 --- a/projects/plugins/boost/app/lib/class-minify.php +++ b/projects/plugins/boost/app/lib/class-minify.php @@ -18,7 +18,7 @@ class Minify { /** - * @var Minify - Holds the CssMin\Minifier instance, for reuse on subsequent calls. + * @var CSSMinifier - Holds the CssMin\Minifier instance, for reuse on subsequent calls. */ private static $css_minifier; diff --git a/projects/plugins/boost/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/plugins/boost/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/plugins/boost/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/plugins/inspect/.phan/baseline.php b/projects/plugins/inspect/.phan/baseline.php index a788d1c404050..8b314a1552ea0 100644 --- a/projects/plugins/inspect/.phan/baseline.php +++ b/projects/plugins/inspect/.phan/baseline.php @@ -9,13 +9,10 @@ */ return [ // # Issue statistics: - // PhanUndeclaredClassMethod : 5 occurrences // PhanParamTooMany : 3 occurrences // PhanCommentParamWithoutRealParam : 2 occurrences // PhanTypeMismatchArgumentInternal : 2 occurrences - // PhanUndeclaredTypeParameter : 2 occurrences // PhanAccessMethodInternal : 1 occurrence - // PhanImpossibleCondition : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence // PhanUndeclaredInvokeInCallable : 1 occurrence // PhanUndeclaredMethodInCallable : 1 occurrence @@ -25,7 +22,7 @@ 'app/Monitor.php' => ['PhanUndeclaredMethodInCallable'], 'app/Options/Monitor_Status.php' => ['PhanTypeMismatchReturn'], 'app/Options/Observer_Settings.php' => ['PhanTypeMismatchArgumentInternal'], - 'app/REST_API/Endpoints/Send_Request.php' => ['PhanImpossibleCondition', 'PhanTypeMismatchArgumentInternal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredInvokeInCallable', 'PhanUndeclaredTypeParameter'], + 'app/REST_API/Endpoints/Send_Request.php' => ['PhanTypeMismatchArgumentInternal', 'PhanUndeclaredInvokeInCallable'], 'app/REST_API/Permissions/Nonce.php' => ['PhanParamTooMany'], 'functions.php' => ['PhanAccessMethodInternal'], 'packages/Async_Option/Async_Option.php' => ['PhanParamTooMany'], diff --git a/projects/plugins/inspect/app/REST_API/Endpoints/Send_Request.php b/projects/plugins/inspect/app/REST_API/Endpoints/Send_Request.php index 56da51a629c25..fca60e6f5ed2d 100644 --- a/projects/plugins/inspect/app/REST_API/Endpoints/Send_Request.php +++ b/projects/plugins/inspect/app/REST_API/Endpoints/Send_Request.php @@ -4,6 +4,7 @@ use Automattic\Jetpack_Inspect\Monitors; use Automattic\Jetpack_Inspect\REST_API\Permissions\Current_User_Admin; +use WP_REST_Request; use WP_REST_Server; /** @@ -49,7 +50,7 @@ public function maybe_get_json( $value ) { /** * Handle the request and return the response. * - * @param Request $request request. + * @param WP_REST_Request $request request. */ public function response( $request ) { @@ -86,7 +87,7 @@ public function response( $request ) { /** * Returns transport function name. * - * @param Request $request request. + * @param WP_REST_Request $request request. */ private function get_transport_function( $request ) { $transport_name = $request->get_param( 'transport' ) ?? 'wp_remote_request'; diff --git a/projects/plugins/inspect/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/plugins/inspect/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..4c732efc39436 --- /dev/null +++ b/projects/plugins/inspect/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index 33c181127a314..c102eac02f95e 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -10,42 +10,42 @@ return [ // # Issue statistics: // PhanTypeMismatchArgument : 550+ occurrences - // PhanUndeclaredMethod : 320+ occurrences // PhanTypeMismatchArgumentProbablyReal : 300+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 290+ occurrences + // PhanUndeclaredMethod : 270+ occurrences // PhanNoopNew : 210+ occurrences - // PhanTypeMismatchReturn : 170+ occurrences - // PhanTypeMismatchReturnProbablyReal : 170+ occurrences - // PhanDeprecatedFunction : 150+ occurrences + // PhanTypeMismatchReturn : 160+ occurrences + // PhanTypeMismatchReturnProbablyReal : 160+ occurrences + // PhanDeprecatedFunction : 140+ occurrences // PhanTypePossiblyInvalidDimOffset : 110+ occurrences // PhanTypeArraySuspiciousNullable : 100+ occurrences - // PhanUndeclaredClassMethod : 85+ occurrences // PhanRedundantCondition : 70+ occurrences // PhanUndeclaredThis : 70+ occurrences // PhanPossiblyUndeclaredVariable : 65+ occurrences // PhanTypeMismatchArgumentNullable : 55+ occurrences // PhanUndeclaredGlobalVariable : 55+ occurrences - // PhanTypeExpectedObjectPropAccess : 50+ occurrences // PhanTypeMismatchArgumentInternal : 50+ occurrences // PhanParamTooMany : 45+ occurrences + // PhanTypeExpectedObjectPropAccess : 45+ occurrences // PhanPluginDuplicateAdjacentStatement : 40+ occurrences // PhanUndeclaredStaticProperty : 40+ occurrences // PhanTypeInvalidDimOffset : 35+ occurrences + // PhanUndeclaredClassMethod : 35+ occurrences // PhanUndeclaredProperty : 35+ occurrences - // PhanParamSignatureMismatch : 30+ occurrences // PhanTypeMismatchPropertyProbablyReal : 30+ occurrences // PhanDeprecatedProperty : 25+ occurrences + // PhanParamSignatureMismatch : 25+ occurrences // PhanPluginSimplifyExpressionBool : 25+ occurrences // PhanTypeMismatchDefault : 25+ occurrences // PhanTypeMissingReturn : 25+ occurrences // PhanUndeclaredFunction : 25+ occurrences // PhanUnextractableAnnotation : 25+ occurrences - // PhanUnextractableAnnotationSuffix : 25+ occurrences // PhanMisspelledAnnotation : 20+ occurrences // PhanTypeArraySuspicious : 20+ occurrences // PhanTypeMismatchArgumentNullableInternal : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanTypeSuspiciousNonTraversableForeach : 20+ occurrences + // PhanUnextractableAnnotationSuffix : 20+ occurrences // PhanPluginDuplicateExpressionAssignmentOperation : 15+ occurrences // PhanPluginMixedKeyNoKey : 15+ occurrences // PhanSuspiciousMagicConstant : 15+ occurrences @@ -62,14 +62,11 @@ // PhanDeprecatedClass : 9 occurrences // PhanUndeclaredMethodInCallable : 9 occurrences // PhanPluginRedundantAssignment : 8 occurrences - // PhanUndeclaredTypeReturnType : 8 occurrences // PhanTypeArraySuspiciousNull : 7 occurrences // PhanTypeMismatchArgumentInternalReal : 7 occurrences // PhanUndeclaredConstant : 7 occurrences // PhanCommentAbstractOnInheritedMethod : 6 occurrences // PhanRedefineFunction : 6 occurrences - // PhanUndeclaredClassProperty : 6 occurrences - // PhanUndeclaredTypeParameter : 6 occurrences // PhanUndeclaredVariableDim : 6 occurrences // PhanUnextractableAnnotationElementName : 6 occurrences // PhanImpossibleCondition : 5 occurrences @@ -86,7 +83,6 @@ // PhanTypeInvalidLeftOperandOfBitwiseOp : 4 occurrences // PhanTypeInvalidRightOperandOfBitwiseOp : 4 occurrences // PhanTypeInvalidRightOperandOfNumericOp : 4 occurrences - // PhanUndeclaredTypeProperty : 4 occurrences // PhanDeprecatedFunctionInternal : 3 occurrences // PhanDeprecatedTrait : 3 occurrences // PhanTypeConversionFromArray : 3 occurrences @@ -121,6 +117,7 @@ // PhanTypeVoidArgument : 1 occurrence // PhanUndeclaredClassReference : 1 occurrence // PhanUndeclaredExtendedClass : 1 occurrence + // PhanUndeclaredTypeReturnType : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ @@ -149,12 +146,12 @@ '_inc/lib/class-jetpack-recommendations.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition'], '_inc/lib/class-jetpack-top-posts-helper.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], '_inc/lib/class.color.php' => ['PhanImpossibleTypeComparison', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeInvalidRightOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDefault'], - '_inc/lib/class.core-rest-api-endpoints.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUnextractableAnnotationSuffix'], - '_inc/lib/class.jetpack-keyring-service-helper.php' => ['PhanEmptyForeach', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeReturnType'], + '_inc/lib/class.core-rest-api-endpoints.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredMethod', 'PhanUnextractableAnnotationSuffix'], + '_inc/lib/class.jetpack-keyring-service-helper.php' => ['PhanEmptyForeach', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanUndeclaredMethod'], '_inc/lib/class.jetpack-password-checker.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchProperty', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchPropertyProbablyReal'], '_inc/lib/class.media-extractor.php' => ['PhanImpossibleCondition', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchDefault', 'PhanTypePossiblyInvalidDimOffset'], '_inc/lib/class.media-summary.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanRedundantCondition', 'PhanTypeArraySuspiciousNull', 'PhanTypeMismatchArgument'], - '_inc/lib/class.media.php' => ['PhanTypeMismatchArgument', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredTypeParameter', 'PhanUnextractableAnnotation'], + '_inc/lib/class.media.php' => ['PhanTypePossiblyInvalidDimOffset', 'PhanUnextractableAnnotation'], '_inc/lib/core-api/class-wpcom-rest-field-controller.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeMissingReturn'], '_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeArraySuspicious', 'PhanTypeComparisonToArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredConstant'], '_inc/lib/core-api/class.jetpack-core-api-site-endpoints.php' => ['PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod'], @@ -169,7 +166,7 @@ '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php' => ['PhanUndeclaredFunction'], '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-podcast-player.php' => ['PhanTypeMismatchReturn'], '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-related-posts.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchReturn'], - '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php' => ['PhanPluginMixedKeyNoKey', 'PhanUndeclaredClassProperty', 'PhanUndeclaredTypeParameter'], + '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php' => ['PhanPluginMixedKeyNoKey'], '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-send-email-preview.php' => ['PhanTypeMismatchReturn'], '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-template-loader.php' => ['PhanTypeMismatchReturnProbablyReal'], '_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginMixedKeyNoKey', 'PhanTypeInvalidLeftOperandOfAdd', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturnProbablyReal'], @@ -180,7 +177,7 @@ '_inc/lib/core-api/wpcom-endpoints/publicize-services.php' => ['PhanParamSignatureMismatch', 'PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument'], '_inc/lib/core-api/wpcom-endpoints/service-api-keys.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchReturnProbablyReal'], '_inc/lib/core-api/wpcom-endpoints/trait-wpcom-rest-api-proxy-request-trait.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanUndeclaredProperty'], - '_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturn', 'PhanTypeMissingReturn', 'PhanUndeclaredTypeReturnType'], + '_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMissingReturn'], '_inc/lib/debugger/class-jetpack-cxn-test-base.php' => ['PhanDeprecatedFunctionInternal', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn'], '_inc/lib/debugger/class-jetpack-cxn-tests.php' => ['PhanPluginSimplifyExpressionBool'], '_inc/lib/debugger/class-jetpack-debug-data.php' => ['PhanPossiblyUndeclaredVariable', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanUndeclaredMethod'], @@ -231,14 +228,11 @@ 'extensions/blocks/pinterest/pinterest.php' => ['PhanMisspelledAnnotation', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable'], 'extensions/blocks/podcast-player/podcast-player.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateExpressionAssignmentOperation'], 'extensions/blocks/podcast-player/templates/playlist-track.php' => ['PhanUndeclaredGlobalVariable'], - 'extensions/blocks/premium-content/_inc/access-check.php' => ['PhanUndeclaredClassMethod'], - 'extensions/blocks/premium-content/_inc/legacy-buttons.php' => ['PhanUndeclaredClassMethod'], - 'extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredClassProperty', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeParameter', 'PhanUnextractableAnnotationSuffix'], + 'extensions/blocks/premium-content/_inc/access-check.php' => ['PhanUndeclaredMethod'], + 'extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument', 'PhanTypeSuspiciousNonTraversableForeach', 'PhanUndeclaredMethod', 'PhanUnextractableAnnotationSuffix'], 'extensions/blocks/premium-content/_inc/subscription-service/class-jetpack-token-subscription-service.php' => ['PhanTypeMismatchReturn'], 'extensions/blocks/premium-content/_inc/subscription-service/class-jwt.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnNullable'], 'extensions/blocks/premium-content/_inc/subscription-service/class-wpcom-online-subscription-service.php' => ['PhanParamSignatureMismatch'], - 'extensions/blocks/premium-content/_inc/subscription-service/include.php' => ['PhanTypeMismatchReturn', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeReturnType'], - 'extensions/blocks/premium-content/login-button/login-button.php' => ['PhanUndeclaredClassMethod'], 'extensions/blocks/rating-star/rating-meta.php' => ['PhanTypeMismatchArgument'], 'extensions/blocks/rating-star/rating-star.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'extensions/blocks/repeat-visitor/repeat-visitor.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], @@ -366,12 +360,11 @@ 'modules/comments/base.php' => ['PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'], 'modules/comments/comments.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanUndeclaredFunction'], 'modules/comments/subscription-modal-on-comment/class-jetpack-subscription-modal-on-comment.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnNullable'], - 'modules/contact-form/admin.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredMethod'], - 'modules/contact-form/grunion-contact-form.php' => ['PhanDeprecatedClass', 'PhanDeprecatedFunction', 'PhanDeprecatedProperty', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredStaticProperty', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeProperty', 'PhanUnextractableAnnotationElementName'], + 'modules/contact-form/grunion-contact-form.php' => ['PhanDeprecatedClass', 'PhanDeprecatedFunction', 'PhanDeprecatedProperty', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredStaticProperty', 'PhanUnextractableAnnotationElementName'], 'modules/copy-post.php' => ['PhanNoopNew'], 'modules/custom-css/csstidy/class.csstidy-ctype.php' => ['PhanRedefineFunctionInternal'], 'modules/custom-css/csstidy/class.csstidy-optimise.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginSimplifyExpressionBool', 'PhanTypeComparisonFromArray', 'PhanTypeConversionFromArray', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeInvalidRightOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchReturnProbablyReal'], - 'modules/custom-css/csstidy/class.csstidy-print.php' => ['PhanPluginRedundantAssignmentInLoop', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanUndeclaredMethod'], + 'modules/custom-css/csstidy/class.csstidy-print.php' => ['PhanPluginRedundantAssignmentInLoop', 'PhanTypeMismatchReturn'], 'modules/custom-css/csstidy/class.csstidy.php' => ['PhanCompatibleNegativeStringOffset', 'PhanImpossibleCondition', 'PhanInfiniteRecursion', 'PhanParamTooMany', 'PhanRedundantCondition', 'PhanTypeMismatchArgument', 'PhanUnextractableAnnotationSuffix'], 'modules/custom-css/custom-css.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'modules/custom-post-types/comics.php' => ['PhanParamTooMany', 'PhanRedundantCondition', 'PhanTypeMismatchArgument'], @@ -410,13 +403,13 @@ 'modules/masterbar/inline-help/inline-help-template.php' => ['PhanUndeclaredGlobalVariable'], 'modules/masterbar/masterbar/class-masterbar.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'modules/masterbar/profile-edit/bootstrap.php' => ['PhanNoopNew'], - 'modules/memberships/class-jetpack-memberships.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod'], + 'modules/memberships/class-jetpack-memberships.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'], 'modules/module-headings.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], 'modules/monitor.php' => ['PhanNoopNew', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'], 'modules/photon-cdn.php' => ['PhanTypeMismatchArgument'], 'modules/plugin-search.php' => ['PhanTypePossiblyInvalidDimOffset'], 'modules/post-by-email/class-jetpack-post-by-email.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethodInCallable'], - 'modules/publicize.php' => ['PhanNoopNew', 'PhanPluginSimplifyExpressionBool', 'PhanRedefineFunction', 'PhanTypeMismatchProperty', 'PhanUndeclaredTypeProperty'], + 'modules/publicize.php' => ['PhanNoopNew', 'PhanPluginSimplifyExpressionBool', 'PhanRedefineFunction'], 'modules/related-posts/class.related-posts-customize.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing'], 'modules/related-posts/jetpack-related-posts.php' => ['PhanMisspelledAnnotation', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredFunction'], 'modules/scan/class-admin-bar-notice.php' => ['PhanRedundantCondition', 'PhanTypeMismatchReturnProbablyReal'], @@ -553,7 +546,7 @@ 'modules/widgets/simple-payments/form.php' => ['PhanAccessPropertyPrivate', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredThis'], 'modules/widgets/simple-payments/widget.php' => ['PhanTypeArraySuspiciousNullable'], 'modules/widgets/social-icons.php' => ['PhanPluginSimplifyExpressionBool'], - 'modules/widgets/social-media-icons.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredTypeReturnType', 'PhanUnextractableAnnotationSuffix'], + 'modules/widgets/social-media-icons.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturn', 'PhanUnextractableAnnotationSuffix'], 'modules/widgets/top-posts.php' => ['PhanImpossibleTypeComparison', 'PhanParamSignatureMismatch', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanRedundantConditionInLoop'], 'modules/widgets/twitter-timeline.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMissingReturn', 'PhanTypePossiblyInvalidDimOffset'], 'modules/widgets/upcoming-events.php' => ['PhanParamSignatureMismatch', 'PhanRedundantConditionInLoop'], @@ -579,7 +572,6 @@ 'sal/class.json-api-token.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanSuspiciousValueComparison', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanUndeclaredVariable'], 'src/class-jetpack-crm-data.php' => ['PhanUndeclaredFunction'], 'src/class-jetpack-modules-overrides.php' => ['PhanRedundantCondition'], - 'src/class-tracking.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredClassProperty', 'PhanUndeclaredTypeParameter'], 'tests/php/3rd-party/test__atomic.php' => ['PhanTypeMismatchArgument'], 'tests/php/3rd-party/test_class-domain-mapping.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgument'], 'tests/php/3rd-party/test_class.jetpack-amp-support.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -588,7 +580,6 @@ 'tests/php/_inc/lib/test_class.rest-api-authentication.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing'], 'tests/php/_inc/lib/test_class.rest-api-endpoints.php' => ['PhanParamTooMany', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeInvalidLeftOperandOfAdd', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], 'tests/php/core-api/test_class-wpcom-rest-field-controller.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'tests/php/core-api/test_class.jetpack-core-api-module-endpoints.php' => ['PhanUndeclaredMethod'], 'tests/php/core-api/test_class.jetpack-core-api-xmlrpc-consumer-endpoint.php' => ['PhanDeprecatedFunction'], 'tests/php/core-api/wpcom-endpoints/test-class-wpcom-rest-api-v2-endpoint-admin-menu.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchReturn'], 'tests/php/core-api/wpcom-endpoints/test-class-wpcom-rest-api-v2-endpoint-external-media.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument'], @@ -596,7 +587,7 @@ 'tests/php/core-api/wpcom-fields/class-test-wpcom-rest-api-v2-attachment-videopress-data.php' => ['PhanDeprecatedFunction', 'PhanUndeclaredClassMethod'], 'tests/php/core-api/wpcom-fields/test-attachment-fields-videopress.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/core-api/wpcom-fields/test-post-fields-publicize-connections.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeComparisonToArray', 'PhanTypeMismatchPropertyProbablyReal'], - 'tests/php/extensions/blocks/premium-content/test_class.jetpack-premium-content.php' => ['PhanDeprecatedProperty', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMissingReturn', 'PhanUndeclaredClassMethod'], + 'tests/php/extensions/blocks/premium-content/test_class.jetpack-premium-content.php' => ['PhanDeprecatedProperty', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMissingReturn', 'PhanUndeclaredMethod'], 'tests/php/extensions/blocks/test-story.php' => ['PhanUndeclaredMethodInCallable'], 'tests/php/general/test-class.jetpack-gutenberg.php' => ['PhanPluginDuplicateAdjacentStatement'], 'tests/php/general/test-class.jetpack-options.php' => ['PhanTypeMismatchArgument'], @@ -614,7 +605,7 @@ 'tests/php/media/test-class.jetpack-media-extractor.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/media/test-class.jetpack-post-images.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'tests/php/modules/contact-form/test-class.grunion-contact-form.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchReturnSuperType', 'PhanUndeclaredMethod'], - 'tests/php/modules/geo-location/test_class.jetpack-geo-location.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredTypeReturnType'], + 'tests/php/modules/geo-location/test_class.jetpack-geo-location.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/modules/google-analytics/test-class.google-analytics.php' => ['PhanDeprecatedFunction'], 'tests/php/modules/google-analytics/test-class.jetpack-google-amp-analytics.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredMethod'], 'tests/php/modules/masterbar/test-class-admin-color-schemes.php' => ['PhanNoopNew'], @@ -657,7 +648,7 @@ 'tests/php/sync/test-class.jetpack-sync-checksum.php' => ['PhanNoopNew', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'], 'tests/php/sync/test_class.jetpack-sync-actions.php' => ['PhanUndeclaredMethod'], 'tests/php/sync/test_class.jetpack-sync-base.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn'], - 'tests/php/sync/test_class.jetpack-sync-callables.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMissingReturn', 'PhanUndeclaredClassReference', 'PhanUndeclaredFunctionInCallable', 'PhanUndeclaredMethod'], + 'tests/php/sync/test_class.jetpack-sync-callables.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMissingReturn', 'PhanUndeclaredClassReference', 'PhanUndeclaredMethod'], 'tests/php/sync/test_class.jetpack-sync-comments.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredMethod'], 'tests/php/sync/test_class.jetpack-sync-constants.php' => ['PhanUndeclaredMethod'], 'tests/php/sync/test_class.jetpack-sync-full-immediately.php' => ['PhanParamTooMany', 'PhanPluginDuplicateAdjacentStatement', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredVariableDim'], diff --git a/projects/plugins/jetpack/3rd-party/class-domain-mapping.php b/projects/plugins/jetpack/3rd-party/class-domain-mapping.php index 5f03116629d3e..23e560403e14d 100644 --- a/projects/plugins/jetpack/3rd-party/class-domain-mapping.php +++ b/projects/plugins/jetpack/3rd-party/class-domain-mapping.php @@ -150,7 +150,7 @@ public function function_exists( $function ) { * Returns the Domain_Map::utils() instance. * * @see https://github.com/wpmudev/domain-mapping/blob/master/classes/Domainmap/Utils.php - * @return Domainmap_Utils + * @return \Domainmap_Utils */ public function get_domain_mapping_utils_instance() { return \domain_map::utils(); diff --git a/projects/plugins/jetpack/_inc/lib/class.jetpack-keyring-service-helper.php b/projects/plugins/jetpack/_inc/lib/class.jetpack-keyring-service-helper.php index 7468736c8fc15..50790cf9d6ee0 100644 --- a/projects/plugins/jetpack/_inc/lib/class.jetpack-keyring-service-helper.php +++ b/projects/plugins/jetpack/_inc/lib/class.jetpack-keyring-service-helper.php @@ -123,7 +123,7 @@ public function get_services( $filter = 'all' ) { * @param string $service Shortname of a specific service. * @param array $params Parameters to append to an API connection URL. * - * @return URL to specific public-api process + * @return string URL to specific public-api process */ private static function api_url( $service = false, $params = array() ) { /** diff --git a/projects/plugins/jetpack/_inc/lib/class.media.php b/projects/plugins/jetpack/_inc/lib/class.media.php index aa58cedee469a..0c3b88063414d 100644 --- a/projects/plugins/jetpack/_inc/lib/class.media.php +++ b/projects/plugins/jetpack/_inc/lib/class.media.php @@ -222,9 +222,9 @@ public static function get_snapshot( $media_item ) { /** * Add a new item into revision_history array. * - * @param object $media_item - media post object. - * @param file $file - file recently added. - * @param bool $has_original_media - condition is the original media has been already added. + * @param object $media_item - media post object. + * @param array|WP_Error $file - File data, or WP_Error on error. + * @param bool $has_original_media - condition is the original media has been already added. * @return bool `true` if the item has been added. Otherwise `false`. */ public static function register_revision( $media_item, $file, $has_original_media ) { diff --git a/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php b/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php index 4361110b6429b..aae8a47b52be5 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php @@ -543,7 +543,7 @@ private function decode_special_characters( $value ) { * @type string $slug Module slug. * } * - * @return bool|WP_Error True if module was updated. Otherwise, a WP_Error instance with the corresponding error. + * @return bool|WP_REST_Response|WP_Error True or a WP_REST_Response if module was updated. Otherwise, a WP_Error instance with the corresponding error. */ public function update_data( $request ) { diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php index 404565bea9cea..3d08e4425698f 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-resolve-redirect.php @@ -113,10 +113,10 @@ public function get_item_schema() { /** * Finds the destination url from an http response. * - * @todo Add WpOrg\Requests\Response type hint to method when wpcom picks up the new Requests lib (it seems it was skipped during their update to 6.2) + * @todo Add WpOrg\Requests\Response type hint to method when wpcom picks up the new Requests lib (it seems it was skipped during their update to 6.2). * - * @param \WpOrg\Requests\Response|Requests_Response $response Response object. - * @return string Final url of the response. + * @param \WpOrg\Requests\Response $response Response object. + * @return string Final url of the response. */ protected function get_response_url( $response ) { $history = $response->history; diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php index bb3fb37535c6a..6c611f9b66afa 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php @@ -258,7 +258,7 @@ public function get( $post_array, $request ) { // phpcs:ignore VariableAnalysis. * @param object $post Post data to insert/update. * @param WP_REST_Request $request API request. * - * @return Filtered $post + * @return object|WP_Error Filtered $post */ public function rest_pre_insert( $post, $request ) { if ( ! isset( $request['jetpack_publicize_connections'] ) ) { diff --git a/projects/plugins/jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc b/projects/plugins/jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc new file mode 100644 index 0000000000000..13ac7475b04bd --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-more-phan-undefined-because-of-phpdoc @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Fix a bunch of phpdocs to make Phan happier. No change to functionality. + + diff --git a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php index 4b4b8d2b49814..ae14b4099979b 100644 --- a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php +++ b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php @@ -507,9 +507,9 @@ private function token_from_request() { /** * Return true if any ID/date pairs are valid. Otherwise false. * - * @param int[] $valid_plan_ids List of valid plan IDs. - * @param array $token_subscriptions : ID must exist in the provided $valid_subscriptions parameter. - * The provided end date needs to be greater than now(). + * @param int[] $valid_plan_ids List of valid plan IDs. + * @param array $token_subscriptions : ID must exist in the provided $valid_subscriptions parameter. + * The provided end date needs to be greater than now(). * * @return bool */ diff --git a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/include.php b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/include.php index 6af2319dd9cae..44abce925824b 100644 --- a/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/include.php +++ b/projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/include.php @@ -16,6 +16,7 @@ require_once __DIR__ . '/class-unconfigured-subscription-service.php'; use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Jetpack_Token_Subscription_Service; +use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Subscription_Service; use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Unconfigured_Subscription_Service; use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\WPCOM_Online_Subscription_Service; diff --git a/projects/plugins/jetpack/functions.global.php b/projects/plugins/jetpack/functions.global.php index 10872439fe0e7..1cb6eead121ba 100644 --- a/projects/plugins/jetpack/functions.global.php +++ b/projects/plugins/jetpack/functions.global.php @@ -335,8 +335,8 @@ function jetpack_upgrader_pre_download( $reply ) { * @deprecated Automattic\Jetpack\Sync\Functions::json_wrap * - * @param array|object $any Source data to be cleaned up. - * @param array $seen_nodes Built array of nodes. + * @param mixed $any Source data to be cleaned up. + * @param array $seen_nodes Built array of nodes. * * @return array */ diff --git a/projects/plugins/jetpack/modules/contact-form/admin.php b/projects/plugins/jetpack/modules/contact-form/admin.php index 03b5e9540f087..3d13e39b5f2a9 100644 --- a/projects/plugins/jetpack/modules/contact-form/admin.php +++ b/projects/plugins/jetpack/modules/contact-form/admin.php @@ -270,11 +270,12 @@ function grunion_sort_objects( $a, $b ) { * returns both the shortcode form, and HTML markup representing a preview of the form * * @deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Admin->grunion_ajax_shortcode + * @return never */ function grunion_ajax_shortcode() { _deprecated_function( __FUNCTION__, 'jetpack-13.3', 'Automattic\Jetpack\Forms\ContactForm\Admin->grunion_ajax_shortcode' ); - return Grunion_Admin::$instance->grunion_ajax_shortcode(); + Grunion_Admin::$instance->grunion_ajax_shortcode(); } /** @@ -282,11 +283,12 @@ function grunion_ajax_shortcode() { * and constructs a json object representing its contents and attributes. * * @deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Admin->grunion_ajax_shortcode_to_json + * @return never */ function grunion_ajax_shortcode_to_json() { _deprecated_function( __FUNCTION__, 'jetpack-13.3', 'Automattic\Jetpack\Forms\ContactForm\Admin->grunion_ajax_shortcode_to_json' ); - return Grunion_Admin::$instance->grunion_ajax_shortcode_to_json(); + Grunion_Admin::$instance->grunion_ajax_shortcode_to_json(); } /** @@ -403,7 +405,7 @@ class Grunion_Admin { /** * Singleton class instance * - * @var Grunion_Admin Class instance. + * @var Admin Class instance. */ public static $instance; @@ -411,7 +413,7 @@ class Grunion_Admin { * Instantiates this singleton class * * @deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Admin::init - * @return Grunion_Admin The Grunion Admin class instance. + * @return Admin The Grunion Admin class instance. */ public static function init() { _deprecated_function( __METHOD__, 'jetpack-13.3', 'Automattic\Jetpack\Forms\ContactForm\Admin::init' ); diff --git a/projects/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/projects/plugins/jetpack/modules/contact-form/grunion-contact-form.php index d4d60063fbf36..36b0b1792386f 100644 --- a/projects/plugins/jetpack/modules/contact-form/grunion-contact-form.php +++ b/projects/plugins/jetpack/modules/contact-form/grunion-contact-form.php @@ -1104,7 +1104,7 @@ class Crunion_Contact_Form_Shortcode { * We're using object composition to call code from the `forms` package. * This holds the reference to the Contact_Form_Shortcode instance. * - * @var Contact_Form_Shortcode + * @var Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode */ private $shortcode; @@ -1250,7 +1250,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { * Form we are currently looking at. If processed, will become $last * * @deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form - * @var Whatever + * @var Grunion_Contact_Form */ private static $current_form; @@ -1282,7 +1282,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { * We're using object composition to call code from the `forms` package. * This holds the reference to the Contact_Form instance. * - * @var Contact_Form + * @var Automattic\Jetpack\Forms\ContactForm\Contact_Form */ private $form; @@ -1643,7 +1643,7 @@ public static function wrap_message_in_html_tags( $title, $body, $footer ) { * that the message will be flagged as spam. * * @deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form::add_plain_text_alternative - * @param PHPMailer $phpmailer - the phpmailer. + * @param PHPMailer\PHPMailer\PHPMailer $phpmailer - the phpmailer. */ public static function add_plain_text_alternative( $phpmailer ) { _deprecated_function( __METHOD__, 'jetpack-13.3', 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::add_plain_text_alternative' ); diff --git a/projects/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php b/projects/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php index be92e251a9bb8..10576b17ec2d9 100644 --- a/projects/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php +++ b/projects/plugins/jetpack/modules/custom-css/csstidy/class.csstidy-print.php @@ -66,7 +66,7 @@ class csstidy_print { // phpcs:ignore /** * Constructor * - * @param array $css contains the class csstidy. + * @param csstidy $css contains the class csstidy. * @access private * @version 1.0 */ @@ -83,7 +83,7 @@ public function __construct( &$css ) { /** * Call constructor function. * - * @param object $css - the CSS we're working with. + * @param csstidy $css - the CSS we're working with. */ public function csstidy_print( &$css ) { $this->__construct( $css ); diff --git a/projects/plugins/jetpack/modules/publicize.php b/projects/plugins/jetpack/modules/publicize.php index 8e4adfce91724..639bc669266e7 100644 --- a/projects/plugins/jetpack/modules/publicize.php +++ b/projects/plugins/jetpack/modules/publicize.php @@ -24,7 +24,7 @@ class Jetpack_Publicize { /** * Current status about Jetpack modules. * - * @var Modules + * @var Automattic\Jetpack\Modules */ public $modules; diff --git a/projects/plugins/jetpack/modules/widgets/social-media-icons.php b/projects/plugins/jetpack/modules/widgets/social-media-icons.php index 174632e611d5f..cecceb152ff88 100644 --- a/projects/plugins/jetpack/modules/widgets/social-media-icons.php +++ b/projects/plugins/jetpack/modules/widgets/social-media-icons.php @@ -289,9 +289,9 @@ class="widefat" * Update Widget Settings. * * @access public - * @param mixed $new_instance New Instance. - * @param mixed $old_instance Old Instance. - * @return Instance. + * @param array $new_instance New Instance. + * @param array|null $old_instance Old Instance. + * @return array Instance. */ public function update( $new_instance, $old_instance ) { $instance = (array) $old_instance; @@ -324,8 +324,8 @@ public function update( $new_instance, $old_instance ) { * Remove username from value before to save stats. * * @access public - * @param mixed $val Value. - * @return Value. + * @param string $val Value. + * @return string Value. */ public function remove_username( $val ) { return str_replace( '_username', '', $val ); diff --git a/projects/plugins/jetpack/src/class-tracking.php b/projects/plugins/jetpack/src/class-tracking.php index db8898e01e38c..86513ff405779 100644 --- a/projects/plugins/jetpack/src/class-tracking.php +++ b/projects/plugins/jetpack/src/class-tracking.php @@ -10,6 +10,7 @@ use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\IP\Utils as IP_Utils; use Automattic\Jetpack\Tracking as Tracks; +use IXR_Error; use WP_Error; use WP_User; @@ -222,7 +223,7 @@ public function jetpack_xmlrpc_server_event( $action, $stage, $parameters = arra 'error_code' => $parameters->get_error_code(), 'error_message' => $parameters->get_error_message(), ); - } elseif ( is_a( $parameters, '\\IXR_Error' ) ) { + } elseif ( is_a( $parameters, IXR_Error::class ) ) { $parameters = array( 'error_code' => $parameters->code, 'error_message' => $parameters->message, diff --git a/projects/plugins/jetpack/tests/php/modules/geo-location/test_class.jetpack-geo-location.php b/projects/plugins/jetpack/tests/php/modules/geo-location/test_class.jetpack-geo-location.php index 9e64ed2fa951d..965481bdfb93d 100644 --- a/projects/plugins/jetpack/tests/php/modules/geo-location/test_class.jetpack-geo-location.php +++ b/projects/plugins/jetpack/tests/php/modules/geo-location/test_class.jetpack-geo-location.php @@ -375,7 +375,7 @@ private function get_instance_with_mock_private_post() { /** * @param string[] $additional_mock_methods * @param boolean $disable_constructor - * @return Jetpack_Geo_Location|PHPUnit_Framework_MockObject_MockObject + * @return Jetpack_Geo_Location&\PHPUnit\Framework\MockObject\MockObject */ private function create_mock_instance( $additional_mock_methods = array(), @@ -386,9 +386,6 @@ private function create_mock_instance( $additional_mock_methods ); - /** - * @var $instance Jetpack_Geo_Location|PHPUnit_Framework_MockObject_MockObject - */ $builder = $this->getMockBuilder( Jetpack_Geo_Location::class ) ->setMethods( $mock_methods ); @@ -402,9 +399,6 @@ private function create_mock_instance( private function mock_is_single() { global $wp_query; - /** - * @var $wp_query WP_Query|PHPUnit_Framework_MockObject_MockObject - */ $wp_query = $this->getMockBuilder( WP_Query::class ) ->setMethods( array( 'is_feed', 'is_single' ) ) ->getMock(); @@ -417,9 +411,6 @@ private function mock_is_single() { private function mock_is_not_single() { global $wp_query; - /** - * @var $wp_query WP_Query|PHPUnit_Framework_MockObject_MockObject - */ $wp_query = $this->getMockBuilder( WP_Query::class ) ->setMethods( array( 'is_feed', 'is_single' ) ) ->getMock(); @@ -432,9 +423,6 @@ private function mock_is_not_single() { private function mock_is_feed() { global $wp_query; - /** - * @var $wp_query WP_Query|PHPUnit_Framework_MockObject_MockObject - */ $wp_query = $this->getMockBuilder( WP_Query::class ) ->setMethods( array( 'is_feed' ) ) ->getMock(); @@ -447,9 +435,6 @@ private function mock_is_feed() { private function mock_is_not_feed() { global $wp_query; - /** - * @var $wp_query WP_Query|PHPUnit_Framework_MockObject_MockObject - */ $wp_query = $this->getMockBuilder( WP_Query::class ) ->setMethods( array( 'is_feed' ) ) ->getMock();