Skip to content

Commit 9f19b77

Browse files
Bump phpstan/phpstan-deprecation-rules from 2.0.1 to 2.0.2 (#14114)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent f33c6d3 commit 9f19b77

File tree

11 files changed

+62
-97
lines changed

11 files changed

+62
-97
lines changed

composer.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/AMP/Output_Buffer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ public static function is_needed(): bool {
138138

139139
$has_old_amp_version = ! \defined( '\AMP__VERSION' ) || ( \defined( '\AMP__VERSION' ) && version_compare( \AMP__VERSION, WEBSTORIES_AMP_VERSION, '<' ) );
140140
$amp_available = \function_exists( 'amp_is_available' ) && amp_is_available();
141-
$amp_enabled = \function_exists( 'amp_is_enabled' ) && amp_is_enabled(); // Technically an internal method.
142-
$amp_initialized = did_action( 'amp_init' ) > 0;
143-
$amp_supported_post = \function_exists( 'amp_is_post_supported' ) && amp_is_post_supported( $current_post->ID ?? 0 );
141+
142+
// @phpstan-ignore function.internal
143+
$amp_enabled = \function_exists( 'amp_is_enabled' ) && amp_is_enabled();
144+
$amp_initialized = did_action( 'amp_init' ) > 0;
145+
$amp_supported_post = \function_exists( 'amp_is_post_supported' ) && amp_is_post_supported( $current_post->ID ?? 0 );
144146

145147
return $has_old_amp_version || ! $amp_available || ! $amp_enabled || ! $amp_initialized || ! $amp_supported_post;
146148
}

includes/Media/Media_Source_Taxonomy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public function filter_rest_generated_media_attachments( $args ) {
304304
* @since 1.29.0
305305
*/
306306
private function add_missing_terms(): void {
307+
// @phpstan-ignore function.internal (false positive)
307308
$existing_terms = get_terms(
308309
[
309310
'taxonomy' => $this->get_taxonomy_slug(),

includes/Plugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class Plugin extends ServiceBasedPlugin {
129129
'rest.products' => REST_API\Products_Controller::class,
130130
'rest.publisher_logos' => REST_API\Publisher_Logos_Controller::class,
131131
'rest.status_check_controller' => REST_API\Status_Check_Controller::class,
132-
'rest.stories_autosave' => REST_API\Stories_Autosaves_Controller::class,
133132
'rest.stories_lock' => REST_API\Stories_Lock_Controller::class,
134133
'rest.media' => REST_API\Stories_Media_Controller::class,
135134
'rest.settings' => REST_API\Stories_Settings_Controller::class,

includes/REST_API/Font_Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public function prepare_item_for_response( $item, $request ): WP_REST_Response {
315315
$self = $links['self']['href'];
316316

317317
foreach ( $actions as $rel ) {
318+
// @phpstan-ignore method.internal (false positive)
318319
$response->add_link( $rel, $self );
319320
}
320321
}

includes/REST_API/Stories_Autosaves_Controller.php

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828

2929
namespace Google\Web_Stories\REST_API;
3030

31-
use Google\Web_Stories\Infrastructure\Delayed;
32-
use Google\Web_Stories\Infrastructure\HasRequirements;
33-
use Google\Web_Stories\Infrastructure\Registerable;
34-
use Google\Web_Stories\Infrastructure\Service;
35-
use Google\Web_Stories\Story_Post_Type;
3631
use WP_Post;
3732
use WP_REST_Autosaves_Controller;
3833
use WP_REST_Controller;
@@ -43,11 +38,9 @@
4338
/**
4439
* Stories_Autosaves_Controller class.
4540
*
46-
* Register using register_post_type once https://core.trac.wordpress.org/ticket/56922 is committed.
47-
*
4841
* @phpstan-import-type Schema from \Google\Web_Stories\REST_API\Stories_Base_Controller
4942
*/
50-
class Stories_Autosaves_Controller extends WP_REST_Autosaves_Controller implements Service, Delayed, Registerable, HasRequirements {
43+
class Stories_Autosaves_Controller extends WP_REST_Autosaves_Controller {
5144

5245
/**
5346
* Parent post controller.
@@ -64,58 +57,28 @@ class Stories_Autosaves_Controller extends WP_REST_Autosaves_Controller implemen
6457
*
6558
* @since 1.0.0
6659
*
67-
* @param Story_Post_Type $story_post_type Story_Post_Type instance.
68-
*/
69-
public function __construct( Story_Post_Type $story_post_type ) {
70-
parent::__construct( $story_post_type->get_slug() );
71-
72-
$this->parent_controller = $story_post_type->get_parent_controller();
73-
$this->parent_base = $story_post_type->get_rest_base();
74-
$this->namespace = $story_post_type->get_rest_namespace();
75-
}
76-
77-
/**
78-
* Register the service.
79-
*
80-
* @since 1.7.0
60+
* @param string $parent_post_type Post type of the parent.
8161
*/
82-
public function register(): void {
83-
$this->register_routes();
84-
}
62+
public function __construct( string $parent_post_type ) {
63+
parent::__construct( $parent_post_type );
8564

86-
/**
87-
* Get the action to use for registering the service.
88-
*
89-
* @since 1.7.0
90-
*
91-
* @return string Registration action to use.
92-
*/
93-
public static function get_registration_action(): string {
94-
return 'rest_api_init';
95-
}
65+
/**
66+
* Post type instance.
67+
*
68+
* @var \WP_Post_Type $post_type_object
69+
*/
70+
$post_type_object = get_post_type_object( $parent_post_type );
9671

97-
/**
98-
* Get the action priority to use for registering the service.
99-
*
100-
* @since 1.7.0
101-
*
102-
* @return int Registration action priority to use.
103-
*/
104-
public static function get_registration_action_priority(): int {
105-
return 100;
106-
}
72+
/**
73+
* Parent controller instance.
74+
*
75+
* @var WP_REST_Controller $parent_controller
76+
*/
77+
$parent_controller = $post_type_object->get_rest_controller();
10778

108-
/**
109-
* Get the list of service IDs required for this service to be registered.
110-
*
111-
* Needed because the story post type needs to be registered first.
112-
*
113-
* @since 1.13.0
114-
*
115-
* @return string[] List of required services.
116-
*/
117-
public static function get_requirements(): array {
118-
return [ 'story_post_type' ];
79+
$this->parent_controller = $parent_controller;
80+
$this->parent_base = ! empty( $post_type_object->rest_base ) ? (string) $post_type_object->rest_base : $post_type_object->name;
81+
$this->namespace = ! empty( $post_type_object->rest_namespace ) ? (string) $post_type_object->rest_namespace : 'wp/v2';
11982
}
12083

12184
/**
@@ -195,6 +158,7 @@ public function prepare_item_for_response( $post, $request ): WP_REST_Response {
195158
$response = new WP_REST_Response( $data );
196159
foreach ( $links as $rel => $rel_links ) {
197160
foreach ( $rel_links as $link ) {
161+
// @phpstan-ignore method.internal (false positive)
198162
$response->add_link( $rel, $link['href'], $link['attributes'] );
199163
}
200164
}

includes/REST_API/Stories_Base_Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function prepare_item_for_response( $post, $request ): WP_REST_Response {
147147
$response = new WP_REST_Response( $data );
148148
foreach ( $links as $rel => $rel_links ) {
149149
foreach ( $rel_links as $link ) {
150+
// @phpstan-ignore method.internal (false positive)
150151
$response->add_link( $rel, $link['href'], $link['attributes'] );
151152
}
152153
}

includes/REST_API/Stories_Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function prepare_item_for_response( $post, $request ): WP_REST_Response {
153153
$response = new WP_REST_Response( $data );
154154
foreach ( $links as $rel => $rel_links ) {
155155
foreach ( $rel_links as $link ) {
156+
// @phpstan-ignore method.internal (false positive)
156157
$response->add_link( $rel, $link['href'], $link['attributes'] );
157158
}
158159
}

includes/Story_Post_Type.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
use Google\Web_Stories\Infrastructure\HasMeta;
3232
use Google\Web_Stories\Infrastructure\HasRequirements;
33+
use Google\Web_Stories\REST_API\Stories_Autosaves_Controller;
3334
use Google\Web_Stories\REST_API\Stories_Controller;
3435
use WP_Post;
3536

@@ -331,7 +332,7 @@ public function on_plugin_uninstall(): void {
331332
*/
332333
protected function get_args(): array {
333334
return [
334-
'labels' => [
335+
'labels' => [
335336
'name' => _x( 'Stories', 'post type general name', 'web-stories' ),
336337
'singular_name' => _x( 'Story', 'post type singular name', 'web-stories' ),
337338
'add_new' => __( 'Add New Story', 'web-stories' ),
@@ -367,8 +368,8 @@ protected function get_args(): array {
367368
'item_link_description' => _x( 'A link to a story.', 'navigation link block description', 'web-stories' ),
368369
'item_trashed' => __( 'Story trashed.', 'web-stories' ),
369370
],
370-
'menu_icon' => $this->get_post_type_icon(),
371-
'supports' => [
371+
'menu_icon' => $this->get_post_type_icon(),
372+
'supports' => [
372373
'title', // Used for amp-story[title].
373374
'author',
374375
'editor',
@@ -377,20 +378,21 @@ protected function get_args(): array {
377378
'revisions', // Without this, the REST API will return 404 for an autosave request.
378379
'custom-fields',
379380
],
380-
'rewrite' => [
381+
'rewrite' => [
381382
'slug' => self::REWRITE_SLUG,
382383
'with_front' => false,
383384
'feeds' => true,
384385
],
385-
'public' => true,
386-
'has_archive' => $this->get_has_archive(),
387-
'exclude_from_search' => true,
388-
'show_ui' => true,
389-
'show_in_rest' => true,
390-
'rest_namespace' => self::REST_NAMESPACE,
391-
'rest_controller_class' => Stories_Controller::class,
392-
'capability_type' => [ 'web-story', 'web-stories' ],
393-
'map_meta_cap' => true,
386+
'public' => true,
387+
'has_archive' => $this->get_has_archive(),
388+
'exclude_from_search' => true,
389+
'show_ui' => true,
390+
'show_in_rest' => true,
391+
'rest_namespace' => self::REST_NAMESPACE,
392+
'rest_controller_class' => Stories_Controller::class,
393+
'autosave_rest_controller_class' => Stories_Autosaves_Controller::class,
394+
'capability_type' => [ 'web-story', 'web-stories' ],
395+
'map_meta_cap' => true,
394396
];
395397
}
396398

phpstan.neon.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ parameters:
2121
identifier: requireOnce.fileNotFound
2222
-
2323
identifier: require.fileNotFound
24+
-
25+
identifier: function.internal
26+
path: tests/phpunit/integration/tests
27+
-
28+
identifier: staticMethod.internalClass
29+
path: tests/phpunit/unit/tests
2430
-
2531
message: '/^Parameter #2 \$args of method WP_Customize_Manager::add_setting\(\)/'
2632
path: includes/Admin/Customizer.php

0 commit comments

Comments
 (0)