diff --git a/.github/workflows/composer-diff.yml b/.github/workflows/composer-diff.yml
new file mode 100644
index 0000000..295b538
--- /dev/null
+++ b/.github/workflows/composer-diff.yml
@@ -0,0 +1,31 @@
+name: Composer Diff
+on:
+ pull_request:
+ paths:
+ - 'composer.lock'
+jobs:
+ composer-diff:
+ name: Composer Diff
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout
+ with:
+ fetch-depth: 0 # Required to make it possible to compare with PR base branch
+
+ - name: Generate composer diff
+ id: composer_diff # To reference the output in comment
+ uses: IonBazan/composer-diff-action@v1
+
+ - uses: marocchino/sticky-pull-request-comment@v2
+ # An empty diff result will break this action.
+ if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
+ with:
+ header: composer-diff # Creates a collapsed comment with the report
+ message: |
+
+ Composer package changes
+
+ ${{ steps.composer_diff.outputs.composer_diff }}
+
+
diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml
new file mode 100644
index 0000000..8f9583b
--- /dev/null
+++ b/.github/workflows/phpstan.yml
@@ -0,0 +1,36 @@
+name: Run PHPStan
+
+on:
+ # Run on pushes to select branches and on all pull requests.
+ push:
+ branches:
+ - main
+ - develop
+ - 'release/[0-9]+.[0-9]+*'
+ - 'hotfix/[0-9]+.[0-9]+*'
+ pull_request:
+ # Allow manually triggering the workflow.
+ workflow_dispatch:
+
+jobs:
+ phpstan:
+ name: Static Analysis
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: 'latest'
+ coverage: none
+ tools: composer, cs2pr
+
+ - name: Install PHP dependencies
+ uses: ramsey/composer-install@v2
+ with:
+ composer-options: '--prefer-dist --no-scripts'
+
+ - name: PHPStan
+ run: composer phpstan
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index cdf9bb7..63a33ee 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -26,22 +26,19 @@ jobs:
matrix:
include:
- php_version: '7.4'
- wp_version: '5.9'
+ wp_version: '6.2'
multisite: false
- # WP 5.6 is the earliest version which (sort of) supports PHP 8.0.
- php_version: '8.0'
- wp_version: '5.9'
+ wp_version: '6.2'
multisite: false
- # WP 5.9 is the earliest version which (sort of) supports PHP 8.1.
- php_version: '8.1'
wp_version: 'latest'
multisite: true
- # WP 6.1 is the earliest version which supports PHP 8.2.
- php_version: '8.2'
- wp_version: '6.1'
+ wp_version: '6.4'
multisite: true
name: "Integration Test: PHP ${{ matrix.php_version }} | WP ${{ matrix.wp_version }}${{ matrix.multisite == true && ' (+ ms)' || '' }}"
diff --git a/.github/workflows/wp-version-checker.yml b/.github/workflows/wp-version-checker.yml
new file mode 100644
index 0000000..8cad49a
--- /dev/null
+++ b/.github/workflows/wp-version-checker.yml
@@ -0,0 +1,20 @@
+name: "WordPress version checker"
+on:
+ push:
+ branches:
+ - develop
+ - main
+ schedule:
+ - cron: '0 0 * * *'
+
+permissions:
+ issues: write
+
+jobs:
+ wordpress-version-checker:
+ runs-on: ubuntu-latest
+ steps:
+ - name: WordPress version checker
+ uses: skaut/wordpress-version-checker@v2.0.0
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/admin/admin.php b/admin/admin.php
index d932e16..66792a6 100644
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -25,8 +25,10 @@ class Admin {
/**
* Holds the plugins options.
+ *
+ * @var mixed[]
*/
- private array $options = [];
+ public array $options = [];
/**
* The absolute minimum comment length when this plugin is enabled.
@@ -71,7 +73,7 @@ public function show_forward_status( $comment_text, $comment ): string {
return $comment_text;
}
- $ch_forwarded = \get_comment_meta( $comment->comment_ID, 'ch_forwarded' );
+ $ch_forwarded = \get_comment_meta( (int) $comment->comment_ID, 'ch_forwarded' );
if ( $ch_forwarded ) {
/* translators: %s is replaced by the name you're forwarding to. */
$pre = '
' . \sprintf( \esc_html__( 'This comment was forwarded to %s.', 'comment-hacks' ), \esc_html( $this->options['forward_name'] ) ) . '
';
@@ -112,7 +114,7 @@ public function forward_comment(): void {
/* translators: %1$s is replaced by (a link to) the blog's name, %2$s by (a link to) the title of the post. */
\esc_html__( 'This comment was forwarded from %1$s where it was left on: %2$s.', 'comment-hacks' ),
'' . \esc_html( \get_bloginfo( 'name' ) ) . '',
- '' . esc_html( \get_the_title( $comment->comment_post_ID ) ) . ''
+ '' . esc_html( \get_the_title( (int) $comment->comment_post_ID ) ) . ''
) . "\n\n";
if ( ! empty( $this->options['forward_extra'] ) ) {
@@ -360,6 +362,8 @@ private function sanitize_string( $value, $default ) {
/**
* Register the config page for all users that have the manage_options capability.
+ *
+ * @return void
*/
public function add_config_page() {
\add_options_page(
diff --git a/admin/comment-parent.php b/admin/comment-parent.php
index cd1ebfc..f81e7ff 100644
--- a/admin/comment-parent.php
+++ b/admin/comment-parent.php
@@ -20,6 +20,8 @@ public function __construct() {
* Shows the comment parent box where you can change the comment parent.
*
* @param object $comment The comment object.
+ *
+ * @return void
*/
public function comment_parent_box( $comment ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Param used in included file.
require_once \EMILIA_COMMENT_HACKS_PATH . 'admin/views/comment-parent-box.php';
@@ -27,6 +29,8 @@ public function comment_parent_box( $comment ) { // phpcs:ignore Generic.CodeAna
/**
* Adds the comment parent box to the meta box.
+ *
+ * @return void
*/
public function load_comment_parent_box() {
if ( \function_exists( 'add_meta_box' ) ) {
@@ -45,6 +49,8 @@ public function load_comment_parent_box() {
/**
* Updates the comment parent field.
+ *
+ * @return void
*/
public function update_comment_parent() {
$comment_parent = \filter_input( \INPUT_POST, 'epch_comment_parent', \FILTER_VALIDATE_INT );
diff --git a/admin/views/comment-parent-box.php b/admin/views/comment-parent-box.php
index 3ec6cea..0fa3652 100644
--- a/admin/views/comment-parent-box.php
+++ b/admin/views/comment-parent-box.php
@@ -3,6 +3,11 @@
* Parent Box view.
*/
+/**
+ * The comment object.
+ *
+ * @var WP_Comment $comment
+ */
?>