Skip to content

Commit c3f5577

Browse files
authored
more fixes
1 parent f1bb049 commit c3f5577

5 files changed

Lines changed: 45 additions & 10 deletions

File tree

.github/workflows/php-sast.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,51 @@ jobs:
2424
# - name: Validate composer.json and composer.lock
2525
# run: composer validate --strict
2626

27+
# This config file gets auto-loaded by PHPStan
28+
- name: Set PHPStan config
29+
run: |
30+
cat <<'EOF' > phpstan.neon
31+
parameters:
32+
level: 1 # form 0 to 11 where 0 is the loosest and 11 the strictest
33+
errorFormat: github
34+
paths:
35+
- plugins/*
36+
stubFiles:
37+
- custom-defs.stub
38+
includes:
39+
- vendor/szepeviktor/phpstan-wordpress/extension.neon
40+
EOF
41+
42+
- name: Create custom stubs for plugin functions. If this grows too big it can be commited as a separate file
43+
run: |
44+
cat <<'EOF' > custom-defs.stub
45+
<?php
46+
47+
// Advanced Custom Fields stubs
48+
if (!function_exists('get_field')) {
49+
/**
50+
* @param string $selector The field name or field key.
51+
* @param mixed $post_id Optional. Post ID, "option", false, or other ACF-supported context.
52+
* @param bool $format_value Optional. Whether to apply formatting logic. Default true.
53+
* @param bool $escape_html Optional. Whether to return escaped HTML.
54+
* Requires $format_value to be true. Default false.
55+
*
56+
* @return mixed|null The field value.
57+
*/
58+
function get_field(
59+
string $selector,
60+
$post_id = false,
61+
bool $format_value = true,
62+
bool $escape_html = false
63+
);
64+
}
65+
EOF
66+
2767
- name: Install PHPStan and Wordpress-stub
2868
run: |
2969
composer require --dev phpstan/phpstan
3070
composer require --dev szepeviktor/phpstan-wordpress
31-
composer config --no-plugins allow-plugins.phpstan/extension-installer true
32-
composer require --dev phpstan/extension-installer
3371
3472
- name: Run PHPStan
35-
run: vendor/bin/phpstan analyse plugins/* --error-format github --no-progress
73+
run: vendor/bin/phpstan analyse --error-format github --no-progress
3674

plugins/bcc-login/includes/class-bcc-login-visibility.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ function on_block_editor_assets() {
487487
* applies to category lists and REST API results.
488488
*
489489
* @param WP_Query $query
490-
* @return WP_Query
490+
* @return void
491491
*/
492492
function filter_pre_get_posts( $query ) {
493493
// Don't filter posts for Phrase
@@ -628,7 +628,6 @@ function filter_pre_get_posts( $query ) {
628628

629629
// Set the meta query to the complete, altered query
630630
$query->set('meta_query', $meta_query);
631-
return;
632631
}
633632

634633
/**
@@ -1159,7 +1158,7 @@ function render_visibility_meta_box_to_attachments( $post ) {
11591158
/**
11601159
* Save visibility value to attachments.
11611160
*/
1162-
function save_visibility_to_attachments( $attach_id ) {
1161+
function save_visibility_to_attachments( $attach_id, $post_after, $post_before ) {
11631162
if ( !current_user_can( 'edit_post', $attach_id ) ) {
11641163
return;
11651164
}

plugins/bcc-login/includes/class-bcc-notifications.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function send_notification($post_id) {
196196

197197
$templates = array_key_exists($wp_lang, $this->settings->notification_templates)
198198
? $this->settings->notification_templates[$wp_lang]
199-
: (array_key_exists($site_language, $this->_settings->notification_templates)
199+
: (array_key_exists($site_language, $this->settings->notification_templates)
200200
? $this->settings->notification_templates[$site_language]
201201
: null);
202202

plugins/bcc-login/includes/class-bcc-storage.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22

33
class BCC_Storage {
4-
private BCC_Encryption $_encryption;
5-
64
private $_encryption_key;
75
private $_encryption_method = "AES-256-CBC";
86

plugins/bcc-post-update-translations-notifier/includes/class-bcc-post-update-translations-notifier-updater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function update( $transient ) {
153153

154154
}
155155

156-
public function purge(){
156+
public function purge( $upgrader_object, $options ){
157157

158158
if (
159159
$this->cache_allowed

0 commit comments

Comments
 (0)