diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 64dff583..768fe615 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 }}" @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e439c55..9c95e319 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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' @@ -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: @@ -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. diff --git a/README.md b/README.md index 2ed25e87..0d8e4c8d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/composer.json b/composer.json index 9b8deda1..fbbaa03e 100644 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/feed-parsers/class-feed-parser-json-feed.php b/feed-parsers/class-feed-parser-json-feed.php index 382025a1..acbc8294 100644 --- a/feed-parsers/class-feed-parser-json-feed.php +++ b/feed-parsers/class-feed-parser-json-feed.php @@ -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 ); diff --git a/feed-parsers/class-feed-parser-microformats.php b/feed-parsers/class-feed-parser-microformats.php index 6a758e80..40b5f336 100644 --- a/feed-parsers/class-feed-parser-microformats.php +++ b/feed-parsers/class-feed-parser-microformats.php @@ -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. diff --git a/feed-parsers/class-feed-parser-simplepie.php b/feed-parsers/class-feed-parser-simplepie.php index 96d0326a..5e130ea1 100644 --- a/feed-parsers/class-feed-parser-simplepie.php +++ b/feed-parsers/class-feed-parser-simplepie.php @@ -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(); @@ -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; diff --git a/feed-parsers/class-feed-parser-v2.php b/feed-parsers/class-feed-parser-v2.php index c46c9ee4..854b7e86 100644 --- a/feed-parsers/class-feed-parser-v2.php +++ b/feed-parsers/class-feed-parser-v2.php @@ -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(); } } diff --git a/includes/class-admin.php b/includes/class-admin.php index 1850a227..55b07f46 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -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(); diff --git a/includes/class-feed.php b/includes/class-feed.php index df4de7e5..02f201e6 100644 --- a/includes/class-feed.php +++ b/includes/class-feed.php @@ -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; @@ -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; } diff --git a/includes/class-frontend.php b/includes/class-frontend.php index b8edef20..2ea17458 100644 --- a/includes/class-frontend.php +++ b/includes/class-frontend.php @@ -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( @@ -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' ) ); } diff --git a/includes/class-user-feed.php b/includes/class-user-feed.php index f52dc6ac..e995dbde 100644 --- a/includes/class-user-feed.php +++ b/includes/class-user-feed.php @@ -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; } diff --git a/libs/Mf2/Parser.php b/libs/Mf2/Parser.php index c09fefef..b8837a10 100644 --- a/libs/Mf2/Parser.php +++ b/libs/Mf2/Parser.php @@ -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); @@ -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(); } @@ -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)))' diff --git a/tests/class-feed-parser-local-file.php b/tests/class-feed-parser-local-file.php index ed1dd097..a1914e1d 100644 --- a/tests/class-feed-parser-local-file.php +++ b/tests/class-feed-parser-local-file.php @@ -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 ); diff --git a/tests/test-feed.php b/tests/test-feed.php index e989e2b9..d53bdf5e 100644 --- a/tests/test-feed.php +++ b/tests/test-feed.php @@ -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 ); }