Skip to content
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
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
/package.json
/package-lock.json
/phpcs.xml
/phpstan.neon
/phpunit.xml
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
/package.json export-ignore
/package-lock.json export-ignore
/phpcs.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/tests export-ignore

17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ jobs:
composer lint-js
composer lint-css

phpstan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: composer
- name: Install PHP dependencies
run: composer install --no-interaction --prefer-dist --no-scripts
- name: PHPStan
run: composer phpstan

analysis:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"dealerdirect/phpcodesniffer-composer-installer": "^v1.2",
"matthiasmullie/minify": "^1.3",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpstan/phpstan": "^2.1",
"slowprog/composer-copy-file": "~0.3",
"squizlabs/php_codesniffer": "^3.13",
"szepeviktor/phpstan-wordpress": "^v2.0",
"wp-coding-standards/wpcs": "^3.3",
"yoast/wp-test-utils": "^1.2"
},
Expand Down Expand Up @@ -62,6 +64,9 @@
"minifycss styles/liveticker.css > styles/liveticker.min.css",
"minifyjs scripts/block.js > scripts/block.min.js",
"minifyjs scripts/liveticker.js > scripts/liveticker.min.js"
],
"phpstan": [
"phpstan analyse --memory-limit=1G"
]
},
"config": {
Expand Down
4 changes: 2 additions & 2 deletions includes/class-scliveticker.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private static function tick_html( string $time, string $title, string $content,
$content = do_shortcode( $content );
}

return '<li class="sclt-tick" data-sclt-tick-id="' . esc_attr( $id ) . '">'
return '<li class="sclt-tick" data-sclt-tick-id="' . esc_attr( (string) $id ) . '">'
. '<span class="sclt-tick-time">' . esc_html( $time ) . '</span>'
. '<span class="sclt-tick-title">' . esc_html( $title ) . '</span>'
. '<div class="sclt-tick-content">' . $content . '</div></li>';
Expand All @@ -463,7 +463,7 @@ public static function tick_html_widget( string $time, string $title, bool $high
$out .= ' class="sclt-widget-new"';
}
if ( $id > 0 ) {
$out .= ' data-sclt-tick-id="' . esc_attr( $id ) . '"';
$out .= ' data-sclt-tick-id="' . esc_attr( (string) $id ) . '"';
}
return $out . '>'
. '<span class="sclt-widget-time">' . esc_html( $time ) . '</span>'
Expand Down
2 changes: 1 addition & 1 deletion includes/class-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function widget( $args, $instance ) {
echo ' sclt-ajax" '
. 'data-sclt-ticker="' . esc_attr( $category ) . '" '
. 'data-sclt-limit="' . esc_attr( $count ) . '" '
. 'data-sclt-last="' . esc_attr( current_datetime()->getTimestamp() );
. 'data-sclt-last="' . esc_attr( (string) current_datetime()->getTimestamp() );
}
echo '"><ul class="sclt-widget">';

Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
level: 5
paths:
- includes/
- stklcode-liveticker.php
ignoreErrors:
- message: '/^Constant SCLIVETICKER_(BASE|DIR) not found\.$/'
path: includes/
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
Loading