File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 44
55use WP_Error ;
66use WP \OAuth2 ;
7+ use WP \OAuth2 \Types \Type ;
78
89class Authorization {
910 const LOGIN_ACTION = 'oauth2_authorize ' ;
@@ -26,6 +27,7 @@ public function handle_request() {
2627 // Match type to a handler.
2728 $ grant_types = OAuth2 \get_grant_types ();
2829 if ( $ grant_types ) {
30+ /** @var Type $type_handler */
2931 foreach ( array_reverse ( $ grant_types ) as $ type_handler ) {
3032 if ( $ type_handler ->get_response_type_code () === $ type ) {
3133 $ handler = $ type_handler ;
Original file line number Diff line number Diff line change 99
1010namespace WP \OAuth2 ;
1111
12+ use WP \OAuth2 \Types \Type ;
1213use WP_REST_Response ;
1314
1415bootstrap ();
@@ -63,7 +64,7 @@ function rest_oauth2_load_authorize_page() {
6364/**
6465 * Get valid grant types.
6566 *
66- * @return array Map of grant type to handler object.
67+ * @return Type[] Map of grant type to handler object.
6768 */
6869function get_grant_types () {
6970 /**
@@ -73,9 +74,14 @@ function get_grant_types() {
7374 * Note that additional grant types must follow the extension policy in the
7475 * OAuth 2 specification.
7576 *
76- * @param array $grant_types Map of grant type to handler object.
77+ * @param Type[] $grant_types Map of grant type to handler object.
7778 */
78- return apply_filters ( 'oauth2.grant_types ' , array () );
79+ $ grant_types = apply_filters ( 'oauth2.grant_types ' , array () );
80+
81+ return array_filter ( $ grant_types , function ( $ type ) {
82+
83+ return $ type instanceof Type;
84+ } );
7985}
8086
8187/**
You can’t perform that action at this time.
0 commit comments