Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP version 7.4 requirement #1034

Merged
merged 9 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
wordpress: [ '5.7', '6.3' ]
php: [ '7.1', '7.4', '8.0', '8.2' ]
php: [ '7.4', '8.0', '8.2' ]
allowed_failure: [ false ]
include:
# Check upcoming WP.
Expand Down Expand Up @@ -67,10 +67,6 @@ jobs:
- name: Start MySQL service
run: sudo systemctl start mysql.service

- name: Setting mysql_native_password for PHP <= 7.3
if: ${{ matrix.php <= 7.3 }}
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'";

- name: Install WordPress environment
run: composer prepare ${{ matrix.wordpress }}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Stable tag: 3.6.0
Requires at least: 4.1
Tested up to: 6.5
Requires PHP: 5.6
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: authors, users, multiple authors, co-authors, multi-author, publishing
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"require": {
"composer/installers": "~1.0",
"php": ">=5.6"
"php": ">=7.4"
},
"require-dev": {
"automattic/vipwpcs": "^2.2",
Expand Down
6 changes: 3 additions & 3 deletions php/api/endpoints/class-coauthors-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function get_item( $request ) {
* @param WP_User|stdClass $coauthor
*/
public static function is_coauthor( $coauthor ): bool {
return is_a( $coauthor, 'WP_User' ) || self::is_guest_author( $coauthor );
return $coauthor instanceof \WP_User || self::is_guest_author( $coauthor );
}

/**
Expand Down Expand Up @@ -320,10 +320,10 @@ public function get_item_schema(): array {
* @return WP_REST_Response|WP_Error
*/
public function prepare_item_for_response( $author, $request ) {

$fields = $this->get_fields_for_response( $request );

if ( is_a( $author, 'WP_User' ) ) {
if ( $author instanceof \WP_User ) {
$author = $author->data;
$author->description = get_user_meta( $author->ID, 'description', true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @since 3.6.0
*/

namespace CoAuthors\Blocks;
namespace CoAuthors\Blocks;

use WP_Block;
/**
Expand Down Expand Up @@ -52,12 +52,12 @@ public static function render_block( array $attributes, string $content, WP_Bloc
if ( empty( $avatar_urls ) ) {
return '';
}

$display_name = esc_html( $author['display_name'] ?? '' );
$link = esc_url( $author['link'] ?? '' );
$is_link = '' !== $link && $attributes['isLink'] ?? false;
$rel = $attributes['rel'] ?? '';
$size = $attributes['size'] ?? array_keys( $avatar_urls )[0];
$size = $attributes['size'] ?? array_key_first( $avatar_urls );
$align = esc_attr( $attributes['align'] ?? '' );

$srcset = array_map(
Expand Down
14 changes: 7 additions & 7 deletions php/blocks/class-blocks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Blocks
*
*
* @package Automattic\CoAuthorsPlus
* @since 3.6.0
*/
Expand All @@ -13,7 +13,7 @@

/**
* Blocks
*
*
* @package CoAuthors
*/
class Blocks {
Expand Down Expand Up @@ -101,14 +101,14 @@ public static function provide_author_archive_context( array $context, array $pa

/**
* Block Uses Author Context
*
*
* @param string $block_name Block name to check for use of author context.
* @return bool Whether the `uses_context` property of the registered block type includes `'co-authors-plus/author'`
*/
public static function block_uses_author_context( string $block_name ): bool {
$block = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );

if ( ! is_a( $block, 'WP_Block_Type' ) ) {
if ( ! $block instanceof \WP_Block_Type ) {
return false;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public static function enqueue_store(): void {
* @return null|array Either an array of data about an author, or null.
*/
public static function get_author_with_api_schema( $author ): ?array {
if ( ! ( is_a( $author, 'stdClass' ) || is_a( $author, 'WP_User' ) ) ) {
if ( ! ( $author instanceof \stdClass || $author instanceof \WP_User ) ) {
return null;
}

Expand Down Expand Up @@ -199,10 +199,10 @@ public static function get_author_with_api_schema( $author ): ?array {

/**
* Get CoAuthors with API Schema
*
*
* Use the global WP_REST_Server to fetch co-authors for a post,
* so that it matches what a user would see in the editor.
*
*
* @since 3.6.0
* @param int $post_id Post ID for querying co-authors.
* @param array $data Co-authors as returned by the REST API.
Expand Down
22 changes: 11 additions & 11 deletions php/class-coauthors-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct( $coauthors_instance ) {
/**
* Register endpoints.
*/
public function add_endpoints() {
public function add_endpoints(): void {
register_rest_route(
static::NS,
static::SEARCH_ROUTE,
Expand Down Expand Up @@ -126,11 +126,11 @@ public function add_endpoints() {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
public function get_coauthors_search_results( $request ) {
public function get_coauthors_search_results( $request ): WP_REST_Response {
$response = array();

$search = strtolower( $request->get_param( 'q' ) );
$ignorable = null === $request->get_param( 'existing_authors' ) ? '' : $request->get_param( 'existing_authors' );
$ignorable = $request->get_param( 'existing_authors' ) ?? '';
$ignore = explode( ',', $ignorable );
$authors = $this->coauthors->search_authors( $search, $ignore );

Expand All @@ -149,7 +149,7 @@ public function get_coauthors_search_results( $request ) {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
public function get_coauthors( $request ) {
public function get_coauthors( $request ): WP_REST_Response {
$response = array();

$this->_build_authors_response( $response, $request );
Expand All @@ -163,7 +163,7 @@ public function get_coauthors( $request ) {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
public function update_coauthors( $request ) {
public function update_coauthors( $request ): WP_REST_Response {

$response = array();

Expand All @@ -185,7 +185,7 @@ public function update_coauthors( $request ) {
* @param mixed $param Value to validate.
* @return bool
*/
public function validate_numeric( $param ) {
public function validate_numeric( $param ): bool {
return is_numeric( $param );
}

Expand All @@ -194,7 +194,7 @@ public function validate_numeric( $param ) {
*
* @return bool
*/
public function can_edit_coauthors() {
public function can_edit_coauthors(): bool {
return $this->coauthors->current_user_can_set_authors();
}

Expand All @@ -205,7 +205,7 @@ public function can_edit_coauthors() {
* @param object $author The result from co-authors methods.
* @return array
*/
public function _format_author_data( $author ) {
public function _format_author_data( $author ): array {

return array(
'id' => esc_html( $author->ID ),
Expand All @@ -223,7 +223,7 @@ public function _format_author_data( $author ) {
* @param array The response array.
* @param int The post ID from the request.
*/
public function _build_authors_response( &$response, $request ) {
public function _build_authors_response( &$response, $request ): void {
$authors = get_coauthors( $request->get_param( 'post_id' ) );

if ( ! empty( $authors ) ) {
Expand All @@ -237,7 +237,7 @@ public function _build_authors_response( &$response, $request ) {
* Add filters to REST endpoints for each post that
* supports co-authors.
*/
public function modify_responses() {
public function modify_responses(): void {

$post_types = $this->coauthors->supported_post_types();

Expand Down Expand Up @@ -266,7 +266,7 @@ public function modify_responses() {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
public function remove_author_link( $response, $post, $request ) {
public function remove_author_link( $response, $post, $request ): WP_REST_Response {
if (
! isset( $request['context'] )
|| 'edit' !== $request['context']
Expand Down
Loading
Loading