Skip to content

Commit

Permalink
Fix deprecation notices and raise minimum PHP version to 7.2 (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk authored Nov 29, 2024
1 parent db63a94 commit cb9ceeb
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 70 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ jobs:

strategy:
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

continue-on-error: ${{ matrix.php == '8.3' }}
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

name: "Lint: PHP ${{ matrix.php }}"

Expand All @@ -40,31 +38,11 @@ jobs:
- name: 'Composer: remove PHPUnit (not needed for lint)'
run: composer remove phpunit/phpunit --no-update --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
if: matrix.php != '8.3'
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Install Composer dependencies - ignore PHP restrictions
if: matrix.php == '8.3'
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-req=php+
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Lint PHP files against parse errors - PHP < 7.0"
if: ${{ matrix.php < 7.0 }}
run: composer lint-lt70

- name: "Lint PHP files against parse errors - PHP 7.x"
if: ${{ startsWith( matrix.php, '7' ) }}
run: composer lint7

- name: "Lint PHP files against parse errors - PHP >= 8.0"
if: ${{ matrix.php >= 8.0 }}
run: composer lint-gte80
- name: "Lint PHP files against parse errors"
run: composer lint
29 changes: 8 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
phpunit: ['6.3.1']
wordpress: ['6.0', 'trunk']

include:
- php: '5.6'
phpunit: '5.7.21'
wordpress: '6.0'
- php: '7.2'
phpunit: '6.3.1'
wordpress: '6.0'
Expand All @@ -29,10 +22,16 @@ jobs:
phpunit: '8.5.16'
wordpress: 'trunk'
- php: '8.1'
phpunit: '9.5.27'
phpunit: '9.6.21'
wordpress: 'trunk'
- php: '8.2'
phpunit: '9.5.27'
phpunit: '9.6.21'
wordpress: 'trunk'
- php: '8.3'
phpunit: '9.6.21'
wordpress: 'trunk'
- php: '8.4'
phpunit: '9.6.21'
wordpress: 'trunk'

services:
Expand Down Expand Up @@ -84,18 +83,6 @@ jobs:
with:
composer-options: --ignore-platform-reqs

- name: "Lint PHP files against parse errors - PHP < 7.0"
if: ${{ matrix.phpunit == 'auto' && matrix.php < 7.0 }}
run: composer lint-lt70

- name: "Lint PHP files against parse errors - PHP 7.x"
if: ${{ matrix.phpunit == 'auto' && startsWith( matrix.php, '7' ) }}
run: composer lint7

- name: "Lint PHP files against parse errors - PHP >= 8.0"
if: ${{ matrix.phpunit == 'auto' && matrix.php >= 8.0 }}
run: composer lint-gte80

# Scan the logs for failing tests and surface that information by creating annotations and log file decorations.
- name: Setup problem matcher to provide annotations for PHPUnit test errors and failures
# The JSON file is provided by the `shivammathur/setup-php` action. See https://github.com/shivammathur/setup-php#problem-matchers.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- Contributors: akirk
- Tags: friends, rss, decentralized, social-network, own-your-data
- Requires at least: 5.0
- Requires PHP: 7.2
- Tested up to: 6.7
- License: GPL-2.0-or-later
- Stable tag: 3.2.1
Expand Down
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
},
"prefer-stable": true,
"scripts": {
"lint7": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"lint-lt70": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"lint-gte80": [
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"check-cs": [
Expand Down
2 changes: 1 addition & 1 deletion feed-parsers/class-feed-parser-json-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function discover_available_feeds( $content, $url ) {
*
* @return array An array of feed items.
*/
public function fetch_feed( $url, User_Feed $user_feed = null ) {
public function fetch_feed( $url, ?User_Feed $user_feed = null ) {
$args = array();
$res = wp_safe_remote_request( $url, $args );

Expand Down
2 changes: 1 addition & 1 deletion feed-parsers/class-feed-parser-microformats.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function parse_hfeed( $mf ) {
*
* @return array An array of feed items.
*/
public function fetch_feed( $url, User_Feed $user_feed = null ) {
public function fetch_feed( $url, ?User_Feed $user_feed = null ) {
$mf = Mf2\fetch( $url );
if ( ! $mf ) {
// translators: %s is a URL.
Expand Down
4 changes: 2 additions & 2 deletions feed-parsers/class-feed-parser-simplepie.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function discover_available_feeds( $content, $url ) {
*
* @return array An array of feed items.
*/
public function fetch_feed( $url, User_Feed $user_feed = null ) {
public function fetch_feed( $url, ?User_Feed $user_feed = null ) {
// Use SimplePie which is bundled with WordPress.
$feed = $this->get_simplepie();

Expand Down Expand Up @@ -381,7 +381,7 @@ public function no_comments_feed_available( $text, $post_id ) {
*
* @return array The comments.
*/
public function get_comments( $comments, $post_id, User $friend_user = null, User_Feed $user_feed = null ) {
public function get_comments( $comments, $post_id, ?User $friend_user = null, ?User_Feed $user_feed = null ) {
$comments_url = get_post_meta( $post_id, Feed::COMMENTS_FEED_META, true );
if ( ! $comments_url || ! $friend_user || ! $user_feed ) {
return $comments;
Expand Down
2 changes: 1 addition & 1 deletion feed-parsers/class-feed-parser-v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Feed_Parser_V2 extends Feed_Parser {
*
* @return array An array of feed items.
*/
public function fetch_feed( $url, User_Feed $user_feed = null ) {
public function fetch_feed( $url, ?User_Feed $user_feed = null ) {
return array();
}
}
2 changes: 1 addition & 1 deletion includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ public function render_friends_list() {
* @param string $catch_all The catch all behavior.
* @param \WP_Post $post The post.
*/
public function render_preview_friend_rules( $rules, $catch_all, \WP_Post $post = null ) {
public function render_preview_friend_rules( $rules, $catch_all, ?\WP_Post $post = null ) {
$friend = $this->check_admin_edit_friend_rules();
$friend_posts = new \WP_Query();

Expand Down
4 changes: 2 additions & 2 deletions includes/class-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function retrieve_friend_posts( $ignore_due_date = false ) {
* @param User $friend_user The friend user.
* @return Feed_Item The modified feed item.
*/
public function apply_early_feed_rules( $item, User_Feed $feed = null, User $friend_user = null ) {
public function apply_early_feed_rules( $item, ?User_Feed $feed = null, ?User $friend_user = null ) {
$updated_item = $this->apply_feed_rules( $item, $feed, $friend_user );
if ( $updated_item->_feed_rule_delete ) {
return $updated_item;
Expand All @@ -330,7 +330,7 @@ public function apply_early_feed_rules( $item, User_Feed $feed = null, User $fri
* @param User $friend_user The friend user.
* @return Feed_Item The modified feed item.
*/
public function apply_feed_rules( $item, User_Feed $feed = null, User $friend_user = null ) {
public function apply_feed_rules( $item, ?User_Feed $feed = null, ?User $friend_user = null ) {
if ( is_null( $friend_user ) ) {
return $item;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public function header_widget_title( $title ) {
* @param array $html_attributes HTML attributes.
* @param User $friend_user The friend user.
*/
public function link( $url, $text, array $html_attributes = array(), User $friend_user = null ) {
public function link( $url, $text, array $html_attributes = array(), ?User $friend_user = null ) {
echo wp_kses(
self::get_link( $url, $text, $html_attributes, $friend_user ),
array(
Expand Down Expand Up @@ -996,7 +996,7 @@ public function link( $url, $text, array $html_attributes = array(), User $frien
*
* @return string The link.
*/
public static function get_link( $url, $text, array $html_attributes = array(), User $friend_user = null ) {
public static function get_link( $url, $text, array $html_attributes = array(), ?User $friend_user = null ) {
if ( is_null( $friend_user ) ) {
$friend_user = new User( get_the_author_meta( 'ID' ) );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-user-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class User_Feed {
* @param \WP_Term $term The WordPress term of the feed taxonomy.
* @param User|null $friend_user Optionally the associated User, if available.
*/
public function __construct( \WP_Term $term, User $friend_user = null ) {
public function __construct( \WP_Term $term, ?User $friend_user = null ) {
$this->term = $term;
$this->friend_user = $friend_user;
}
Expand Down
6 changes: 3 additions & 3 deletions libs/Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ public function upgradeRelTagToCategory(DOMElement $el) {
* @param DOMElement $context optionally specify an element from which to parse microformats
* @return array An array containing all the microformats found in the current document
*/
public function parse($convertClassic = true, DOMElement $context = null) {
public function parse($convertClassic = true, ?DOMElement $context = null) {
$this->convertClassic = $convertClassic;
$mfs = $this->parse_recursive($context);

Expand Down Expand Up @@ -1420,7 +1420,7 @@ public function parse($convertClassic = true, DOMElement $context = null) {
* @param int $depth: recursion depth
* @return array
*/
public function parse_recursive(DOMElement $context = null, $depth = 0) {
public function parse_recursive(?DOMElement $context = null, $depth = 0) {
if ( $depth > 2 ) {
return array();
}
Expand Down Expand Up @@ -1529,7 +1529,7 @@ public function parseFromId($id, $convertClassic=true) {
* @param DOMElement $context
* @return DOMNodeList
*/
public function getRootMF(DOMElement $context = null) {
public function getRootMF(?DOMElement $context = null) {
// start with mf2 root class name xpath
$xpaths = array(
'(php:function("\\Friends\\Mf2\\classHasMf2RootClassname", normalize-space(@class)))'
Expand Down
2 changes: 1 addition & 1 deletion tests/class-feed-parser-local-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Feed_Parser_Local_File extends Feed_Parser_SimplePie {
public function __construct( Feed $friends_feed ) {
}

public function fetch_feed( $url, User_Feed $user_feed = null ) {
public function fetch_feed( $url, ?User_Feed $user_feed = null ) {
$file = new \SimplePie_File( $url );
$feed = new \SimplePie();
$feed->set_file( $file );
Expand Down
2 changes: 1 addition & 1 deletion tests/test-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function get_rss2( $url ) {
* @param string $file A SimplePie File.
* @param User $user The optional user, otherwise the friend_id will be used.
*/
private function feed_parsing_test( $file, User $user = null ) {
private function feed_parsing_test( $file, ?User $user = null ) {
if ( is_null( $user ) ) {
$user = new User( $this->friend_id );
}
Expand Down

0 comments on commit cb9ceeb

Please sign in to comment.